Skip to content

Commit

Permalink
Add proper cfgs for struct HirIdValidator used only with debug assert…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
mu001999 committed Mar 6, 2024
1 parent 2064c19 commit bacf1a4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions compiler/rustc_passes/src/hir_id_validator.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -36,13 +36,15 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
}
}

#[cfg(debug_assertions)]
struct HirIdValidator<'a, 'hir> {
tcx: TyCtxt<'hir>,
owner: Option<hir::OwnerId>,
hir_ids_seen: GrowableBitSet<ItemLocalId>,
errors: &'a Lock<Vec<String>>,
}

#[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 }
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit bacf1a4

Please sign in to comment.