diff options
| author | Ralf Jung <post@ralfj.de> | 2019-10-19 18:16:22 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2019-10-20 11:22:06 +0200 |
| commit | f907fbe1a6676a26cfc893b78f0fffb4285f1e6c (patch) | |
| tree | 30075378463bff8c9bbe19dad61d7f2b5051e5a2 | |
| parent | 282403e6bd0f858474c47fe2b9efd50645023c7c (diff) | |
| download | rust-f907fbe1a6676a26cfc893b78f0fffb4285f1e6c.tar.gz rust-f907fbe1a6676a26cfc893b78f0fffb4285f1e6c.zip | |
skip all refs-to-uninit-local, not just arguments
| -rw-r--r-- | src/librustc_mir/transform/const_prop.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 223330a3ecb..780b49cd9db 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -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; } } |
