@@ -108,6 +108,15 @@ struct Qualifier<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
108
108
promotion_candidates : Vec < Candidate >
109
109
}
110
110
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
+
111
120
impl < ' a , ' tcx > Qualifier < ' a , ' tcx , ' tcx > {
112
121
fn new ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
113
122
def_id : DefId ,
@@ -147,6 +156,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
147
156
// categories, but enabling full miri would make that
148
157
// slightly pointless (even with feature-gating).
149
158
fn not_const ( & mut self ) {
159
+ unleash_miri ! ( self ) ;
150
160
self . add ( Qualif :: NOT_CONST ) ;
151
161
if self . mode != Mode :: Fn {
152
162
let mut err = struct_span_err ! (
@@ -419,6 +429,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
419
429
}
420
430
return ;
421
431
}
432
+ unleash_miri ! ( self ) ;
422
433
self . add ( Qualif :: NOT_CONST ) ;
423
434
424
435
if self . mode != Mode :: Fn {
@@ -618,6 +629,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
618
629
}
619
630
620
631
if forbidden_mut {
632
+ unleash_miri ! ( self ) ;
621
633
self . add ( Qualif :: NOT_CONST ) ;
622
634
if self . mode != Mode :: Fn {
623
635
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> {
660
672
661
673
debug ! ( "visit_rvalue: forbidden_mut={:?}" , forbidden_mut) ;
662
674
if forbidden_mut {
675
+ unleash_miri ! ( self ) ;
663
676
self . add ( Qualif :: NOT_CONST ) ;
664
677
} else {
665
678
// We might have a candidate for promotion.
@@ -700,6 +713,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
700
713
match ( cast_in, cast_out) {
701
714
( CastTy :: Ptr ( _) , CastTy :: Int ( _) ) |
702
715
( CastTy :: FnPtr , CastTy :: Int ( _) ) => {
716
+ unleash_miri ! ( self ) ;
703
717
if let Mode :: Fn = self . mode {
704
718
// in normal functions, mark such casts as not promotable
705
719
self . add ( Qualif :: NOT_CONST ) ;
@@ -727,6 +741,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
727
741
op == BinOp :: Ge || op == BinOp :: Gt ||
728
742
op == BinOp :: Offset ) ;
729
743
744
+ unleash_miri ! ( self ) ;
730
745
if let Mode :: Fn = self . mode {
731
746
// raw pointer operations are not allowed inside promoteds
732
747
self . add ( Qualif :: NOT_CONST ) ;
@@ -745,6 +760,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
745
760
}
746
761
747
762
Rvalue :: NullaryOp ( NullOp :: Box , _) => {
763
+ unleash_miri ! ( self ) ;
748
764
self . add ( Qualif :: NOT_CONST ) ;
749
765
if self . mode != Mode :: Fn {
750
766
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> {
861
877
} else {
862
878
// stable const fns or unstable const fns with their feature gate
863
879
// 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 {
865
887
is_const_fn = true ;
866
888
} else if self . is_const_panic_fn ( def_id) {
867
889
// Check the const_panic feature gate.
@@ -1030,6 +1052,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
1030
1052
1031
1053
// Deny *any* live drops anywhere other than functions.
1032
1054
if self . mode != Mode :: Fn {
1055
+ unleash_miri ! ( self ) ;
1033
1056
// HACK(eddyb): emulate a bit of dataflow analysis,
1034
1057
// conservatively, that drop elaboration will do.
1035
1058
let needs_drop = if let Place :: Local ( local) = * place {
@@ -1175,7 +1198,9 @@ impl MirPass for QualifyAndPromoteConstants {
1175
1198
let ( temps, candidates) = {
1176
1199
let mut qualifier = Qualifier :: new ( tcx, def_id, mir, mode) ;
1177
1200
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) {
1179
1204
// enforce `min_const_fn` for stable const fns
1180
1205
use super :: qualify_min_const_fn:: is_min_const_fn;
1181
1206
if let Err ( ( span, err) ) = is_min_const_fn ( tcx, def_id, mir) {
0 commit comments