@@ -331,7 +331,6 @@ struct ConstPropagator<'mir, 'tcx> {
331
331
// by accessing them through `ecx` instead.
332
332
source_scopes : IndexVec < SourceScope , SourceScopeData > ,
333
333
local_decls : IndexVec < Local , LocalDecl < ' tcx > > ,
334
- ret : Option < OpTy < ' tcx , ( ) > > ,
335
334
// Because we have `MutVisitor` we can't obtain the `SourceInfo` from a `Location`. So we store
336
335
// the last known `SourceInfo` here and just keep revisiting it.
337
336
source_info : Option < SourceInfo > ,
@@ -403,22 +402,23 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
403
402
source_scopes : body. source_scopes . clone ( ) ,
404
403
//FIXME(wesleywiser) we can't steal this because `Visitor::super_visit_body()` needs it
405
404
local_decls : body. local_decls . clone ( ) ,
406
- ret : ret. map ( Into :: into) ,
407
405
source_info : None ,
408
406
}
409
407
}
410
408
411
409
fn get_const ( & self , local : Local ) -> Option < OpTy < ' tcx > > {
410
+ let op = self . ecx . access_local ( self . ecx . frame ( ) , local, None ) . ok ( ) ;
411
+
412
412
if local == RETURN_PLACE {
413
413
// Try to read the return place as an immediate so that if it is representable as a
414
414
// scalar, we can handle it as such, but otherwise, just return the value as is.
415
- return match self . ret . map ( |ret| self . ecx . try_read_immediate ( ret) ) {
415
+ return match op . map ( |ret| self . ecx . try_read_immediate ( ret) ) {
416
416
Some ( Ok ( Ok ( imm) ) ) => Some ( imm. into ( ) ) ,
417
- _ => self . ret ,
417
+ _ => op ,
418
418
} ;
419
419
}
420
420
421
- self . ecx . access_local ( self . ecx . frame ( ) , local , None ) . ok ( )
421
+ op
422
422
}
423
423
424
424
fn remove_const ( & mut self , local : Local ) {
0 commit comments