@@ -11,9 +11,9 @@ use rustc_index::bit_set::BitSet;
11
11
use rustc_index:: vec:: IndexVec ;
12
12
use rustc_middle:: mir:: visit:: { MutatingUseContext , NonMutatingUseContext , PlaceContext , Visitor } ;
13
13
use rustc_middle:: mir:: {
14
- AssertKind , BasicBlock , BinOp , Body , Constant , ConstantKind , Local , LocalKind , Location ,
15
- Operand , Place , Rvalue , SourceInfo , Statement , StatementKind , Terminator , TerminatorKind , UnOp ,
16
- RETURN_PLACE ,
14
+ AssertKind , BasicBlock , BinOp , Body , Constant , ConstantKind , Local , LocalDecl , LocalKind ,
15
+ Location , Operand , Place , Rvalue , SourceInfo , SourceScope , SourceScopeData , Statement ,
16
+ StatementKind , Terminator , TerminatorKind , UnOp , RETURN_PLACE ,
17
17
} ;
18
18
use rustc_middle:: ty:: layout:: { LayoutError , LayoutOf , LayoutOfHelpers , TyAndLayout } ;
19
19
use rustc_middle:: ty:: subst:: { InternalSubsts , Subst } ;
@@ -308,6 +308,8 @@ struct ConstPropagator<'mir, 'tcx> {
308
308
ecx : InterpCx < ' mir , ' tcx , ConstPropMachine < ' mir , ' tcx > > ,
309
309
tcx : TyCtxt < ' tcx > ,
310
310
param_env : ParamEnv < ' tcx > ,
311
+ source_scopes : & ' mir IndexVec < SourceScope , SourceScopeData < ' tcx > > ,
312
+ local_decls : & ' mir IndexVec < Local , LocalDecl < ' tcx > > ,
311
313
// Because we have `MutVisitor` we can't obtain the `SourceInfo` from a `Location`. So we store
312
314
// the last known `SourceInfo` here and just keep revisiting it.
313
315
source_info : Option < SourceInfo > ,
@@ -389,7 +391,14 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
389
391
)
390
392
. expect ( "failed to push initial stack frame" ) ;
391
393
392
- ConstPropagator { ecx, tcx, param_env, source_info : None }
394
+ ConstPropagator {
395
+ ecx,
396
+ tcx,
397
+ param_env,
398
+ source_scopes : & dummy_body. source_scopes ,
399
+ local_decls : & dummy_body. local_decls ,
400
+ source_info : None ,
401
+ }
393
402
}
394
403
395
404
fn get_const ( & self , place : Place < ' tcx > ) -> Option < OpTy < ' tcx > > {
@@ -417,7 +426,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
417
426
}
418
427
419
428
fn lint_root ( & self , source_info : SourceInfo ) -> Option < HirId > {
420
- source_info. scope . lint_root ( & self . ecx . frame ( ) . body . source_scopes )
429
+ source_info. scope . lint_root ( self . source_scopes )
421
430
}
422
431
423
432
fn use_ecx < F , T > ( & mut self , f : F ) -> Option < T >
@@ -554,7 +563,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
554
563
let r = r?;
555
564
// We need the type of the LHS. We cannot use `place_layout` as that is the type
556
565
// of the result, which for checked binops is not the same!
557
- let left_ty = left. ty ( & self . ecx . frame ( ) . body . local_decls , self . tcx ) ;
566
+ let left_ty = left. ty ( self . local_decls , self . tcx ) ;
558
567
let left_size = self . ecx . layout_of ( left_ty) . ok ( ) ?. size ;
559
568
let right_size = r. layout . size ;
560
569
let r_bits = r. to_scalar ( ) . ok ( ) ;
@@ -1008,7 +1017,7 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
1008
1017
assert ! (
1009
1018
self . get_const( local. into( ) ) . is_none( )
1010
1019
|| self
1011
- . layout_of( self . ecx . frame ( ) . body . local_decls[ local] . ty)
1020
+ . layout_of( self . local_decls[ local] . ty)
1012
1021
. map_or( true , |layout| layout. is_zst( ) )
1013
1022
)
1014
1023
}
0 commit comments