diff options
| -rw-r--r-- | src/librustc_mir/transform/const_prop.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 79dba2c5db8..1a0ac4a21df 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -331,7 +331,6 @@ struct ConstPropagator<'mir, 'tcx> { // by accessing them through `ecx` instead. source_scopes: IndexVec<SourceScope, SourceScopeData>, local_decls: IndexVec<Local, LocalDecl<'tcx>>, - ret: Option<OpTy<'tcx, ()>>, // Because we have `MutVisitor` we can't obtain the `SourceInfo` from a `Location`. So we store // the last known `SourceInfo` here and just keep revisiting it. source_info: Option<SourceInfo>, @@ -403,22 +402,23 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { source_scopes: body.source_scopes.clone(), //FIXME(wesleywiser) we can't steal this because `Visitor::super_visit_body()` needs it local_decls: body.local_decls.clone(), - ret: ret.map(Into::into), source_info: None, } } fn get_const(&self, local: Local) -> Option<OpTy<'tcx>> { + let op = self.ecx.access_local(self.ecx.frame(), local, None).ok(); + if local == RETURN_PLACE { // Try to read the return place as an immediate so that if it is representable as a // scalar, we can handle it as such, but otherwise, just return the value as is. - return match self.ret.map(|ret| self.ecx.try_read_immediate(ret)) { + return match op.map(|ret| self.ecx.try_read_immediate(ret)) { Some(Ok(Ok(imm))) => Some(imm.into()), - _ => self.ret, + _ => op, }; } - self.ecx.access_local(self.ecx.frame(), local, None).ok() + op } fn remove_const(&mut self, local: Local) { |
