@@ -591,9 +591,16 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
591591 val : & mir:: ConstantKind < ' tcx > ,
592592 layout : Option < TyAndLayout < ' tcx > > ,
593593 ) -> InterpResult < ' tcx , OpTy < ' tcx , M :: Provenance > > {
594+ // FIXME(const_prop): normalization needed b/c const prop lint in
595+ // `mir_drops_elaborated_and_const_checked`, which happens before
596+ // optimized MIR. Only after optimizing the MIR can we guarantee
597+ // that the `RevealAll` pass has happened and that the body's consts
598+ // are normalized, so any call to resolve before that needs to be
599+ // manually normalized.
600+ let val = self . tcx . normalize_erasing_regions ( self . param_env , * val) ;
594601 match val {
595- mir:: ConstantKind :: Ty ( ct) => self . const_to_op ( * ct, layout) ,
596- mir:: ConstantKind :: Val ( val, ty) => self . const_val_to_op ( * val, * ty, layout) ,
602+ mir:: ConstantKind :: Ty ( ct) => self . const_to_op ( ct, layout) ,
603+ mir:: ConstantKind :: Val ( val, ty) => self . const_val_to_op ( val, ty, layout) ,
597604 mir:: ConstantKind :: Unevaluated ( uv, _) => {
598605 let instance = self . resolve ( uv. def , uv. substs ) ?;
599606 Ok ( self . eval_to_allocation ( GlobalId { instance, promoted : uv. promoted } ) ?. into ( ) )
0 commit comments