Skip to content

Commit 583d6ba

Browse files
committed
Add proper cfgs for struct HirIdValidator used only with debug assertions
1 parent 2064c19 commit 583d6ba

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

compiler/rustc_passes/src/hir_id_validator.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
use rustc_data_structures::sync::Lock;
2-
use rustc_hir as hir;
3-
use rustc_hir::def_id::LocalDefId;
4-
use rustc_hir::intravisit;
5-
use rustc_hir::{HirId, ItemLocalId};
6-
use rustc_index::bit_set::GrowableBitSet;
7-
use rustc_middle::hir::nested_filter;
81
use rustc_middle::ty::TyCtxt;
2+
#[cfg(debug_assertions)]
3+
use ::{
4+
rustc_data_structures::sync::Lock,
5+
rustc_hir as hir,
6+
rustc_hir::def_id::LocalDefId,
7+
rustc_hir::{intravisit, HirId, ItemLocalId},
8+
rustc_index::bit_set::GrowableBitSet,
9+
rustc_middle::hir::nested_filter,
10+
};
911

1012
pub fn check_crate(tcx: TyCtxt<'_>) {
1113
if tcx.sess.opts.unstable_opts.hir_stats {
@@ -36,13 +38,15 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
3638
}
3739
}
3840

41+
#[cfg(debug_assertions)]
3942
struct HirIdValidator<'a, 'hir> {
4043
tcx: TyCtxt<'hir>,
4144
owner: Option<hir::OwnerId>,
4245
hir_ids_seen: GrowableBitSet<ItemLocalId>,
4346
errors: &'a Lock<Vec<String>>,
4447
}
4548

49+
#[cfg(debug_assertions)]
4650
impl<'a, 'hir> HirIdValidator<'a, 'hir> {
4751
fn new_visitor(&self, tcx: TyCtxt<'hir>) -> HirIdValidator<'a, 'hir> {
4852
HirIdValidator { tcx, owner: None, hir_ids_seen: Default::default(), errors: self.errors }
@@ -114,6 +118,7 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> {
114118
}
115119
}
116120

121+
#[cfg(debug_assertions)]
117122
impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
118123
type NestedFilter = nested_filter::OnlyBodies;
119124

0 commit comments

Comments
 (0)