Skip to content

Commit

Permalink
skip all refs-to-uninit-local, not just arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Oct 20, 2019
1 parent 282403e commit f907fbe
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/librustc_mir/transform/const_prop.rs
Expand Up @@ -523,18 +523,19 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
// local. There's nothing it can do here: taking a reference needs an allocation
// which needs to know the size. Normally that's okay as during execution
// (e.g. for CTFE) it can never happen. But here in const_prop
// we leave function arguments uninitialized, so if one of these is unsized
// unknown data is uninitialized, so if e.g. a function argument is unsized
// and has a reference taken, we get an ICE.
Rvalue::Ref(_, _, Place { base: PlaceBase::Local(local), projection: box [] }) => {
trace!("checking Ref({:?})", place);
let alive =
if let LocalValue::Live(_) = self.ecx.frame().locals[*local].value {
true
} else { false };
} else {
false
};

// local 0 is the return place; locals 1..=arg_count are the arguments.
if local.as_usize() <= self.ecx.frame().body.arg_count && !alive {
trace!("skipping Ref({:?})", place);
if !alive {
trace!("skipping Ref({:?}) to uninitialized local", place);
return None;
}
}
Expand Down

0 comments on commit f907fbe

Please sign in to comment.