Skip to content

Commit f907fbe

Browse files
committed
skip all refs-to-uninit-local, not just arguments
1 parent 282403e commit f907fbe

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/librustc_mir/transform/const_prop.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -523,18 +523,19 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
523523
// local. There's nothing it can do here: taking a reference needs an allocation
524524
// which needs to know the size. Normally that's okay as during execution
525525
// (e.g. for CTFE) it can never happen. But here in const_prop
526-
// we leave function arguments uninitialized, so if one of these is unsized
526+
// unknown data is uninitialized, so if e.g. a function argument is unsized
527527
// and has a reference taken, we get an ICE.
528528
Rvalue::Ref(_, _, Place { base: PlaceBase::Local(local), projection: box [] }) => {
529529
trace!("checking Ref({:?})", place);
530530
let alive =
531531
if let LocalValue::Live(_) = self.ecx.frame().locals[*local].value {
532532
true
533-
} else { false };
533+
} else {
534+
false
535+
};
534536

535-
// local 0 is the return place; locals 1..=arg_count are the arguments.
536-
if local.as_usize() <= self.ecx.frame().body.arg_count && !alive {
537-
trace!("skipping Ref({:?})", place);
537+
if !alive {
538+
trace!("skipping Ref({:?}) to uninitialized local", place);
538539
return None;
539540
}
540541
}

0 commit comments

Comments
 (0)