]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/transform/mod.rs
Add a query to get the `promoted`s for a `mir::Body`
[rust.git] / src / librustc_mir / transform / mod.rs
index 81d91dcd0a95f58f66d6bd173832cae477f94b96..4313c75342f0b63164d2ccaca6a3da551a35f5c0 100644 (file)
@@ -1,4 +1,5 @@
 use crate::{build, shim};
+use rustc_data_structures::indexed_vec::IndexVec;
 use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
 use rustc::mir::{Body, MirPhase, Promoted};
 use rustc::ty::{TyCtxt, InstanceDef};
@@ -46,6 +47,7 @@ pub(crate) fn provide(providers: &mut Providers<'_>) {
         mir_validated,
         optimized_mir,
         is_mir_available,
+        promoted_mir,
         ..*providers
     };
 }
@@ -296,3 +298,8 @@ fn optimized_mir<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx Body<'tcx> {
     ]);
     tcx.arena.alloc(body)
 }
+
+fn promoted_mir<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx IndexVec<Promoted, Body<'tcx>> {
+    let body = tcx.optimized_mir(def_id);
+    &body.promoted
+}