@@ -822,15 +822,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
822
822
self . stack_mut ( ) . push ( frame) ;
823
823
824
824
// Make sure all the constants required by this frame evaluate successfully (post-monomorphization check).
825
- if M :: POST_MONO_CHECKS {
826
- for & const_ in & body. required_consts {
827
- let c = self
828
- . instantiate_from_current_frame_and_normalize_erasing_regions ( const_. const_ ) ?;
829
- c. eval ( * self . tcx , self . param_env , const_. span ) . map_err ( |err| {
830
- err. emit_note ( * self . tcx ) ;
831
- err
832
- } ) ?;
833
- }
825
+ for & const_ in & body. required_consts {
826
+ let c =
827
+ self . instantiate_from_current_frame_and_normalize_erasing_regions ( const_. const_ ) ?;
828
+ c. eval ( * self . tcx , self . param_env , const_. span ) . map_err ( |err| {
829
+ err. emit_note ( * self . tcx ) ;
830
+ err
831
+ } ) ?;
834
832
}
835
833
836
834
// done
@@ -1181,8 +1179,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
1181
1179
) -> InterpResult < ' tcx , OpTy < ' tcx , M :: Provenance > > {
1182
1180
M :: eval_mir_constant ( self , * val, span, layout, |ecx, val, span, layout| {
1183
1181
let const_val = val. eval ( * ecx. tcx , ecx. param_env , span) . map_err ( |err| {
1184
- // FIXME: somehow this is reachable even when POST_MONO_CHECKS is on.
1185
- // Are we not always populating `required_consts`?
1182
+ if M :: all_required_consts_are_checked ( self )
1183
+ && !matches ! ( err, ErrorHandled :: TooGeneric ( ..) )
1184
+ {
1185
+ // Looks like the const is not captued by `required_consts`, that's bad.
1186
+ bug ! ( "interpret const eval failure of {val:?} which is not in required_consts" ) ;
1187
+ }
1186
1188
err. emit_note ( * ecx. tcx ) ;
1187
1189
err
1188
1190
} ) ?;
0 commit comments