Skip to content

Commit d520046

Browse files
committed
test: Visit debuginfos when needed
1 parent 3a1ab06 commit d520046

File tree

10 files changed

+26
-1
lines changed

10 files changed

+26
-1
lines changed

compiler/rustc_middle/src/mir/visit.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ use crate::ty::CanonicalUserTypeAnnotation;
6868
macro_rules! make_mir_visitor {
6969
($visitor_trait_name:ident, $($mutability:ident)?) => {
7070
pub trait $visitor_trait_name<'tcx> {
71+
const VISIT_DEBUG_INFO: bool = false;
72+
7173
// Override these, and call `self.super_xxx` to revert back to the
7274
// default behavior.
7375

@@ -100,7 +102,9 @@ macro_rules! make_mir_visitor {
100102
stmt_debuginfo: & $($mutability)? [StmtDebugInfo<'tcx>],
101103
location: Location
102104
) {
103-
self.super_statement_debuginfos(stmt_debuginfo, location);
105+
if Self::VISIT_DEBUG_INFO {
106+
self.super_statement_debuginfos(stmt_debuginfo, location);
107+
}
104108
}
105109

106110
fn visit_statement_debuginfo(

compiler/rustc_mir_dataflow/src/debuginfo.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ pub fn debuginfo_locals(body: &Body<'_>) -> DenseBitSet<Local> {
1212
struct DebuginfoLocals(DenseBitSet<Local>);
1313

1414
impl Visitor<'_> for DebuginfoLocals {
15+
const VISIT_DEBUG_INFO: bool = true;
16+
1517
fn visit_local(&mut self, local: Local, place_context: PlaceContext, _: Location) {
1618
if place_context == PlaceContext::NonUse(NonUseContext::VarDebugInfo) {
1719
self.0.insert(local);

compiler/rustc_mir_transform/src/copy_prop.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ struct Replacer<'a, 'tcx> {
104104
}
105105

106106
impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
107+
const VISIT_DEBUG_INFO: bool = true;
108+
107109
fn tcx(&self) -> TyCtxt<'tcx> {
108110
self.tcx
109111
}

compiler/rustc_mir_transform/src/dest_prop.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ struct Merger<'tcx> {
292292
}
293293

294294
impl<'tcx> MutVisitor<'tcx> for Merger<'tcx> {
295+
const VISIT_DEBUG_INFO: bool = true;
295296
fn tcx(&self) -> TyCtxt<'tcx> {
296297
self.tcx
297298
}

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,8 @@ impl<'tcx> VnState<'_, 'tcx> {
17491749
}
17501750

17511751
impl<'tcx> MutVisitor<'tcx> for VnState<'_, 'tcx> {
1752+
const VISIT_DEBUG_INFO: bool = true;
1753+
17521754
fn tcx(&self) -> TyCtxt<'tcx> {
17531755
self.tcx
17541756
}

compiler/rustc_mir_transform/src/inline.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,8 @@ impl Integrator<'_, '_> {
12301230
}
12311231

12321232
impl<'tcx> MutVisitor<'tcx> for Integrator<'_, 'tcx> {
1233+
const VISIT_DEBUG_INFO: bool = true;
1234+
12331235
fn tcx(&self) -> TyCtxt<'tcx> {
12341236
self.tcx
12351237
}

compiler/rustc_mir_transform/src/prettify.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ struct LocalUpdater<'tcx> {
148148
}
149149

150150
impl<'tcx> MutVisitor<'tcx> for LocalUpdater<'tcx> {
151+
const VISIT_DEBUG_INFO: bool = true;
152+
151153
fn tcx(&self) -> TyCtxt<'tcx> {
152154
self.tcx
153155
}

compiler/rustc_mir_transform/src/ref_prop.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ fn compute_replacement<'tcx>(
284284
where
285285
F: FnMut(Place<'tcx>, Location) -> bool,
286286
{
287+
const VISIT_DEBUG_INFO: bool = true;
288+
287289
fn visit_place(&mut self, place: &Place<'tcx>, ctxt: PlaceContext, loc: Location) {
288290
if matches!(ctxt, PlaceContext::NonUse(_)) {
289291
// There is no need to check liveness for non-uses.
@@ -354,6 +356,8 @@ struct Replacer<'tcx> {
354356
}
355357

356358
impl<'tcx> MutVisitor<'tcx> for Replacer<'tcx> {
359+
const VISIT_DEBUG_INFO: bool = true;
360+
357361
fn tcx(&self) -> TyCtxt<'tcx> {
358362
self.tcx
359363
}

compiler/rustc_mir_transform/src/simplify.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,8 @@ struct LocalUpdater<'tcx> {
669669
}
670670

671671
impl<'tcx> MutVisitor<'tcx> for LocalUpdater<'tcx> {
672+
const VISIT_DEBUG_INFO: bool = true;
673+
672674
fn tcx(&self) -> TyCtxt<'tcx> {
673675
self.tcx
674676
}
@@ -709,6 +711,8 @@ impl UsedInStmtLocals {
709711
}
710712

711713
impl<'tcx> Visitor<'tcx> for UsedInStmtLocals {
714+
const VISIT_DEBUG_INFO: bool = true;
715+
712716
fn visit_local(&mut self, local: Local, context: PlaceContext, _: Location) {
713717
if matches!(context, PlaceContext::NonUse(_)) {
714718
return;

compiler/rustc_mir_transform/src/validate.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ impl<'a, 'tcx> CfgChecker<'a, 'tcx> {
280280
}
281281

282282
impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
283+
const VISIT_DEBUG_INFO: bool = true;
283284
fn visit_local(&mut self, local: Local, _context: PlaceContext, location: Location) {
284285
if self.body.local_decls.get(local).is_none() {
285286
self.fail(
@@ -627,6 +628,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
627628
}
628629

629630
impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
631+
const VISIT_DEBUG_INFO: bool = true;
630632
fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) {
631633
// This check is somewhat expensive, so only run it when -Zvalidate-mir is passed.
632634
if self.tcx.sess.opts.unstable_opts.validate_mir

0 commit comments

Comments
 (0)