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 583d6ba
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions compiler/rustc_passes/src/hir_id_validator.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
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};
use rustc_index::bit_set::GrowableBitSet;
use rustc_middle::hir::nested_filter;
use rustc_middle::ty::TyCtxt;
#[cfg(debug_assertions)]
use ::{
rustc_data_structures::sync::Lock,
rustc_hir as hir,
rustc_hir::def_id::LocalDefId,
rustc_hir::{intravisit, HirId, ItemLocalId},
rustc_index::bit_set::GrowableBitSet,
rustc_middle::hir::nested_filter,
};

pub fn check_crate(tcx: TyCtxt<'_>) {
if tcx.sess.opts.unstable_opts.hir_stats {
Expand Down Expand Up @@ -36,13 +38,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 +118,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 583d6ba

Please sign in to comment.