about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-11-26 18:15:18 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2024-12-10 12:09:25 +1100
commitdddc09d2c359b57e43a0a6729e0d5e84894fbfe9 (patch)
tree6b7014d1d970b7d59a701c68b2f966b7db8f9313
parent1d56943f34ee3e1d28ae7677b8410af867f267da (diff)
downloadrust-dddc09d2c359b57e43a0a6729e0d5e84894fbfe9.tar.gz
rust-dddc09d2c359b57e43a0a6729e0d5e84894fbfe9.zip
Reorder some `Analysis` methods.
In most places, the `early` method is listed before the corresponding
`primary` method, like you'd expect. This commit fixes two places where
that isn't the case.
-rw-r--r--compiler/rustc_mir_dataflow/src/framework/mod.rs42
-rw-r--r--compiler/rustc_mir_dataflow/src/framework/tests.rs24
2 files changed, 33 insertions, 33 deletions
diff --git a/compiler/rustc_mir_dataflow/src/framework/mod.rs b/compiler/rustc_mir_dataflow/src/framework/mod.rs
index 25c1579d4d4..f69f0e89d65 100644
--- a/compiler/rustc_mir_dataflow/src/framework/mod.rs
+++ b/compiler/rustc_mir_dataflow/src/framework/mod.rs
@@ -122,14 +122,6 @@ pub trait Analysis<'tcx> {
     // `resume`). It's not obvious how to handle `yield` points in coroutines, however.
     fn initialize_start_block(&self, body: &mir::Body<'tcx>, state: &mut Self::Domain);
 
-    /// Updates the current dataflow state with the effect of evaluating a statement.
-    fn apply_primary_statement_effect(
-        &mut self,
-        state: &mut Self::Domain,
-        statement: &mir::Statement<'tcx>,
-        location: Location,
-    );
-
     /// Updates the current dataflow state with an "early" effect, i.e. one
     /// that occurs immediately before the given statement.
     ///
@@ -145,20 +137,13 @@ pub trait Analysis<'tcx> {
     ) {
     }
 
-    /// Updates the current dataflow state with the effect of evaluating a terminator.
-    ///
-    /// The effect of a successful return from a `Call` terminator should **not** be accounted for
-    /// in this function. That should go in `apply_call_return_effect`. For example, in the
-    /// `InitializedPlaces` analyses, the return place for a function call is not marked as
-    /// initialized here.
-    fn apply_primary_terminator_effect<'mir>(
+    /// Updates the current dataflow state with the effect of evaluating a statement.
+    fn apply_primary_statement_effect(
         &mut self,
-        _state: &mut Self::Domain,
-        terminator: &'mir mir::Terminator<'tcx>,
-        _location: Location,
-    ) -> TerminatorEdges<'mir, 'tcx> {
-        terminator.edges()
-    }
+        state: &mut Self::Domain,
+        statement: &mir::Statement<'tcx>,
+        location: Location,
+    );
 
     /// Updates the current dataflow state with an effect that occurs immediately *before* the
     /// given terminator.
@@ -175,6 +160,21 @@ pub trait Analysis<'tcx> {
     ) {
     }
 
+    /// Updates the current dataflow state with the effect of evaluating a terminator.
+    ///
+    /// The effect of a successful return from a `Call` terminator should **not** be accounted for
+    /// in this function. That should go in `apply_call_return_effect`. For example, in the
+    /// `InitializedPlaces` analyses, the return place for a function call is not marked as
+    /// initialized here.
+    fn apply_primary_terminator_effect<'mir>(
+        &mut self,
+        _state: &mut Self::Domain,
+        terminator: &'mir mir::Terminator<'tcx>,
+        _location: Location,
+    ) -> TerminatorEdges<'mir, 'tcx> {
+        terminator.edges()
+    }
+
     /* Edge-specific effects */
 
     /// Updates the current dataflow state with the effect of a successful return from a `Call`
diff --git a/compiler/rustc_mir_dataflow/src/framework/tests.rs b/compiler/rustc_mir_dataflow/src/framework/tests.rs
index 87cd7ba2ec5..8e7d4ab0fa3 100644
--- a/compiler/rustc_mir_dataflow/src/framework/tests.rs
+++ b/compiler/rustc_mir_dataflow/src/framework/tests.rs
@@ -168,6 +168,16 @@ impl<'tcx, D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
         unimplemented!("This is never called since `MockAnalysis` is never iterated to fixpoint");
     }
 
+    fn apply_early_statement_effect(
+        &mut self,
+        state: &mut Self::Domain,
+        _statement: &mir::Statement<'tcx>,
+        location: Location,
+    ) {
+        let idx = self.effect(Effect::Early.at_index(location.statement_index));
+        assert!(state.insert(idx));
+    }
+
     fn apply_primary_statement_effect(
         &mut self,
         state: &mut Self::Domain,
@@ -178,10 +188,10 @@ impl<'tcx, D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
         assert!(state.insert(idx));
     }
 
-    fn apply_early_statement_effect(
+    fn apply_early_terminator_effect(
         &mut self,
         state: &mut Self::Domain,
-        _statement: &mir::Statement<'tcx>,
+        _terminator: &mir::Terminator<'tcx>,
         location: Location,
     ) {
         let idx = self.effect(Effect::Early.at_index(location.statement_index));
@@ -198,16 +208,6 @@ impl<'tcx, D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
         assert!(state.insert(idx));
         terminator.edges()
     }
-
-    fn apply_early_terminator_effect(
-        &mut self,
-        state: &mut Self::Domain,
-        _terminator: &mir::Terminator<'tcx>,
-        location: Location,
-    ) {
-        let idx = self.effect(Effect::Early.at_index(location.statement_index));
-        assert!(state.insert(idx));
-    }
 }
 
 #[derive(Clone, Copy, Debug, PartialEq, Eq)]