Skip to content

Commit d4a0569

Browse files
Rollup merge of #79080 - camelid:mir-visit-debuginfo-project, r=jonas-schievink
MIR visitor: Don't treat debuginfo field access as a use of the struct Fixes #77454. r? `@jonas-schievink`
2 parents 703f176 + b196bec commit d4a0569

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

compiler/rustc_middle/src/mir/visit.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -1017,11 +1017,14 @@ macro_rules! visit_place_fns {
10171017
let mut context = context;
10181018

10191019
if !place.projection.is_empty() {
1020-
context = if context.is_mutating_use() {
1021-
PlaceContext::MutatingUse(MutatingUseContext::Projection)
1022-
} else {
1023-
PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection)
1024-
};
1020+
if context.is_use() {
1021+
// ^ Only change the context if it is a real use, not a "use" in debuginfo.
1022+
context = if context.is_mutating_use() {
1023+
PlaceContext::MutatingUse(MutatingUseContext::Projection)
1024+
} else {
1025+
PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection)
1026+
};
1027+
}
10251028
}
10261029

10271030
self.visit_local(&place.local, context, location);

compiler/rustc_mir/src/transform/validate.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_middle::mir::traversal;
1212
use rustc_middle::mir::visit::{PlaceContext, Visitor};
1313
use rustc_middle::mir::{
1414
AggregateKind, BasicBlock, Body, BorrowKind, Local, Location, MirPhase, Operand, PlaceRef,
15-
Rvalue, SourceScope, Statement, StatementKind, Terminator, TerminatorKind, VarDebugInfo,
15+
Rvalue, SourceScope, Statement, StatementKind, Terminator, TerminatorKind,
1616
};
1717
use rustc_middle::ty::fold::BottomUpFolder;
1818
use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt, TypeFoldable};
@@ -200,12 +200,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
200200
}
201201
}
202202

203-
fn visit_var_debug_info(&mut self, var_debug_info: &VarDebugInfo<'tcx>) {
204-
// Debuginfo can contain field projections, which count as a use of the base local. Skip
205-
// debuginfo so that we avoid the storage liveness assertion in that case.
206-
self.visit_source_info(&var_debug_info.source_info);
207-
}
208-
209203
fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) {
210204
// This check is somewhat expensive, so only run it when -Zvalidate-mir is passed.
211205
if self.tcx.sess.opts.debugging_opts.validate_mir {

0 commit comments

Comments
 (0)