@@ -554,6 +554,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
554
554
val : & mir:: ConstantKind < ' tcx > ,
555
555
layout : Option < TyAndLayout < ' tcx > > ,
556
556
) -> 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) ;
557
564
match val {
558
565
mir:: ConstantKind :: Ty ( ct) => {
559
566
match ct. kind ( ) {
@@ -585,7 +592,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
585
592
}
586
593
}
587
594
}
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) ,
589
596
mir:: ConstantKind :: Unevaluated ( uv, _) => {
590
597
let instance = self . resolve ( uv. def , uv. substs ) ?;
591
598
Ok ( self . eval_to_allocation ( GlobalId { instance, promoted : uv. promoted } ) ?. into ( ) )
0 commit comments