about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPaul Daniel Faria <Nashenas88@users.noreply.github.com>2019-10-25 10:01:08 -0400
committerPaul Daniel Faria <Nashenas88@users.noreply.github.com>2019-12-02 08:31:35 -0500
commit38c0887c769b227c827c76d80fa76fc5e4493516 (patch)
treee8de1d8fd7c896118e08e7b5090210b7d19dac9e /src
parent3642a71da21005366e5ab270cf4a347d5abeca54 (diff)
downloadrust-38c0887c769b227c827c76d80fa76fc5e4493516.tar.gz
rust-38c0887c769b227c827c76d80fa76fc5e4493516.zip
Fix remaining Body -> (ReadOnly)BodyCache type errors in librustc_mir outside of librustc_mir/transform
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/shim.rs11
-rw-r--r--src/librustc_mir/util/def_use.rs19
2 files changed, 16 insertions, 14 deletions
diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs
index 734e1a5972e..c80b6e38ac5 100644
--- a/src/librustc_mir/shim.rs
+++ b/src/librustc_mir/shim.rs
@@ -202,12 +202,14 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
         sig.inputs().len(),
         span);
 
+    let mut body_cache = BodyCache::new(&mut body);
+
     if let Some(..) = ty {
         // The first argument (index 0), but add 1 for the return value.
         let dropee_ptr = Place::from(Local::new(1+0));
         if tcx.sess.opts.debugging_opts.mir_emit_retag {
             // Function arguments should be retagged, and we make this one raw.
-            body.basic_blocks_mut()[START_BLOCK].statements.insert(0, Statement {
+            body_cache.basic_blocks_mut()[START_BLOCK].statements.insert(0, Statement {
                 source_info,
                 kind: StatementKind::Retag(RetagKind::Raw, box(dropee_ptr.clone())),
             });
@@ -215,8 +217,8 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
         let patch = {
             let param_env = tcx.param_env(def_id).with_reveal_all();
             let mut elaborator = DropShimElaborator {
-                body: &body,
-                patch: MirPatch::new(&body),
+                body: body_cache.body(),
+                patch: MirPatch::new(body_cache.body()),
                 tcx,
                 param_env
             };
@@ -233,9 +235,10 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option<Ty<'tcx>>)
             );
             elaborator.patch
         };
-        patch.apply(&mut body);
+        patch.apply(&mut body_cache);
     }
 
+    // TODO(pfaia) return owning body cache...
     body
 }
 
diff --git a/src/librustc_mir/util/def_use.rs b/src/librustc_mir/util/def_use.rs
index 1611caddad1..11b61bcd484 100644
--- a/src/librustc_mir/util/def_use.rs
+++ b/src/librustc_mir/util/def_use.rs
@@ -1,6 +1,6 @@
 //! Def-use analysis.
 
-use rustc::mir::{Body, Local, Location, PlaceElem, VarDebugInfo};
+use rustc::mir::{Body, BodyCache, Local, Location, PlaceElem, ReadOnlyBodyCache, VarDebugInfo};
 use rustc::mir::visit::{PlaceContext, MutVisitor, Visitor};
 use rustc::ty::TyCtxt;
 use rustc_index::vec::IndexVec;
@@ -30,7 +30,7 @@ impl DefUseAnalysis {
         }
     }
 
-    pub fn analyze(&mut self, body: &Body<'_>) {
+    pub fn analyze(&mut self, body_cache: &ReadOnlyBodyCache<'_, '_>) {
         self.clear();
 
         let mut finder = DefUseFinder {
@@ -38,7 +38,7 @@ impl DefUseAnalysis {
             var_debug_info_index: 0,
             in_var_debug_info: false,
         };
-        finder.visit_body(body);
+        finder.visit_body(body_cache);
         self.info = finder.info
     }
 
@@ -55,28 +55,28 @@ impl DefUseAnalysis {
     fn mutate_defs_and_uses(
         &self,
         local: Local,
-        body: &mut Body<'tcx>,
+        body_cache: &mut BodyCache<&mut Body<'tcx>>,
         new_local: Local,
         tcx: TyCtxt<'tcx>,
     ) {
-        let mut visitor = MutateUseVisitor::new(local, new_local, body, tcx);
+        let mut visitor = MutateUseVisitor::new(local, new_local, tcx);
         let info = &self.info[local];
         for place_use in &info.defs_and_uses {
-            visitor.visit_location(body, place_use.location)
+            visitor.visit_location(body_cache, place_use.location)
         }
         // Update debuginfo as well, alongside defs/uses.
         for &i in &info.var_debug_info_indices {
-            visitor.visit_var_debug_info(&mut body.var_debug_info[i]);
+            visitor.visit_var_debug_info(&mut body_cache.var_debug_info[i]);
         }
     }
 
     // FIXME(pcwalton): this should update the def-use chains.
     pub fn replace_all_defs_and_uses_with(&self,
                                           local: Local,
-                                          body: &mut Body<'tcx>,
+                                          body_cache: &mut BodyCache<&mut Body<'tcx>>,
                                           new_local: Local,
                                           tcx: TyCtxt<'tcx>) {
-        self.mutate_defs_and_uses(local, body, new_local, tcx)
+        self.mutate_defs_and_uses(local, body_cache, new_local, tcx)
     }
 }
 
@@ -156,7 +156,6 @@ impl MutateUseVisitor<'tcx> {
     fn new(
         query: Local,
         new_local: Local,
-        _: &Body<'tcx>,
         tcx: TyCtxt<'tcx>,
     ) -> MutateUseVisitor<'tcx> {
         MutateUseVisitor { query, new_local, tcx }