Skip to content

Commit bacf1a4

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

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compiler/rustc_passes/src/hir_id_validator.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use rustc_data_structures::sync::Lock;
22
use rustc_hir as hir;
33
use rustc_hir::def_id::LocalDefId;
4-
use rustc_hir::intravisit;
5-
use rustc_hir::{HirId, ItemLocalId};
4+
#[cfg(debug_assertions)]
5+
use rustc_hir::{intravisit, HirId, ItemLocalId};
66
use rustc_index::bit_set::GrowableBitSet;
77
use rustc_middle::hir::nested_filter;
88
use rustc_middle::ty::TyCtxt;
@@ -36,13 +36,15 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
3636
}
3737
}
3838

39+
#[cfg(debug_assertions)]
3940
struct HirIdValidator<'a, 'hir> {
4041
tcx: TyCtxt<'hir>,
4142
owner: Option<hir::OwnerId>,
4243
hir_ids_seen: GrowableBitSet<ItemLocalId>,
4344
errors: &'a Lock<Vec<String>>,
4445
}
4546

47+
#[cfg(debug_assertions)]
4648
impl<'a, 'hir> HirIdValidator<'a, 'hir> {
4749
fn new_visitor(&self, tcx: TyCtxt<'hir>) -> HirIdValidator<'a, 'hir> {
4850
HirIdValidator { tcx, owner: None, hir_ids_seen: Default::default(), errors: self.errors }
@@ -114,6 +116,7 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> {
114116
}
115117
}
116118

119+
#[cfg(debug_assertions)]
117120
impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
118121
type NestedFilter = nested_filter::OnlyBodies;
119122

0 commit comments

Comments
 (0)