@@ -50,6 +50,7 @@ pub(crate) fn provide(providers: &mut Providers) {
5050 self :: check_unsafety:: provide ( providers) ;
5151 * providers = Providers {
5252 mir_keys,
53+ mir_built,
5354 mir_const,
5455 mir_validated,
5556 optimized_mir,
@@ -103,9 +104,17 @@ fn mir_keys<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, krate: CrateNum)
103104 Rc :: new ( set)
104105}
105106
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+
106112fn 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+
108116 let source = MirSource :: from_local_def_id ( tcx, def_id) ;
117+ let mut mir = tcx. mir_built ( def_id) . steal ( ) ;
109118 transform:: run_suite ( tcx, source, MIR_CONST , & mut mir) ;
110119 tcx. alloc_steal_mir ( mir)
111120}
@@ -117,7 +126,6 @@ fn mir_validated<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx
117126 // this point, before we steal the mir-const result.
118127 let _ = tcx. mir_const_qualif ( def_id) ;
119128 }
120- let _ = tcx. unsafety_violations ( def_id) ;
121129
122130 let mut mir = tcx. mir_const ( def_id) . steal ( ) ;
123131 transform:: run_suite ( tcx, source, MIR_VALIDATED , & mut mir) ;
0 commit comments