Skip to content

Commit dddc09d

Browse files
committed
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.
1 parent 1d56943 commit dddc09d

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

compiler/rustc_mir_dataflow/src/framework/mod.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,6 @@ pub trait Analysis<'tcx> {
122122
// `resume`). It's not obvious how to handle `yield` points in coroutines, however.
123123
fn initialize_start_block(&self, body: &mir::Body<'tcx>, state: &mut Self::Domain);
124124

125-
/// Updates the current dataflow state with the effect of evaluating a statement.
126-
fn apply_primary_statement_effect(
127-
&mut self,
128-
state: &mut Self::Domain,
129-
statement: &mir::Statement<'tcx>,
130-
location: Location,
131-
);
132-
133125
/// Updates the current dataflow state with an "early" effect, i.e. one
134126
/// that occurs immediately before the given statement.
135127
///
@@ -145,20 +137,13 @@ pub trait Analysis<'tcx> {
145137
) {
146138
}
147139

148-
/// Updates the current dataflow state with the effect of evaluating a terminator.
149-
///
150-
/// The effect of a successful return from a `Call` terminator should **not** be accounted for
151-
/// in this function. That should go in `apply_call_return_effect`. For example, in the
152-
/// `InitializedPlaces` analyses, the return place for a function call is not marked as
153-
/// initialized here.
154-
fn apply_primary_terminator_effect<'mir>(
140+
/// Updates the current dataflow state with the effect of evaluating a statement.
141+
fn apply_primary_statement_effect(
155142
&mut self,
156-
_state: &mut Self::Domain,
157-
terminator: &'mir mir::Terminator<'tcx>,
158-
_location: Location,
159-
) -> TerminatorEdges<'mir, 'tcx> {
160-
terminator.edges()
161-
}
143+
state: &mut Self::Domain,
144+
statement: &mir::Statement<'tcx>,
145+
location: Location,
146+
);
162147

163148
/// Updates the current dataflow state with an effect that occurs immediately *before* the
164149
/// given terminator.
@@ -175,6 +160,21 @@ pub trait Analysis<'tcx> {
175160
) {
176161
}
177162

163+
/// Updates the current dataflow state with the effect of evaluating a terminator.
164+
///
165+
/// The effect of a successful return from a `Call` terminator should **not** be accounted for
166+
/// in this function. That should go in `apply_call_return_effect`. For example, in the
167+
/// `InitializedPlaces` analyses, the return place for a function call is not marked as
168+
/// initialized here.
169+
fn apply_primary_terminator_effect<'mir>(
170+
&mut self,
171+
_state: &mut Self::Domain,
172+
terminator: &'mir mir::Terminator<'tcx>,
173+
_location: Location,
174+
) -> TerminatorEdges<'mir, 'tcx> {
175+
terminator.edges()
176+
}
177+
178178
/* Edge-specific effects */
179179

180180
/// Updates the current dataflow state with the effect of a successful return from a `Call`

compiler/rustc_mir_dataflow/src/framework/tests.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,16 @@ impl<'tcx, D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
168168
unimplemented!("This is never called since `MockAnalysis` is never iterated to fixpoint");
169169
}
170170

171+
fn apply_early_statement_effect(
172+
&mut self,
173+
state: &mut Self::Domain,
174+
_statement: &mir::Statement<'tcx>,
175+
location: Location,
176+
) {
177+
let idx = self.effect(Effect::Early.at_index(location.statement_index));
178+
assert!(state.insert(idx));
179+
}
180+
171181
fn apply_primary_statement_effect(
172182
&mut self,
173183
state: &mut Self::Domain,
@@ -178,10 +188,10 @@ impl<'tcx, D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
178188
assert!(state.insert(idx));
179189
}
180190

181-
fn apply_early_statement_effect(
191+
fn apply_early_terminator_effect(
182192
&mut self,
183193
state: &mut Self::Domain,
184-
_statement: &mir::Statement<'tcx>,
194+
_terminator: &mir::Terminator<'tcx>,
185195
location: Location,
186196
) {
187197
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> {
198208
assert!(state.insert(idx));
199209
terminator.edges()
200210
}
201-
202-
fn apply_early_terminator_effect(
203-
&mut self,
204-
state: &mut Self::Domain,
205-
_terminator: &mir::Terminator<'tcx>,
206-
location: Location,
207-
) {
208-
let idx = self.effect(Effect::Early.at_index(location.statement_index));
209-
assert!(state.insert(idx));
210-
}
211211
}
212212

213213
#[derive(Clone, Copy, Debug, PartialEq, Eq)]

0 commit comments

Comments
 (0)