@@ -8,7 +8,7 @@ use super::MirPass;
88use rustc_middle:: mir:: visit:: { PlaceContext , Visitor } ;
99use rustc_middle:: mir:: {
1010 AggregateKind , BasicBlock , Body , BorrowKind , Local , Location , MirPhase , Operand , Rvalue ,
11- Statement , StatementKind , Terminator , TerminatorKind , VarDebugInfo ,
11+ SourceScope , Statement , StatementKind , Terminator , TerminatorKind , VarDebugInfo ,
1212} ;
1313use rustc_middle:: ty:: relate:: { Relate , RelateResult , TypeRelation } ;
1414use rustc_middle:: ty:: { self , ParamEnv , Ty , TyCtxt } ;
@@ -229,9 +229,10 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
229229 }
230230 }
231231
232- fn visit_var_debug_info ( & mut self , _var_debug_info : & VarDebugInfo < ' tcx > ) {
232+ fn visit_var_debug_info ( & mut self , var_debug_info : & VarDebugInfo < ' tcx > ) {
233233 // Debuginfo can contain field projections, which count as a use of the base local. Skip
234234 // debuginfo so that we avoid the storage liveness assertion in that case.
235+ self . visit_source_info ( & var_debug_info. source_info ) ;
235236 }
236237
237238 fn visit_operand ( & mut self , operand : & Operand < ' tcx > , location : Location ) {
@@ -432,4 +433,16 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
432433 | TerminatorKind :: GeneratorDrop => { }
433434 }
434435 }
436+
437+ fn visit_source_scope ( & mut self , scope : & SourceScope ) {
438+ if self . body . source_scopes . get ( * scope) . is_none ( ) {
439+ self . tcx . sess . diagnostic ( ) . delay_span_bug (
440+ self . body . span ,
441+ & format ! (
442+ "broken MIR in {:?} ({}):\n invalid source scope {:?}" ,
443+ self . body. source. instance, self . when, scope,
444+ ) ,
445+ ) ;
446+ }
447+ }
435448}
0 commit comments