|
1 | 1 | use rustc_data_structures::sync::Lock;
|
2 | 2 | use rustc_hir as hir;
|
3 | 3 | 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}; |
6 | 6 | use rustc_index::bit_set::GrowableBitSet;
|
7 | 7 | use rustc_middle::hir::nested_filter;
|
8 | 8 | use rustc_middle::ty::TyCtxt;
|
@@ -36,13 +36,15 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
|
36 | 36 | }
|
37 | 37 | }
|
38 | 38 |
|
| 39 | +#[cfg(debug_assertions)] |
39 | 40 | struct HirIdValidator<'a, 'hir> {
|
40 | 41 | tcx: TyCtxt<'hir>,
|
41 | 42 | owner: Option<hir::OwnerId>,
|
42 | 43 | hir_ids_seen: GrowableBitSet<ItemLocalId>,
|
43 | 44 | errors: &'a Lock<Vec<String>>,
|
44 | 45 | }
|
45 | 46 |
|
| 47 | +#[cfg(debug_assertions)] |
46 | 48 | impl<'a, 'hir> HirIdValidator<'a, 'hir> {
|
47 | 49 | fn new_visitor(&self, tcx: TyCtxt<'hir>) -> HirIdValidator<'a, 'hir> {
|
48 | 50 | HirIdValidator { tcx, owner: None, hir_ids_seen: Default::default(), errors: self.errors }
|
@@ -114,6 +116,7 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> {
|
114 | 116 | }
|
115 | 117 | }
|
116 | 118 |
|
| 119 | +#[cfg(debug_assertions)] |
117 | 120 | impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
|
118 | 121 | type NestedFilter = nested_filter::OnlyBodies;
|
119 | 122 |
|
|
0 commit comments