@@ -518,27 +518,29 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
518518 }
519519 }
520520
521- // Work around: avoid ICE in miri.
522- // FIXME(wesleywiser) we don't currently handle the case where we try to make a ref
523- // from a function argument that hasn't been assigned to in this function. The main
524- // issue is if an arg is a fat-pointer, miri `expects()` to be able to read the value
525- // of that pointer to get size info. However, since this is `ConstProp`, that argument
526- // doesn't actually have a backing value and so this causes an ICE.
521+ // Work around: avoid ICE in miri. FIXME(wesleywiser)
522+ // The Miri engine ICEs when taking a reference to an uninitialized unsized
523+ // local. There's nothing it can do here: taking a reference needs an allocation
524+ // which needs to know the size. Normally that's okay as during execution
525+ // (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
527+ // and has a reference taken, we get an ICE.
527528 Rvalue :: Ref ( _, _, Place { base : PlaceBase :: Local ( local) , projection : box [ ] } ) => {
528529 trace ! ( "checking Ref({:?})" , place) ;
529530 let alive =
530531 if let LocalValue :: Live ( _) = self . ecx . frame ( ) . locals [ * local] . value {
531532 true
532533 } else { false } ;
533534
535+ // local 0 is the return place; locals 1..=arg_count are the arguments.
534536 if local. as_usize ( ) <= self . ecx . frame ( ) . body . arg_count && !alive {
535537 trace ! ( "skipping Ref({:?})" , place) ;
536538 return None ;
537539 }
538540 }
539541
540- // Work around: avoid extra unnecessary locals.
541- // FIXME(wesleywiser): const eval will turn this into a `const Scalar(<ZST>)` that
542+ // Work around: avoid extra unnecessary locals. FIXME(wesleywiser)
543+ // Const eval will turn this into a `const Scalar(<ZST>)` that
542544 // `SimplifyLocals` doesn't know it can remove.
543545 Rvalue :: Aggregate ( _, operands) if operands. len ( ) == 0 => {
544546 return None ;
0 commit comments