]> git.lizzy.rs Git - rust.git/commitdiff
introduce idea of "stealable" MIR
authorNiko Matsakis <niko@alum.mit.edu>
Fri, 28 Apr 2017 10:00:48 +0000 (06:00 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 2 May 2017 18:01:34 +0000 (14:01 -0400)
This is a more principled version of the `RefCell` we were using
before. We now allocate a `Steal<Mir<'tcx>>` for each intermediate MIR
pass; when the next pass steals the entry, any later attempts to use it
will panic (there is no way to *test* if MIR is stolen, you're just
supposed to *know*).

12 files changed:
src/librustc/mir/transform.rs
src/librustc/ty/context.rs
src/librustc/ty/maps.rs
src/librustc/ty/mod.rs
src/librustc/ty/steal.rs [new file with mode: 0644]
src/librustc_metadata/cstore_impl.rs
src/librustc_mir/mir_map.rs
src/librustc_mir/shim.rs
src/librustc_mir/transform/dump_mir.rs
src/librustc_mir/transform/mod.rs
src/librustc_mir/transform/qualify_consts.rs
src/librustc_mir/util/pretty.rs

index 7c9b86651976c801ce931a2a0082092ef994fb9c..80a4d9a9ff15b0008017811a0c9ff8e686fedf5b 100644 (file)
@@ -13,7 +13,7 @@
 use hir::map::DefPathData;
 use mir::{Mir, Promoted};
 use ty::TyCtxt;
-use std::cell::{Ref, RefCell};
+use std::cell::Ref;
 use std::rc::Rc;
 use syntax::ast::NodeId;
 
@@ -98,7 +98,7 @@ pub trait MirCtxt<'a, 'tcx: 'a> {
     fn pass_num(&self) -> MirPassIndex;
     fn source(&self) -> MirSource;
     fn read_previous_mir(&self) -> Ref<'tcx, Mir<'tcx>>;
-    fn steal_previous_mir(&self) -> &'tcx RefCell<Mir<'tcx>>;
+    fn steal_previous_mir(&self) -> Mir<'tcx>;
 }
 
 #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
@@ -132,7 +132,7 @@ fn name<'a>(&'a self) -> Cow<'a, str> {
         default_name::<Self>()
     }
 
-    fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>) -> &'tcx RefCell<Mir<'tcx>>;
+    fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>) -> Mir<'tcx>;
 }
 
 /// A streamlined trait that you can implement to create a pass; the
@@ -154,14 +154,14 @@ fn name<'a>(&'a self) -> Cow<'a, str> {
         MirPass::name(self)
     }
 
-    fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>) -> &'tcx RefCell<Mir<'tcx>> {
+    fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>) -> Mir<'tcx> {
         let tcx = mir_cx.tcx();
         let source = mir_cx.source();
-        let mir = mir_cx.steal_previous_mir();
-        MirPass::run_pass(self, tcx, source, &mut mir.borrow_mut());
+        let mut mir = mir_cx.steal_previous_mir();
+        MirPass::run_pass(self, tcx, source, &mut mir);
 
         let item_id = source.item_id();
-        for (promoted_index, promoted_mir) in mir.borrow_mut().promoted.iter_enumerated_mut() {
+        for (promoted_index, promoted_mir) in mir.promoted.iter_enumerated_mut() {
             let promoted_source = MirSource::Promoted(item_id, promoted_index);
             MirPass::run_pass(self, tcx, promoted_source, promoted_mir);
         }
index 0c189853c6195efaca60aada70de18a1d93f9742..0dd23eb7e700ca192106a3d8691dacfc2ff21fe8 100644 (file)
@@ -40,6 +40,7 @@
 use ty::layout::{Layout, TargetDataLayout};
 use ty::inhabitedness::DefIdForest;
 use ty::maps;
+use ty::steal::Steal;
 use util::nodemap::{NodeMap, NodeSet, DefIdMap, DefIdSet};
 use util::nodemap::{FxHashMap, FxHashSet};
 use rustc_data_structures::accumulate_vec::AccumulateVec;
@@ -70,7 +71,8 @@ pub struct GlobalArenas<'tcx> {
     generics: TypedArena<ty::Generics>,
     trait_def: TypedArena<ty::TraitDef>,
     adt_def: TypedArena<ty::AdtDef>,
-    mir: TypedArena<RefCell<Mir<'tcx>>>,
+    steal_mir: TypedArena<Steal<Mir<'tcx>>>,
+    mir: TypedArena<Mir<'tcx>>,
     tables: TypedArena<ty::TypeckTables<'tcx>>,
 }
 
@@ -81,6 +83,7 @@ pub fn new() -> GlobalArenas<'tcx> {
             generics: TypedArena::new(),
             trait_def: TypedArena::new(),
             adt_def: TypedArena::new(),
+            steal_mir: TypedArena::new(),
             mir: TypedArena::new(),
             tables: TypedArena::new(),
         }
@@ -622,8 +625,12 @@ pub fn alloc_generics(self, generics: ty::Generics) -> &'gcx ty::Generics {
         self.global_arenas.generics.alloc(generics)
     }
 
-    pub fn alloc_mir(self, mir: Mir<'gcx>) -> &'gcx RefCell<Mir<'gcx>> {
-        self.global_arenas.mir.alloc(RefCell::new(mir))
+    pub fn alloc_steal_mir(self, mir: Mir<'gcx>) -> &'gcx Steal<Mir<'gcx>> {
+        self.global_arenas.steal_mir.alloc(Steal::new(mir))
+    }
+
+    pub fn alloc_mir(self, mir: Mir<'gcx>) -> &'gcx Mir<'gcx> {
+        self.global_arenas.mir.alloc(mir)
     }
 
     pub fn alloc_tables(self, tables: ty::TypeckTables<'gcx>) -> &'gcx ty::TypeckTables<'gcx> {
index 58a38cc903d3c862d214e1931431061590f5ac6a..09bdca4915a18e8bf0a556689296cee724d3ba05 100644 (file)
@@ -20,6 +20,7 @@
 use session::CompileResult;
 use ty::{self, CrateInherentImpls, Ty, TyCtxt};
 use ty::item_path;
+use ty::steal::Steal;
 use ty::subst::Substs;
 use util::nodemap::{DefIdSet, NodeSet};
 
@@ -32,7 +33,7 @@
 use syntax_pos::{Span, DUMMY_SP};
 use syntax::symbol::Symbol;
 
-trait Key {
+trait Key: Clone {
     fn map_crate(&self) -> CrateNum;
     fn default_span(&self, tcx: TyCtxt) -> Span;
 }
@@ -339,13 +340,13 @@ fn describe(tcx: TyCtxt, def_id: DefId) -> String {
 
 impl<'tcx> QueryDescription for queries::mir_suite<'tcx> {
     fn describe(_: TyCtxt, (suite, _): (MirSuite, DefId)) -> String {
-        format!("MIR passes #{}.*", suite.0)
+        format!("MIR suite #{}.*", suite.0)
     }
 }
 
 impl<'tcx> QueryDescription for queries::mir_pass<'tcx> {
-    fn describe(_: TyCtxt, (pass_set, pass_num, _): (MirSuite, MirPassIndex, DefId)) -> String {
-        format!("MIR pass #{}.{}", pass_set.0, pass_num.0)
+    fn describe(_: TyCtxt, (suite, pass_num, _): (MirSuite, MirPassIndex, DefId)) -> String {
+        format!("MIR pass #{}.{}", suite.0, pass_num.0)
     }
 }
 
@@ -586,22 +587,22 @@ fn default() -> Self {
     /// Performs the initial MIR construction. You almost certainly do not
     /// want to use this query, because its output is intended to be stolen
     /// immediately by the MIR passes below. Consider `optimized_mir` instead.
-    [] mir_build: Mir(DefId) -> &'tcx RefCell<mir::Mir<'tcx>>,
+    [] mir_build: Mir(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
 
     /// Fetch the MIR for a given def-id after the given set of passes has ben
     /// applied to it. This is mostly an "intermediate" query. Normally, you would
     /// prefer to use `optimized_mir(def_id)`, which will fetch the MIR after all
     /// optimizations and so forth.
-    [] mir_suite: mir_suite((MirSuite, DefId)) -> &'tcx RefCell<mir::Mir<'tcx>>,
+    [] mir_suite: mir_suite((MirSuite, DefId)) -> &'tcx Steal<mir::Mir<'tcx>>,
 
     /// Fetch the MIR for a given def-id after a given pass has been executed. This is
     /// **only** intended to be used by the `mir_suite` provider -- if you are using it
     /// manually, you're doing it wrong.
-    [] mir_pass: mir_pass((MirSuite, MirPassIndex, DefId)) -> &'tcx RefCell<mir::Mir<'tcx>>,
+    [] mir_pass: mir_pass((MirSuite, MirPassIndex, DefId)) -> &'tcx Steal<mir::Mir<'tcx>>,
 
     /// MIR after our optimization passes have run. This is MIR that is ready
     /// for trans. This is also the only query that can fetch non-local MIR, at present.
-    [] optimized_mir: Mir(DefId) -> &'tcx RefCell<mir::Mir<'tcx>>,
+    [] optimized_mir: Mir(DefId) -> &'tcx mir::Mir<'tcx>,
 
     /// Records the type of each closure. The def ID is the ID of the
     /// expression defining the closure.
@@ -650,7 +651,7 @@ fn default() -> Self {
     /// fn item.
     [] region_maps: RegionMaps(DefId) -> Rc<RegionMaps<'tcx>>,
 
-    [] mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx RefCell<mir::Mir<'tcx>>,
+    [] mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
 
     [] def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
     [] symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
index cf66c83800d367d908b4a57f7c8b0dcec065f42c..537846bc0f477c2aed396d7c673c753052c10ac7 100644 (file)
@@ -35,7 +35,7 @@
 use util::nodemap::{NodeSet, DefIdMap, FxHashMap, FxHashSet};
 
 use serialize::{self, Encodable, Encoder};
-use std::cell::{Cell, RefCell, Ref};
+use std::cell::{Cell, RefCell};
 use std::collections::BTreeMap;
 use std::cmp;
 use std::fmt;
@@ -96,6 +96,7 @@
 pub mod maps;
 pub mod outlives;
 pub mod relate;
+pub mod steal;
 pub mod subst;
 pub mod trait_def;
 pub mod walk;
@@ -2324,13 +2325,13 @@ pub fn item_name(self, id: DefId) -> ast::Name {
     }
 
     /// Given the did of an item, returns its (optimized) MIR, borrowed immutably.
-    pub fn item_mir(self, did: DefId) -> Ref<'gcx, Mir<'gcx>> {
-        self.optimized_mir(did).borrow()
+    pub fn item_mir(self, did: DefId) -> &'gcx Mir<'gcx> {
+        self.optimized_mir(did)
     }
 
     /// Return the possibly-auto-generated MIR of a (DefId, Subst) pair.
     pub fn instance_mir(self, instance: ty::InstanceDef<'gcx>)
-                        -> Ref<'gcx, Mir<'gcx>>
+                        -> &'gcx Mir<'gcx>
     {
         match instance {
             ty::InstanceDef::Item(did) => {
@@ -2341,14 +2342,14 @@ pub fn instance_mir(self, instance: ty::InstanceDef<'gcx>)
             ty::InstanceDef::Virtual(..) |
             ty::InstanceDef::ClosureOnceShim { .. } |
             ty::InstanceDef::DropGlue(..) => {
-                self.mir_shims(instance).borrow()
+                self.mir_shims(instance)
             }
         }
     }
 
     /// Given the DefId of an item, returns its MIR, borrowed immutably.
     /// Returns None if there is no MIR for the DefId
-    pub fn maybe_item_mir(self, did: DefId) -> Option<Ref<'gcx, Mir<'gcx>>> {
+    pub fn maybe_item_mir(self, did: DefId) -> Option<&'gcx Mir<'gcx>> {
         if did.is_local() && !self.mir_keys(LOCAL_CRATE).contains(&did) {
             return None;
         }
diff --git a/src/librustc/ty/steal.rs b/src/librustc/ty/steal.rs
new file mode 100644 (file)
index 0000000..0da937d
--- /dev/null
@@ -0,0 +1,27 @@
+use std::cell::{Ref, RefCell};
+use std::mem;
+
+pub struct Steal<T> {
+    value: RefCell<Option<T>>
+}
+
+impl<T> Steal<T> {
+    pub fn new(value: T) -> Self {
+        Steal {
+            value: RefCell::new(Some(value))
+        }
+    }
+
+    pub fn borrow(&self) -> Ref<T> {
+        Ref::map(self.value.borrow(), |opt| match *opt {
+            None => panic!("attempted to read from stolen value"),
+            Some(ref v) => v
+        })
+    }
+
+    pub fn steal(&self) -> T {
+        let value_ref = &mut *self.value.borrow_mut();
+        let value = mem::replace(value_ref, None);
+        value.expect("attempt to read from stolen value")
+    }
+}
index 4ecce3cc132fe72af74a63d779f24271fad41c80..7bc27596e40e79acf6a32414f05b117e0acc9643 100644 (file)
@@ -30,7 +30,6 @@
 use rustc_back::PanicStrategy;
 
 use std::any::Any;
-use std::mem;
 use std::rc::Rc;
 
 use syntax::ast;
@@ -102,9 +101,6 @@ pub fn provide<$lt>(providers: &mut Providers<$lt>) {
 
         let mir = tcx.alloc_mir(mir);
 
-        // Perma-borrow MIR from extern crates to prevent mutation.
-        mem::forget(mir.borrow());
-
         mir
     }
     mir_const_qualif => { cdata.mir_const_qualif(def_id.index) }
index 46f7c34c06e8d68b4c478e935fe52af2a865ef8b..e51a7a410e026ab46692016f74f2b0f2cb28b9a3 100644 (file)
@@ -29,6 +29,7 @@
 use rustc::traits::Reveal;
 use rustc::ty::{self, Ty, TyCtxt};
 use rustc::ty::maps::Providers;
+use rustc::ty::steal::Steal;
 use rustc::ty::subst::Substs;
 use rustc::hir;
 use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
@@ -37,7 +38,6 @@
 use syntax::ast;
 use syntax_pos::Span;
 
-use std::cell::RefCell;
 use std::mem;
 use std::rc::Rc;
 
@@ -98,7 +98,7 @@ fn nested_visit_map<'b>(&'b mut self) -> NestedVisitorMap<'b, 'tcx> {
     Rc::new(set)
 }
 
-fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx RefCell<Mir<'tcx>> {
+fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx Steal<Mir<'tcx>> {
     let id = tcx.hir.as_local_node_id(def_id).unwrap();
     let unsupported = || {
         span_bug!(tcx.hir.span(id), "can't build MIR for {:?}", def_id);
@@ -196,7 +196,7 @@ fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx RefC
 
         mir_util::dump_mir(tcx, None, "mir_map", &0, src, &mir);
 
-        tcx.alloc_mir(mir)
+        tcx.alloc_steal_mir(mir)
     })
 }
 
@@ -233,7 +233,7 @@ fn visit_substs(&mut self, substs: &mut &'tcx Substs<'tcx>) {
 fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                      ctor_id: ast::NodeId,
                                      v: &'tcx hir::VariantData)
-                                     -> &'tcx RefCell<Mir<'tcx>>
+                                     -> &'tcx Steal<Mir<'tcx>>
 {
     let span = tcx.hir.span(ctor_id);
     if let hir::VariantData::Tuple(ref fields, ctor_id) = *v {
@@ -255,7 +255,7 @@ fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
             mir_util::dump_mir(tcx, None, "mir_map", &0, src, &mir);
 
-            tcx.alloc_mir(mir)
+            tcx.alloc_steal_mir(mir)
         })
     } else {
         span_bug!(span, "attempting to create MIR for non-tuple variant {:?}", v);
index f2a550ec23a8e2abb04cea2d2dd1a7c433bed7e0..a899c69ca150acad42fc4f524dda2667e2687281 100644 (file)
 use syntax::ast;
 use syntax_pos::Span;
 
-use std::cell::RefCell;
 use std::fmt;
 use std::iter;
-use std::mem;
 
 use transform::{add_call_guards, no_landing_pads, simplify};
 use util::elaborate_drops::{self, DropElaborator, DropStyle, DropFlagMode};
@@ -39,7 +37,7 @@ pub fn provide(providers: &mut Providers) {
 
 fn make_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
                        instance: ty::InstanceDef<'tcx>)
-                       -> &'tcx RefCell<Mir<'tcx>>
+                       -> &'tcx Mir<'tcx>
 {
     debug!("make_shim({:?})", instance);
     let did = instance.def_id();
@@ -117,8 +115,6 @@ fn make_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
     debug!("make_shim({:?}) = {:?}", instance, result);
 
     let result = tcx.alloc_mir(result);
-    // Perma-borrow MIR from shims to prevent mutation.
-    mem::forget(result.borrow());
     result
 }
 
index a76ba8a8b688ccfcc7e1ba147ba5b0feaa40e17e..c00817f9179a6648695c9d2deca3f5d888a7cf79 100644 (file)
@@ -11,7 +11,6 @@
 //! This pass just dumps MIR at a specified point.
 
 use std::borrow::Cow;
-use std::cell::RefCell;
 use std::fmt;
 use std::fs::File;
 use std::io;
@@ -29,7 +28,7 @@ fn name<'a>(&'a self) -> Cow<'a, str> {
         Cow::Borrowed(self.0)
     }
 
-    fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>) -> &'tcx RefCell<Mir<'tcx>> {
+    fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>) -> Mir<'tcx> {
         mir_cx.steal_previous_mir()
     }
 }
@@ -53,9 +52,9 @@ fn on_mir_pass<'a, 'tcx: 'a>(&self,
                              mir: Option<&Mir<'tcx>>)
     {
         let tcx = mir_cx.tcx();
-        let pass_set = mir_cx.pass_set();
+        let suite = mir_cx.suite();
         let pass_num = mir_cx.pass_num();
-        let pass = tcx.mir_passes.pass(pass_set, pass_num);
+        let pass = tcx.mir_passes.pass(suite, pass_num);
         let name = &pass.name();
         let source = mir_cx.source();
         if mir_util::dump_enabled(tcx, name, source) {
@@ -68,7 +67,7 @@ fn on_mir_pass<'a, 'tcx: 'a>(&self,
                 }
             };
             mir_util::dump_mir(tcx,
-                               Some((pass_set, pass_num)),
+                               Some((suite, pass_num)),
                                name,
                                &Disambiguator { is_after: mir.is_some() },
                                source,
index 49cb254cdf289e57c89b7b39036196e340ee46dc..d30495efab571a4d9cb3cdabfe93fd1f6d06d294 100644 (file)
 use rustc::hir::def_id::DefId;
 use rustc::mir::Mir;
 use rustc::mir::transform::{MirCtxt, MirPassIndex, MirSuite, MirSource, MIR_OPTIMIZED};
+use rustc::ty::steal::Steal;
 use rustc::ty::TyCtxt;
 use rustc::ty::maps::Providers;
-use std::cell::{Ref, RefCell};
-use std::mem;
+use std::cell::Ref;
 
 pub mod simplify_branches;
 pub mod simplify;
@@ -40,19 +40,14 @@ pub fn provide(providers: &mut Providers) {
     };
 }
 
-fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx RefCell<Mir<'tcx>> {
-    let mir = tcx.mir_suite((MIR_OPTIMIZED, def_id));
-
-    // "lock" the ref cell into read mode; after this point,
-    // there ought to be no more changes to the MIR.
-    mem::drop(mir.borrow());
-
-    mir
+fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx Mir<'tcx> {
+    let mir = tcx.mir_suite((MIR_OPTIMIZED, def_id)).steal();
+    tcx.alloc_mir(mir)
 }
 
 fn mir_suite<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                        (suite, def_id): (MirSuite, DefId))
-                       -> &'tcx RefCell<Mir<'tcx>>
+                       -> &'tcx Steal<Mir<'tcx>>
 {
     let passes = &tcx.mir_passes;
     let len = passes.len_passes(suite);
@@ -62,7 +57,7 @@ fn mir_suite<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
 fn mir_pass<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                       (suite, pass_num, def_id): (MirSuite, MirPassIndex, DefId))
-                      -> &'tcx RefCell<Mir<'tcx>>
+                      -> &'tcx Steal<Mir<'tcx>>
 {
     let passes = &tcx.mir_passes;
     let pass = passes.pass(suite, pass_num);
@@ -75,10 +70,10 @@ fn mir_pass<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     let mir = pass.run_pass(&mir_ctxt);
 
     for hook in passes.hooks() {
-        hook.on_mir_pass(&mir_ctxt, Some(&mir.borrow()));
+        hook.on_mir_pass(&mir_ctxt, Some(&mir));
     }
 
-    mir
+    tcx.alloc_steal_mir(mir)
 }
 
 struct MirCtxtImpl<'a, 'tcx: 'a> {
@@ -112,10 +107,16 @@ fn source(&self) -> MirSource {
     }
 
     fn read_previous_mir(&self) -> Ref<'tcx, Mir<'tcx>> {
-        self.steal_previous_mir().borrow()
+        self.previous_mir().borrow()
     }
 
-    fn steal_previous_mir(&self) -> &'tcx RefCell<Mir<'tcx>> {
+    fn steal_previous_mir(&self) -> Mir<'tcx> {
+        self.previous_mir().steal()
+    }
+}
+
+impl<'a, 'tcx> MirCtxtImpl<'a, 'tcx> {
+    fn previous_mir(&self) -> &'tcx Steal<Mir<'tcx>> {
         let MirSuite(suite) = self.suite;
         let MirPassIndex(pass_num) = self.pass_num;
         if pass_num > 0 {
index cb002acf009d1256351e9508e721d5174d74cba0..8fc264ac1d49b70a5f0e346536d69d7203d4ff3a 100644 (file)
@@ -33,7 +33,6 @@
 use syntax::feature_gate::UnstableFeatures;
 use syntax_pos::{Span, DUMMY_SP};
 
-use std::cell::RefCell;
 use std::fmt;
 use std::usize;
 
@@ -925,7 +924,7 @@ pub fn provide(providers: &mut Providers) {
 fn qualify_const_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                 def_id: DefId)
                                 -> u8 {
-    let mir = &tcx.mir_pass_set((MIR_CONST, def_id)).borrow();
+    let mir = &tcx.mir_suite((MIR_CONST, def_id)).borrow();
     if mir.return_ty.references_error() {
         return Qualif::NOT_CONST.bits();
     }
@@ -940,7 +939,7 @@ fn qualify_const_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 pub struct QualifyAndPromoteConstants;
 
 impl DefIdPass for QualifyAndPromoteConstants {
-    fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>) -> &'tcx RefCell<Mir<'tcx>> {
+    fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>) -> Mir<'tcx> {
         let tcx = mir_cx.tcx();
         match mir_cx.source() {
             MirSource::Const(_) => {
@@ -953,8 +952,8 @@ fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>) -> &'tcx RefCell<Mi
             }
 
             src => {
-                let mir = mir_cx.steal_previous_mir();
-                self.run_pass(tcx, src, &mut mir.borrow_mut());
+                let mut mir = mir_cx.steal_previous_mir();
+                self.run_pass(tcx, src, &mut mir);
                 mir
             }
         }
index c3a30f7b8821368fb45ef147dc98dac061c0661b..4f94c4d122badfd2f82198018c947bb4fec15dfe 100644 (file)
@@ -93,7 +93,7 @@ fn dump_matched_mir_node<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     } else {
         match pass_num {
             None => format!(".-------"),
-            Some((pass_set, pass_num)) => format!(".{:03}-{:03}", pass_set.0, pass_num.0),
+            Some((suite, pass_num)) => format!(".{:03}-{:03}", suite.0, pass_num.0),
         }
     };