@@ -108,6 +108,15 @@ struct Qualifier<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
108108 promotion_candidates : Vec < Candidate >
109109}
110110
111+ macro_rules! unleash_miri {
112+ ( $this: expr) => { {
113+ if $this. tcx. sess. opts. debugging_opts. unleash_the_miri_inside_of_you {
114+ $this. tcx. sess. span_warn( $this. span, "skipping const checks" ) ;
115+ return ;
116+ }
117+ } }
118+ }
119+
111120impl < ' a , ' tcx > Qualifier < ' a , ' tcx , ' tcx > {
112121 fn new ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
113122 def_id : DefId ,
@@ -147,6 +156,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
147156 // categories, but enabling full miri would make that
148157 // slightly pointless (even with feature-gating).
149158 fn not_const ( & mut self ) {
159+ unleash_miri ! ( self ) ;
150160 self . add ( Qualif :: NOT_CONST ) ;
151161 if self . mode != Mode :: Fn {
152162 let mut err = struct_span_err ! (
@@ -419,6 +429,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
419429 }
420430 return ;
421431 }
432+ unleash_miri ! ( self ) ;
422433 self . add ( Qualif :: NOT_CONST ) ;
423434
424435 if self . mode != Mode :: Fn {
@@ -618,6 +629,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
618629 }
619630
620631 if forbidden_mut {
632+ unleash_miri ! ( self ) ;
621633 self . add ( Qualif :: NOT_CONST ) ;
622634 if self . mode != Mode :: Fn {
623635 let mut err = struct_span_err ! ( self . tcx. sess, self . span, E0017 ,
@@ -660,6 +672,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
660672
661673 debug ! ( "visit_rvalue: forbidden_mut={:?}" , forbidden_mut) ;
662674 if forbidden_mut {
675+ unleash_miri ! ( self ) ;
663676 self . add ( Qualif :: NOT_CONST ) ;
664677 } else {
665678 // We might have a candidate for promotion.
@@ -700,6 +713,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
700713 match ( cast_in, cast_out) {
701714 ( CastTy :: Ptr ( _) , CastTy :: Int ( _) ) |
702715 ( CastTy :: FnPtr , CastTy :: Int ( _) ) => {
716+ unleash_miri ! ( self ) ;
703717 if let Mode :: Fn = self . mode {
704718 // in normal functions, mark such casts as not promotable
705719 self . add ( Qualif :: NOT_CONST ) ;
@@ -727,6 +741,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
727741 op == BinOp :: Ge || op == BinOp :: Gt ||
728742 op == BinOp :: Offset ) ;
729743
744+ unleash_miri ! ( self ) ;
730745 if let Mode :: Fn = self . mode {
731746 // raw pointer operations are not allowed inside promoteds
732747 self . add ( Qualif :: NOT_CONST ) ;
@@ -745,6 +760,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
745760 }
746761
747762 Rvalue :: NullaryOp ( NullOp :: Box , _) => {
763+ unleash_miri ! ( self ) ;
748764 self . add ( Qualif :: NOT_CONST ) ;
749765 if self . mode != Mode :: Fn {
750766 let mut err = struct_span_err ! ( self . tcx. sess, self . span, E0010 ,
@@ -861,7 +877,13 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
861877 } else {
862878 // stable const fns or unstable const fns with their feature gate
863879 // active
864- if self . tcx . is_const_fn ( def_id) {
880+ let unleash_miri = self
881+ . tcx
882+ . sess
883+ . opts
884+ . debugging_opts
885+ . unleash_the_miri_inside_of_you ;
886+ if self . tcx . is_const_fn ( def_id) || unleash_miri {
865887 is_const_fn = true ;
866888 } else if self . is_const_panic_fn ( def_id) {
867889 // Check the const_panic feature gate.
@@ -1030,6 +1052,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
10301052
10311053 // Deny *any* live drops anywhere other than functions.
10321054 if self . mode != Mode :: Fn {
1055+ unleash_miri ! ( self ) ;
10331056 // HACK(eddyb): emulate a bit of dataflow analysis,
10341057 // conservatively, that drop elaboration will do.
10351058 let needs_drop = if let Place :: Local ( local) = * place {
@@ -1175,7 +1198,9 @@ impl MirPass for QualifyAndPromoteConstants {
11751198 let ( temps, candidates) = {
11761199 let mut qualifier = Qualifier :: new ( tcx, def_id, mir, mode) ;
11771200 if mode == Mode :: ConstFn {
1178- if tcx. is_min_const_fn ( def_id) {
1201+ if tcx. sess . opts . debugging_opts . unleash_the_miri_inside_of_you {
1202+ qualifier. qualify_const ( ) ;
1203+ } else if tcx. is_min_const_fn ( def_id) {
11791204 // enforce `min_const_fn` for stable const fns
11801205 use super :: qualify_min_const_fn:: is_min_const_fn;
11811206 if let Err ( ( span, err) ) = is_min_const_fn ( tcx, def_id, mir) {
0 commit comments