@@ -729,27 +729,31 @@ pub(crate) fn const_eval<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
729
729
trace ! ( "running old const eval" ) ;
730
730
let old_result = ConstContext :: new ( tcx, key. param_env . and ( substs) , tables) . eval ( & body. value ) ;
731
731
trace ! ( "old const eval produced {:?}" , old_result) ;
732
- let instance = ty:: Instance :: new ( def_id, substs) ;
733
- trace ! ( "const eval instance: {:?}, {:?}" , instance, key. param_env) ;
734
- let miri_result = :: rustc:: mir:: interpret:: eval_body ( tcx, instance, key. param_env ) ;
735
- match ( miri_result, old_result) {
736
- ( ( Err ( err) , ecx) , Ok ( ok) ) => {
737
- trace ! ( "miri failed, ctfe returned {:?}" , ok) ;
738
- tcx. sess . span_warn (
739
- tcx. def_span ( key. value . 0 ) ,
740
- "miri failed to eval, while ctfe succeeded" ,
741
- ) ;
742
- let ( ) = unwrap_miri ( & ecx, Err ( err) ) ;
743
- Ok ( ok)
744
- } ,
745
- ( ( Ok ( _) , _) , Err ( err) ) => {
746
- Err ( err)
747
- } ,
748
- ( ( Err ( _) , _) , Err ( err) ) => Err ( err) ,
749
- ( ( Ok ( ( miri_val, miri_ty) ) , mut ecx) , Ok ( ctfe) ) => {
750
- check_ctfe_against_miri ( & mut ecx, miri_val, miri_ty, ctfe. val ) ;
751
- Ok ( ctfe)
732
+ if tcx. sess . opts . debugging_opts . miri {
733
+ let instance = ty:: Instance :: new ( def_id, substs) ;
734
+ trace ! ( "const eval instance: {:?}, {:?}" , instance, key. param_env) ;
735
+ let miri_result = :: rustc:: mir:: interpret:: eval_body ( tcx, instance, key. param_env ) ;
736
+ match ( miri_result, old_result) {
737
+ ( ( Err ( err) , ecx) , Ok ( ok) ) => {
738
+ trace ! ( "miri failed, ctfe returned {:?}" , ok) ;
739
+ tcx. sess . span_warn (
740
+ tcx. def_span ( key. value . 0 ) ,
741
+ "miri failed to eval, while ctfe succeeded" ,
742
+ ) ;
743
+ let ( ) = unwrap_miri ( & ecx, Err ( err) ) ;
744
+ Ok ( ok)
745
+ } ,
746
+ ( ( Ok ( _) , _) , Err ( err) ) => {
747
+ Err ( err)
748
+ } ,
749
+ ( ( Err ( _) , _) , Err ( err) ) => Err ( err) ,
750
+ ( ( Ok ( ( miri_val, miri_ty) ) , mut ecx) , Ok ( ctfe) ) => {
751
+ check_ctfe_against_miri ( & mut ecx, miri_val, miri_ty, ctfe. val ) ;
752
+ Ok ( ctfe)
753
+ }
752
754
}
755
+ } else {
756
+ old_result
753
757
}
754
758
}
755
759
0 commit comments