Skip to content

Commit c5bfbb6

Browse files
Update const prop
1 parent 0fda0fd commit c5bfbb6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/librustc_mir/transform/const_prop.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ struct ConstPropagator<'mir, 'tcx> {
331331
// by accessing them through `ecx` instead.
332332
source_scopes: IndexVec<SourceScope, SourceScopeData>,
333333
local_decls: IndexVec<Local, LocalDecl<'tcx>>,
334-
ret: Option<OpTy<'tcx, ()>>,
335334
// Because we have `MutVisitor` we can't obtain the `SourceInfo` from a `Location`. So we store
336335
// the last known `SourceInfo` here and just keep revisiting it.
337336
source_info: Option<SourceInfo>,
@@ -403,22 +402,23 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
403402
source_scopes: body.source_scopes.clone(),
404403
//FIXME(wesleywiser) we can't steal this because `Visitor::super_visit_body()` needs it
405404
local_decls: body.local_decls.clone(),
406-
ret: ret.map(Into::into),
407405
source_info: None,
408406
}
409407
}
410408

411409
fn get_const(&self, local: Local) -> Option<OpTy<'tcx>> {
410+
let op = self.ecx.access_local(self.ecx.frame(), local, None).ok();
411+
412412
if local == RETURN_PLACE {
413413
// Try to read the return place as an immediate so that if it is representable as a
414414
// 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)) {
416416
Some(Ok(Ok(imm))) => Some(imm.into()),
417-
_ => self.ret,
417+
_ => op,
418418
};
419419
}
420420

421-
self.ecx.access_local(self.ecx.frame(), local, None).ok()
421+
op
422422
}
423423

424424
fn remove_const(&mut self, local: Local) {

0 commit comments

Comments
 (0)