@@ -554,6 +554,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
554554 val : & mir:: ConstantKind < ' tcx > ,
555555 layout : Option < TyAndLayout < ' tcx > > ,
556556 ) -> InterpResult < ' tcx , OpTy < ' tcx , M :: Provenance > > {
557+ // FIXME(const_prop): normalization needed b/c const prop lint in
558+ // `mir_drops_elaborated_and_const_checked`, which happens before
559+ // optimized MIR. Only after optimizing the MIR can we guarantee
560+ // that the `RevealAll` pass has happened and that the body's consts
561+ // are normalized, so any call to resolve before that needs to be
562+ // manually normalized.
563+ let val = self . tcx . normalize_erasing_regions ( self . param_env , * val) ;
557564 match val {
558565 mir:: ConstantKind :: Ty ( ct) => {
559566 match ct. kind ( ) {
@@ -585,7 +592,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
585592 }
586593 }
587594 }
588- mir:: ConstantKind :: Val ( val, ty) => self . const_val_to_op ( * val, * ty, layout) ,
595+ mir:: ConstantKind :: Val ( val, ty) => self . const_val_to_op ( val, ty, layout) ,
589596 mir:: ConstantKind :: Unevaluated ( uv, _) => {
590597 let instance = self . resolve ( uv. def , uv. substs ) ?;
591598 Ok ( self . eval_to_allocation ( GlobalId { instance, promoted : uv. promoted } ) ?. into ( ) )
0 commit comments