@@ -792,15 +792,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
792
792
self . stack_mut ( ) . push ( frame) ;
793
793
794
794
// Make sure all the constants required by this frame evaluate successfully (post-monomorphization check).
795
- if M :: POST_MONO_CHECKS {
796
- for & const_ in & body. required_consts {
797
- let c = self
798
- . instantiate_from_current_frame_and_normalize_erasing_regions ( const_. const_ ) ?;
799
- c. eval ( * self . tcx , self . param_env , Some ( const_. span ) ) . map_err ( |err| {
800
- err. emit_note ( * self . tcx ) ;
801
- err
802
- } ) ?;
803
- }
795
+ for & const_ in & body. required_consts {
796
+ let c =
797
+ self . instantiate_from_current_frame_and_normalize_erasing_regions ( const_. const_ ) ?;
798
+ c. eval ( * self . tcx , self . param_env , Some ( const_. span ) ) . map_err ( |err| {
799
+ err. emit_note ( * self . tcx ) ;
800
+ err
801
+ } ) ?;
804
802
}
805
803
806
804
// done
@@ -1149,8 +1147,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
1149
1147
) -> InterpResult < ' tcx , OpTy < ' tcx , M :: Provenance > > {
1150
1148
M :: eval_mir_constant ( self , * val, span, layout, |ecx, val, span, layout| {
1151
1149
let const_val = val. eval ( * ecx. tcx , ecx. param_env , span) . map_err ( |err| {
1152
- // FIXME: somehow this is reachable even when POST_MONO_CHECKS is on.
1153
- // Are we not always populating `required_consts`?
1150
+ if M :: all_required_consts_are_checked ( self )
1151
+ && !matches ! ( err, ErrorHandled :: TooGeneric ( ..) )
1152
+ {
1153
+ // Looks like the const is not captued by `required_consts`, that's bad.
1154
+ bug ! ( "interpret const eval failure of {val:?} which is not in required_consts" ) ;
1155
+ }
1154
1156
err. emit_note ( * ecx. tcx ) ;
1155
1157
err
1156
1158
} ) ?;
0 commit comments