about summary refs log tree commit diff
path: root/compiler/rustc_mir_dataflow/src
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_mir_dataflow/src')
-rw-r--r--compiler/rustc_mir_dataflow/src/move_paths/builder.rs17
-rw-r--r--compiler/rustc_mir_dataflow/src/move_paths/mod.rs5
-rw-r--r--compiler/rustc_mir_dataflow/src/rustc_peek.rs4
-rw-r--r--compiler/rustc_mir_dataflow/src/un_derefer.rs16
4 files changed, 21 insertions, 21 deletions
diff --git a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs
index 19aa71d7bc7..462429d1a22 100644
--- a/compiler/rustc_mir_dataflow/src/move_paths/builder.rs
+++ b/compiler/rustc_mir_dataflow/src/move_paths/builder.rs
@@ -1,4 +1,5 @@
 use crate::un_derefer::UnDerefer;
+use rustc_data_structures::stable_map::FxHashMap;
 use rustc_index::vec::IndexVec;
 use rustc_middle::mir::tcx::RvalueInitializationState;
 use rustc_middle::mir::*;
@@ -209,7 +210,10 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
 impl<'a, 'tcx> MoveDataBuilder<'a, 'tcx> {
     fn finalize(
         self,
-    ) -> Result<MoveData<'tcx>, (MoveData<'tcx>, Vec<(Place<'tcx>, MoveError<'tcx>)>)> {
+    ) -> Result<
+        (FxHashMap<rustc_middle::mir::Local, rustc_middle::mir::Place<'tcx>>, MoveData<'tcx>),
+        (MoveData<'tcx>, Vec<(Place<'tcx>, MoveError<'tcx>)>),
+    > {
         debug!("{}", {
             debug!("moves for {:?}:", self.body.span);
             for (j, mo) in self.data.moves.iter_enumerated() {
@@ -222,7 +226,11 @@ impl<'a, 'tcx> MoveDataBuilder<'a, 'tcx> {
             "done dumping moves"
         });
 
-        if !self.errors.is_empty() { Err((self.data, self.errors)) } else { Ok(self.data) }
+        if !self.errors.is_empty() {
+            Err((self.data, self.errors))
+        } else {
+            Ok((self.un_derefer.derefer_sidetable.clone(), self.data))
+        }
     }
 }
 
@@ -230,7 +238,10 @@ pub(super) fn gather_moves<'tcx>(
     body: &Body<'tcx>,
     tcx: TyCtxt<'tcx>,
     param_env: ty::ParamEnv<'tcx>,
-) -> Result<MoveData<'tcx>, (MoveData<'tcx>, Vec<(Place<'tcx>, MoveError<'tcx>)>)> {
+) -> Result<
+    (FxHashMap<rustc_middle::mir::Local, rustc_middle::mir::Place<'tcx>>, MoveData<'tcx>),
+    (MoveData<'tcx>, Vec<(Place<'tcx>, MoveError<'tcx>)>),
+> {
     let mut builder = MoveDataBuilder::new(body, tcx, param_env);
 
     builder.gather_args();
diff --git a/compiler/rustc_mir_dataflow/src/move_paths/mod.rs b/compiler/rustc_mir_dataflow/src/move_paths/mod.rs
index 1af789b4885..b6050a1ccaa 100644
--- a/compiler/rustc_mir_dataflow/src/move_paths/mod.rs
+++ b/compiler/rustc_mir_dataflow/src/move_paths/mod.rs
@@ -386,7 +386,10 @@ impl<'tcx> MoveData<'tcx> {
         body: &Body<'tcx>,
         tcx: TyCtxt<'tcx>,
         param_env: ParamEnv<'tcx>,
-    ) -> Result<Self, (Self, Vec<(Place<'tcx>, MoveError<'tcx>)>)> {
+    ) -> Result<
+        (FxHashMap<rustc_middle::mir::Local, rustc_middle::mir::Place<'tcx>>, MoveData<'tcx>),
+        (MoveData<'tcx>, Vec<(Place<'tcx>, MoveError<'tcx>)>),
+    > {
         builder::gather_moves(body, tcx, param_env)
     }
 
diff --git a/compiler/rustc_mir_dataflow/src/rustc_peek.rs b/compiler/rustc_mir_dataflow/src/rustc_peek.rs
index e1df482786f..98671a86816 100644
--- a/compiler/rustc_mir_dataflow/src/rustc_peek.rs
+++ b/compiler/rustc_mir_dataflow/src/rustc_peek.rs
@@ -30,8 +30,8 @@ impl<'tcx> MirPass<'tcx> for SanityCheck {
         }
 
         let param_env = tcx.param_env(def_id);
-        let move_data = MoveData::gather_moves(body, tcx, param_env).unwrap();
-        let mdpe = MoveDataParamEnv { move_data, param_env };
+        let (_, move_data) = MoveData::gather_moves(body, tcx, param_env).unwrap();
+        let mdpe = MoveDataParamEnv { move_data: move_data, param_env };
 
         if has_rustc_mir_with(tcx, def_id, sym::rustc_peek_maybe_init).is_some() {
             let flow_inits = MaybeInitializedPlaces::new(tcx, body, &mdpe)
diff --git a/compiler/rustc_mir_dataflow/src/un_derefer.rs b/compiler/rustc_mir_dataflow/src/un_derefer.rs
index ec2e516f7ac..04f626b49e8 100644
--- a/compiler/rustc_mir_dataflow/src/un_derefer.rs
+++ b/compiler/rustc_mir_dataflow/src/un_derefer.rs
@@ -9,6 +9,7 @@ pub struct UnDerefer<'tcx> {
 }
 
 impl<'tcx> UnDerefer<'tcx> {
+    #[inline]
     pub fn derefer(&self, place: PlaceRef<'tcx>, body: &Body<'tcx>) -> Option<Place<'tcx>> {
         let reffed = self.derefer_sidetable.get(&place.local)?;
 
@@ -18,19 +19,4 @@ impl<'tcx> UnDerefer<'tcx> {
         }
         Some(new_place)
     }
-
-    pub fn ref_finder(&mut self, body: &Body<'tcx>) {
-        for (_bb, data) in body.basic_blocks().iter_enumerated() {
-            for stmt in data.statements.iter() {
-                match stmt.kind {
-                    StatementKind::Assign(box (place, Rvalue::CopyForDeref(reffed))) => {
-                        if body.local_decls[place.local].is_deref_temp() {
-                            self.derefer_sidetable.insert(place.local, reffed);
-                        }
-                    }
-                    _ => (),
-                }
-            }
-        }
-    }
 }