about summary refs log tree commit diff
path: root/compiler/rustc_mir_dataflow
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2023-11-23 17:17:52 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2023-11-27 10:35:42 +1100
commitd957c4718377b8cb0dacc58cdbaa5a3fe82c53cc (patch)
tree9b8e10cd70b62f40c1e3caa0ba0afdb1fc4ab374 /compiler/rustc_mir_dataflow
parent389e2cc69a917ea7ddc40bef0c1bda0466b423db (diff)
downloadrust-d957c4718377b8cb0dacc58cdbaa5a3fe82c53cc.tar.gz
rust-d957c4718377b8cb0dacc58cdbaa5a3fe82c53cc.zip
Remove `CloneAnalysis`.
It's only implemented for analyses that implement `Copy`, which means
it's basically a complicated synonym for `Copy`. So this commit removes
it and uses `Copy` directly. (That direct use will be removed in a later
commit.)
Diffstat (limited to 'compiler/rustc_mir_dataflow')
-rw-r--r--compiler/rustc_mir_dataflow/src/framework/engine.rs19
-rw-r--r--compiler/rustc_mir_dataflow/src/framework/mod.rs15
2 files changed, 5 insertions, 29 deletions
diff --git a/compiler/rustc_mir_dataflow/src/framework/engine.rs b/compiler/rustc_mir_dataflow/src/framework/engine.rs
index 78b57008233..442b1facfc6 100644
--- a/compiler/rustc_mir_dataflow/src/framework/engine.rs
+++ b/compiler/rustc_mir_dataflow/src/framework/engine.rs
@@ -24,9 +24,8 @@ use rustc_span::symbol::{sym, Symbol};
 use super::fmt::DebugWithContext;
 use super::graphviz;
 use super::{
-    visit_results, Analysis, AnalysisDomain, CloneAnalysis, Direction, GenKill, GenKillAnalysis,
-    GenKillSet, JoinSemiLattice, ResultsClonedCursor, ResultsCursor, ResultsRefCursor,
-    ResultsVisitor,
+    visit_results, Analysis, AnalysisDomain, Direction, GenKill, GenKillAnalysis, GenKillSet,
+    JoinSemiLattice, ResultsClonedCursor, ResultsCursor, ResultsRefCursor, ResultsVisitor,
 };
 
 pub type EntrySets<'tcx, A> = IndexVec<BasicBlock, <A as AnalysisDomain<'tcx>>::Domain>;
@@ -96,23 +95,15 @@ where
 
 impl<'tcx, A> Results<'tcx, A>
 where
-    A: Analysis<'tcx> + CloneAnalysis,
+    A: Analysis<'tcx> + Copy,
 {
-    /// Creates a new `Results` type with a cloned `Analysis` and borrowed entry sets.
-    pub fn clone_analysis(&self) -> ResultsCloned<'_, 'tcx, A> {
-        Results {
-            analysis: self.analysis.clone_analysis(),
-            entry_sets: &self.entry_sets,
-            _marker: PhantomData,
-        }
-    }
-
     /// Creates a `ResultsCursor` that can inspect these `Results`.
     pub fn cloned_results_cursor<'mir>(
         &self,
         body: &'mir mir::Body<'tcx>,
     ) -> ResultsClonedCursor<'_, 'mir, 'tcx, A> {
-        self.clone_analysis().into_results_cursor(body)
+        Results { analysis: self.analysis, entry_sets: &self.entry_sets, _marker: PhantomData }
+            .into_results_cursor(body)
     }
 }
 
diff --git a/compiler/rustc_mir_dataflow/src/framework/mod.rs b/compiler/rustc_mir_dataflow/src/framework/mod.rs
index a5ae1edf221..36c02e329e3 100644
--- a/compiler/rustc_mir_dataflow/src/framework/mod.rs
+++ b/compiler/rustc_mir_dataflow/src/framework/mod.rs
@@ -246,21 +246,6 @@ pub trait Analysis<'tcx>: AnalysisDomain<'tcx> {
     }
 }
 
-/// Defines an `Analysis` which can be cloned for use in multiple `ResultsCursor`s or
-/// `ResultsVisitor`s. Note this need not be a full clone, only enough of one to be used with a new
-/// `ResultsCursor` or `ResultsVisitor`
-pub trait CloneAnalysis {
-    fn clone_analysis(&self) -> Self;
-}
-impl<'tcx, A> CloneAnalysis for A
-where
-    A: Analysis<'tcx> + Copy,
-{
-    fn clone_analysis(&self) -> Self {
-        *self
-    }
-}
-
 /// A gen/kill dataflow problem.
 ///
 /// Each method in this trait has a corresponding one in `Analysis`. However, these methods only