@@ -50,6 +50,7 @@ pub(crate) fn provide(providers: &mut Providers) {
50
50
self :: check_unsafety:: provide ( providers) ;
51
51
* providers = Providers {
52
52
mir_keys,
53
+ mir_built,
53
54
mir_const,
54
55
mir_validated,
55
56
optimized_mir,
@@ -103,9 +104,17 @@ fn mir_keys<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, krate: CrateNum)
103
104
Rc :: new ( set)
104
105
}
105
106
107
+ fn mir_built < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , def_id : DefId ) -> & ' tcx Steal < Mir < ' tcx > > {
108
+ let mir = build:: mir_build ( tcx, def_id) ;
109
+ tcx. alloc_steal_mir ( mir)
110
+ }
111
+
106
112
fn mir_const < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , def_id : DefId ) -> & ' tcx Steal < Mir < ' tcx > > {
107
- let mut mir = build:: mir_build ( tcx, def_id) ;
113
+ // Unsafety check uses the raw mir, so make sure it is run
114
+ let _ = tcx. unsafety_violations ( def_id) ;
115
+
108
116
let source = MirSource :: from_local_def_id ( tcx, def_id) ;
117
+ let mut mir = tcx. mir_built ( def_id) . steal ( ) ;
109
118
transform:: run_suite ( tcx, source, MIR_CONST , & mut mir) ;
110
119
tcx. alloc_steal_mir ( mir)
111
120
}
@@ -117,7 +126,6 @@ fn mir_validated<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx
117
126
// this point, before we steal the mir-const result.
118
127
let _ = tcx. mir_const_qualif ( def_id) ;
119
128
}
120
- let _ = tcx. unsafety_violations ( def_id) ;
121
129
122
130
let mut mir = tcx. mir_const ( def_id) . steal ( ) ;
123
131
transform:: run_suite ( tcx, source, MIR_VALIDATED , & mut mir) ;
0 commit comments