@@ -8,7 +8,7 @@ use super::MirPass;
8
8
use rustc_middle:: mir:: visit:: { PlaceContext , Visitor } ;
9
9
use rustc_middle:: mir:: {
10
10
AggregateKind , BasicBlock , Body , BorrowKind , Local , Location , MirPhase , Operand , Rvalue ,
11
- Statement , StatementKind , Terminator , TerminatorKind , VarDebugInfo ,
11
+ SourceScope , Statement , StatementKind , Terminator , TerminatorKind , VarDebugInfo ,
12
12
} ;
13
13
use rustc_middle:: ty:: relate:: { Relate , RelateResult , TypeRelation } ;
14
14
use rustc_middle:: ty:: { self , ParamEnv , Ty , TyCtxt } ;
@@ -229,9 +229,10 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
229
229
}
230
230
}
231
231
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 > ) {
233
233
// Debuginfo can contain field projections, which count as a use of the base local. Skip
234
234
// debuginfo so that we avoid the storage liveness assertion in that case.
235
+ self . visit_source_info ( & var_debug_info. source_info ) ;
235
236
}
236
237
237
238
fn visit_operand ( & mut self , operand : & Operand < ' tcx > , location : Location ) {
@@ -432,4 +433,16 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
432
433
| TerminatorKind :: GeneratorDrop => { }
433
434
}
434
435
}
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
+ }
435
448
}
0 commit comments