diff --git a/compiler/rustc_passes/src/hir_id_validator.rs b/compiler/rustc_passes/src/hir_id_validator.rs index 02f56ecb10b57..f417c26f1ac0f 100644 --- a/compiler/rustc_passes/src/hir_id_validator.rs +++ b/compiler/rustc_passes/src/hir_id_validator.rs @@ -1,8 +1,8 @@ use rustc_data_structures::sync::Lock; use rustc_hir as hir; use rustc_hir::def_id::LocalDefId; -use rustc_hir::intravisit; -use rustc_hir::{HirId, ItemLocalId}; +#[cfg(debug_assertions)] +use rustc_hir::{intravisit, HirId, ItemLocalId}; use rustc_index::bit_set::GrowableBitSet; use rustc_middle::hir::nested_filter; use rustc_middle::ty::TyCtxt; @@ -36,6 +36,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) { } } +#[cfg(debug_assertions)] struct HirIdValidator<'a, 'hir> { tcx: TyCtxt<'hir>, owner: Option, @@ -43,6 +44,7 @@ struct HirIdValidator<'a, 'hir> { errors: &'a Lock>, } +#[cfg(debug_assertions)] impl<'a, 'hir> HirIdValidator<'a, 'hir> { fn new_visitor(&self, tcx: TyCtxt<'hir>) -> HirIdValidator<'a, 'hir> { HirIdValidator { tcx, owner: None, hir_ids_seen: Default::default(), errors: self.errors } @@ -114,6 +116,7 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> { } } +#[cfg(debug_assertions)] impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> { type NestedFilter = nested_filter::OnlyBodies;