Rename some Analysis
and ResultsVisitor
methods.
The words "before" and "after" have an obvious temporal meaning, e.g. `seek_before_primary_effect`, `visit_statement_{before,after}_primary_effect`. But "before" is also used to name the effect that occurs before the primary effect of a statement/terminator; this is `Effect::Before`. This leads to the confusing possibility of talking about things happening "before/after the before event". This commit removes this awkward overloading of "before" by renaming `Effect::Before` as `Effect::Early`. It also renames some of the `Analysis` and `ResultsVisitor` methods to be more consistent. Here are the before and after names: - `Effect::{Before,Primary}` -> `Effect::{Early,Primary}` - `apply_before_statement_effect` -> `apply_early_statement_effect` - `apply_statement_effect` -> `apply_primary_statement_effect` - `visit_statement_before_primary_effect` -> `visit_after_early_statement_effect` - `visit_statement_after_primary_effect` -> `visit_after_primary_statement_effect` (And s/statement/terminator/ for all the terminator events.)
This commit is contained in:
parent
119fbd32dc
commit
1d56943f34
16 changed files with 148 additions and 150 deletions
|
@ -44,48 +44,48 @@ impl<'a, 'tcx> Analysis<'tcx> for Borrowck<'a, 'tcx> {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_before_statement_effect(
|
fn apply_early_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
stmt: &mir::Statement<'tcx>,
|
stmt: &mir::Statement<'tcx>,
|
||||||
loc: Location,
|
loc: Location,
|
||||||
) {
|
) {
|
||||||
self.borrows.apply_before_statement_effect(&mut state.borrows, stmt, loc);
|
self.borrows.apply_early_statement_effect(&mut state.borrows, stmt, loc);
|
||||||
self.uninits.apply_before_statement_effect(&mut state.uninits, stmt, loc);
|
self.uninits.apply_early_statement_effect(&mut state.uninits, stmt, loc);
|
||||||
self.ever_inits.apply_before_statement_effect(&mut state.ever_inits, stmt, loc);
|
self.ever_inits.apply_early_statement_effect(&mut state.ever_inits, stmt, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_statement_effect(
|
fn apply_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
stmt: &mir::Statement<'tcx>,
|
stmt: &mir::Statement<'tcx>,
|
||||||
loc: Location,
|
loc: Location,
|
||||||
) {
|
) {
|
||||||
self.borrows.apply_statement_effect(&mut state.borrows, stmt, loc);
|
self.borrows.apply_primary_statement_effect(&mut state.borrows, stmt, loc);
|
||||||
self.uninits.apply_statement_effect(&mut state.uninits, stmt, loc);
|
self.uninits.apply_primary_statement_effect(&mut state.uninits, stmt, loc);
|
||||||
self.ever_inits.apply_statement_effect(&mut state.ever_inits, stmt, loc);
|
self.ever_inits.apply_primary_statement_effect(&mut state.ever_inits, stmt, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_before_terminator_effect(
|
fn apply_early_terminator_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
term: &mir::Terminator<'tcx>,
|
term: &mir::Terminator<'tcx>,
|
||||||
loc: Location,
|
loc: Location,
|
||||||
) {
|
) {
|
||||||
self.borrows.apply_before_terminator_effect(&mut state.borrows, term, loc);
|
self.borrows.apply_early_terminator_effect(&mut state.borrows, term, loc);
|
||||||
self.uninits.apply_before_terminator_effect(&mut state.uninits, term, loc);
|
self.uninits.apply_early_terminator_effect(&mut state.uninits, term, loc);
|
||||||
self.ever_inits.apply_before_terminator_effect(&mut state.ever_inits, term, loc);
|
self.ever_inits.apply_early_terminator_effect(&mut state.ever_inits, term, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_terminator_effect<'mir>(
|
fn apply_primary_terminator_effect<'mir>(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
term: &'mir mir::Terminator<'tcx>,
|
term: &'mir mir::Terminator<'tcx>,
|
||||||
loc: Location,
|
loc: Location,
|
||||||
) -> TerminatorEdges<'mir, 'tcx> {
|
) -> TerminatorEdges<'mir, 'tcx> {
|
||||||
self.borrows.apply_terminator_effect(&mut state.borrows, term, loc);
|
self.borrows.apply_primary_terminator_effect(&mut state.borrows, term, loc);
|
||||||
self.uninits.apply_terminator_effect(&mut state.uninits, term, loc);
|
self.uninits.apply_primary_terminator_effect(&mut state.uninits, term, loc);
|
||||||
self.ever_inits.apply_terminator_effect(&mut state.ever_inits, term, loc);
|
self.ever_inits.apply_primary_terminator_effect(&mut state.ever_inits, term, loc);
|
||||||
|
|
||||||
// This return value doesn't matter. It's only used by `iterate_to_fixpoint`, which this
|
// This return value doesn't matter. It's only used by `iterate_to_fixpoint`, which this
|
||||||
// analysis doesn't use.
|
// analysis doesn't use.
|
||||||
|
@ -593,7 +593,7 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
|
||||||
// function execution, so this method has no effect.
|
// function execution, so this method has no effect.
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_before_statement_effect(
|
fn apply_early_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
_statement: &mir::Statement<'tcx>,
|
_statement: &mir::Statement<'tcx>,
|
||||||
|
@ -602,7 +602,7 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
|
||||||
self.kill_loans_out_of_scope_at_location(state, location);
|
self.kill_loans_out_of_scope_at_location(state, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_statement_effect(
|
fn apply_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
stmt: &mir::Statement<'tcx>,
|
stmt: &mir::Statement<'tcx>,
|
||||||
|
@ -651,7 +651,7 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_before_terminator_effect(
|
fn apply_early_terminator_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
_terminator: &mir::Terminator<'tcx>,
|
_terminator: &mir::Terminator<'tcx>,
|
||||||
|
@ -660,7 +660,7 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
|
||||||
self.kill_loans_out_of_scope_at_location(state, location);
|
self.kill_loans_out_of_scope_at_location(state, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_terminator_effect<'mir>(
|
fn apply_primary_terminator_effect<'mir>(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
terminator: &'mir mir::Terminator<'tcx>,
|
terminator: &'mir mir::Terminator<'tcx>,
|
||||||
|
|
|
@ -600,7 +600,7 @@ struct MirBorrowckCtxt<'a, 'infcx, 'tcx> {
|
||||||
// 3. assignments do not affect things loaned out as immutable
|
// 3. assignments do not affect things loaned out as immutable
|
||||||
// 4. moves do not affect things loaned out in any way
|
// 4. moves do not affect things loaned out in any way
|
||||||
impl<'a, 'tcx> ResultsVisitor<'a, 'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<'a, '_, 'tcx> {
|
impl<'a, 'tcx> ResultsVisitor<'a, 'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<'a, '_, 'tcx> {
|
||||||
fn visit_statement_before_primary_effect(
|
fn visit_after_early_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
_results: &mut Results<'tcx, Borrowck<'a, 'tcx>>,
|
_results: &mut Results<'tcx, Borrowck<'a, 'tcx>>,
|
||||||
state: &BorrowckDomain,
|
state: &BorrowckDomain,
|
||||||
|
@ -674,7 +674,7 @@ impl<'a, 'tcx> ResultsVisitor<'a, 'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator_before_primary_effect(
|
fn visit_after_early_terminator_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
_results: &mut Results<'tcx, Borrowck<'a, 'tcx>>,
|
_results: &mut Results<'tcx, Borrowck<'a, 'tcx>>,
|
||||||
state: &BorrowckDomain,
|
state: &BorrowckDomain,
|
||||||
|
@ -787,7 +787,7 @@ impl<'a, 'tcx> ResultsVisitor<'a, 'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator_after_primary_effect(
|
fn visit_after_primary_terminator_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
_results: &mut Results<'tcx, Borrowck<'a, 'tcx>>,
|
_results: &mut Results<'tcx, Borrowck<'a, 'tcx>>,
|
||||||
state: &BorrowckDomain,
|
state: &BorrowckDomain,
|
||||||
|
|
|
@ -329,7 +329,7 @@ where
|
||||||
self.transfer_function(state).initialize_state();
|
self.transfer_function(state).initialize_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_statement_effect(
|
fn apply_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
statement: &mir::Statement<'tcx>,
|
statement: &mir::Statement<'tcx>,
|
||||||
|
@ -338,7 +338,7 @@ where
|
||||||
self.transfer_function(state).visit_statement(statement, location);
|
self.transfer_function(state).visit_statement(statement, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_terminator_effect<'mir>(
|
fn apply_primary_terminator_effect<'mir>(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
terminator: &'mir mir::Terminator<'tcx>,
|
terminator: &'mir mir::Terminator<'tcx>,
|
||||||
|
|
|
@ -179,15 +179,15 @@ where
|
||||||
/// Advances the cursor to hold the dataflow state at `target` before its "primary" effect is
|
/// Advances the cursor to hold the dataflow state at `target` before its "primary" effect is
|
||||||
/// applied.
|
/// applied.
|
||||||
///
|
///
|
||||||
/// The "before" effect at the target location *will be* applied.
|
/// The "early" effect at the target location *will be* applied.
|
||||||
pub fn seek_before_primary_effect(&mut self, target: Location) {
|
pub fn seek_before_primary_effect(&mut self, target: Location) {
|
||||||
self.seek_after(target, Effect::Before)
|
self.seek_after(target, Effect::Early)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Advances the cursor to hold the dataflow state at `target` after its "primary" effect is
|
/// Advances the cursor to hold the dataflow state at `target` after its "primary" effect is
|
||||||
/// applied.
|
/// applied.
|
||||||
///
|
///
|
||||||
/// The "before" effect at the target location will be applied as well.
|
/// The "early" effect at the target location will be applied as well.
|
||||||
pub fn seek_after_primary_effect(&mut self, target: Location) {
|
pub fn seek_after_primary_effect(&mut self, target: Location) {
|
||||||
self.seek_after(target, Effect::Primary)
|
self.seek_after(target, Effect::Primary)
|
||||||
}
|
}
|
||||||
|
@ -222,12 +222,12 @@ where
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
let next_effect = if A::Direction::IS_FORWARD {
|
let next_effect = if A::Direction::IS_FORWARD {
|
||||||
self.pos.curr_effect_index.map_or_else(
|
self.pos.curr_effect_index.map_or_else(
|
||||||
|| Effect::Before.at_index(0),
|
|| Effect::Early.at_index(0),
|
||||||
EffectIndex::next_in_forward_order,
|
EffectIndex::next_in_forward_order,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
self.pos.curr_effect_index.map_or_else(
|
self.pos.curr_effect_index.map_or_else(
|
||||||
|| Effect::Before.at_index(block_data.statements.len()),
|
|| Effect::Early.at_index(block_data.statements.len()),
|
||||||
EffectIndex::next_in_backward_order,
|
EffectIndex::next_in_backward_order,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
|
@ -66,12 +66,12 @@ impl Direction for Backward {
|
||||||
{
|
{
|
||||||
let terminator = block_data.terminator();
|
let terminator = block_data.terminator();
|
||||||
let location = Location { block, statement_index: block_data.statements.len() };
|
let location = Location { block, statement_index: block_data.statements.len() };
|
||||||
analysis.apply_before_terminator_effect(state, terminator, location);
|
analysis.apply_early_terminator_effect(state, terminator, location);
|
||||||
analysis.apply_terminator_effect(state, terminator, location);
|
analysis.apply_primary_terminator_effect(state, terminator, location);
|
||||||
for (statement_index, statement) in block_data.statements.iter().enumerate().rev() {
|
for (statement_index, statement) in block_data.statements.iter().enumerate().rev() {
|
||||||
let location = Location { block, statement_index };
|
let location = Location { block, statement_index };
|
||||||
analysis.apply_before_statement_effect(state, statement, location);
|
analysis.apply_early_statement_effect(state, statement, location);
|
||||||
analysis.apply_statement_effect(state, statement, location);
|
analysis.apply_primary_statement_effect(state, statement, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
let exit_state = state;
|
let exit_state = state;
|
||||||
|
@ -159,14 +159,14 @@ impl Direction for Backward {
|
||||||
let location = Location { block, statement_index: from.statement_index };
|
let location = Location { block, statement_index: from.statement_index };
|
||||||
let terminator = block_data.terminator();
|
let terminator = block_data.terminator();
|
||||||
|
|
||||||
if from.effect == Effect::Before {
|
if from.effect == Effect::Early {
|
||||||
analysis.apply_before_terminator_effect(state, terminator, location);
|
analysis.apply_early_terminator_effect(state, terminator, location);
|
||||||
if to == Effect::Before.at_index(terminator_index) {
|
if to == Effect::Early.at_index(terminator_index) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
analysis.apply_terminator_effect(state, terminator, location);
|
analysis.apply_primary_terminator_effect(state, terminator, location);
|
||||||
if to == Effect::Primary.at_index(terminator_index) {
|
if to == Effect::Primary.at_index(terminator_index) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ impl Direction for Backward {
|
||||||
let location = Location { block, statement_index: from.statement_index };
|
let location = Location { block, statement_index: from.statement_index };
|
||||||
let statement = &block_data.statements[from.statement_index];
|
let statement = &block_data.statements[from.statement_index];
|
||||||
|
|
||||||
analysis.apply_statement_effect(state, statement, location);
|
analysis.apply_primary_statement_effect(state, statement, location);
|
||||||
if to == Effect::Primary.at_index(from.statement_index) {
|
if to == Effect::Primary.at_index(from.statement_index) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ impl Direction for Backward {
|
||||||
from.statement_index - 1
|
from.statement_index - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
Effect::Before => from.statement_index,
|
Effect::Early => from.statement_index,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle all statements between `first_unapplied_idx` and `to.statement_index`.
|
// Handle all statements between `first_unapplied_idx` and `to.statement_index`.
|
||||||
|
@ -196,21 +196,21 @@ impl Direction for Backward {
|
||||||
for statement_index in (to.statement_index..next_effect).rev().map(|i| i + 1) {
|
for statement_index in (to.statement_index..next_effect).rev().map(|i| i + 1) {
|
||||||
let location = Location { block, statement_index };
|
let location = Location { block, statement_index };
|
||||||
let statement = &block_data.statements[statement_index];
|
let statement = &block_data.statements[statement_index];
|
||||||
analysis.apply_before_statement_effect(state, statement, location);
|
analysis.apply_early_statement_effect(state, statement, location);
|
||||||
analysis.apply_statement_effect(state, statement, location);
|
analysis.apply_primary_statement_effect(state, statement, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle the statement at `to`.
|
// Handle the statement at `to`.
|
||||||
|
|
||||||
let location = Location { block, statement_index: to.statement_index };
|
let location = Location { block, statement_index: to.statement_index };
|
||||||
let statement = &block_data.statements[to.statement_index];
|
let statement = &block_data.statements[to.statement_index];
|
||||||
analysis.apply_before_statement_effect(state, statement, location);
|
analysis.apply_early_statement_effect(state, statement, location);
|
||||||
|
|
||||||
if to.effect == Effect::Before {
|
if to.effect == Effect::Early {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
analysis.apply_statement_effect(state, statement, location);
|
analysis.apply_primary_statement_effect(state, statement, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_results_in_block<'mir, 'tcx, A>(
|
fn visit_results_in_block<'mir, 'tcx, A>(
|
||||||
|
@ -228,17 +228,17 @@ impl Direction for Backward {
|
||||||
|
|
||||||
let loc = Location { block, statement_index: block_data.statements.len() };
|
let loc = Location { block, statement_index: block_data.statements.len() };
|
||||||
let term = block_data.terminator();
|
let term = block_data.terminator();
|
||||||
results.analysis.apply_before_terminator_effect(state, term, loc);
|
results.analysis.apply_early_terminator_effect(state, term, loc);
|
||||||
vis.visit_terminator_before_primary_effect(results, state, term, loc);
|
vis.visit_after_early_terminator_effect(results, state, term, loc);
|
||||||
results.analysis.apply_terminator_effect(state, term, loc);
|
results.analysis.apply_primary_terminator_effect(state, term, loc);
|
||||||
vis.visit_terminator_after_primary_effect(results, state, term, loc);
|
vis.visit_after_primary_terminator_effect(results, state, term, loc);
|
||||||
|
|
||||||
for (statement_index, stmt) in block_data.statements.iter().enumerate().rev() {
|
for (statement_index, stmt) in block_data.statements.iter().enumerate().rev() {
|
||||||
let loc = Location { block, statement_index };
|
let loc = Location { block, statement_index };
|
||||||
results.analysis.apply_before_statement_effect(state, stmt, loc);
|
results.analysis.apply_early_statement_effect(state, stmt, loc);
|
||||||
vis.visit_statement_before_primary_effect(results, state, stmt, loc);
|
vis.visit_after_early_statement_effect(results, state, stmt, loc);
|
||||||
results.analysis.apply_statement_effect(state, stmt, loc);
|
results.analysis.apply_primary_statement_effect(state, stmt, loc);
|
||||||
vis.visit_statement_after_primary_effect(results, state, stmt, loc);
|
vis.visit_after_primary_statement_effect(results, state, stmt, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
vis.visit_block_start(state);
|
vis.visit_block_start(state);
|
||||||
|
@ -294,13 +294,13 @@ impl Direction for Forward {
|
||||||
{
|
{
|
||||||
for (statement_index, statement) in block_data.statements.iter().enumerate() {
|
for (statement_index, statement) in block_data.statements.iter().enumerate() {
|
||||||
let location = Location { block, statement_index };
|
let location = Location { block, statement_index };
|
||||||
analysis.apply_before_statement_effect(state, statement, location);
|
analysis.apply_early_statement_effect(state, statement, location);
|
||||||
analysis.apply_statement_effect(state, statement, location);
|
analysis.apply_primary_statement_effect(state, statement, location);
|
||||||
}
|
}
|
||||||
let terminator = block_data.terminator();
|
let terminator = block_data.terminator();
|
||||||
let location = Location { block, statement_index: block_data.statements.len() };
|
let location = Location { block, statement_index: block_data.statements.len() };
|
||||||
analysis.apply_before_terminator_effect(state, terminator, location);
|
analysis.apply_early_terminator_effect(state, terminator, location);
|
||||||
let edges = analysis.apply_terminator_effect(state, terminator, location);
|
let edges = analysis.apply_primary_terminator_effect(state, terminator, location);
|
||||||
|
|
||||||
let exit_state = state;
|
let exit_state = state;
|
||||||
match edges {
|
match edges {
|
||||||
|
@ -368,21 +368,21 @@ impl Direction for Forward {
|
||||||
// after effect, do so now and start the loop below from the next statement.
|
// after effect, do so now and start the loop below from the next statement.
|
||||||
|
|
||||||
let first_unapplied_index = match from.effect {
|
let first_unapplied_index = match from.effect {
|
||||||
Effect::Before => from.statement_index,
|
Effect::Early => from.statement_index,
|
||||||
|
|
||||||
Effect::Primary if from.statement_index == terminator_index => {
|
Effect::Primary if from.statement_index == terminator_index => {
|
||||||
debug_assert_eq!(from, to);
|
debug_assert_eq!(from, to);
|
||||||
|
|
||||||
let location = Location { block, statement_index: terminator_index };
|
let location = Location { block, statement_index: terminator_index };
|
||||||
let terminator = block_data.terminator();
|
let terminator = block_data.terminator();
|
||||||
analysis.apply_terminator_effect(state, terminator, location);
|
analysis.apply_primary_terminator_effect(state, terminator, location);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Effect::Primary => {
|
Effect::Primary => {
|
||||||
let location = Location { block, statement_index: from.statement_index };
|
let location = Location { block, statement_index: from.statement_index };
|
||||||
let statement = &block_data.statements[from.statement_index];
|
let statement = &block_data.statements[from.statement_index];
|
||||||
analysis.apply_statement_effect(state, statement, location);
|
analysis.apply_primary_statement_effect(state, statement, location);
|
||||||
|
|
||||||
// If we only needed to apply the after effect of the statement at `idx`, we are
|
// If we only needed to apply the after effect of the statement at `idx`, we are
|
||||||
// done.
|
// done.
|
||||||
|
@ -399,8 +399,8 @@ impl Direction for Forward {
|
||||||
for statement_index in first_unapplied_index..to.statement_index {
|
for statement_index in first_unapplied_index..to.statement_index {
|
||||||
let location = Location { block, statement_index };
|
let location = Location { block, statement_index };
|
||||||
let statement = &block_data.statements[statement_index];
|
let statement = &block_data.statements[statement_index];
|
||||||
analysis.apply_before_statement_effect(state, statement, location);
|
analysis.apply_early_statement_effect(state, statement, location);
|
||||||
analysis.apply_statement_effect(state, statement, location);
|
analysis.apply_primary_statement_effect(state, statement, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle the statement or terminator at `to`.
|
// Handle the statement or terminator at `to`.
|
||||||
|
@ -408,17 +408,17 @@ impl Direction for Forward {
|
||||||
let location = Location { block, statement_index: to.statement_index };
|
let location = Location { block, statement_index: to.statement_index };
|
||||||
if to.statement_index == terminator_index {
|
if to.statement_index == terminator_index {
|
||||||
let terminator = block_data.terminator();
|
let terminator = block_data.terminator();
|
||||||
analysis.apply_before_terminator_effect(state, terminator, location);
|
analysis.apply_early_terminator_effect(state, terminator, location);
|
||||||
|
|
||||||
if to.effect == Effect::Primary {
|
if to.effect == Effect::Primary {
|
||||||
analysis.apply_terminator_effect(state, terminator, location);
|
analysis.apply_primary_terminator_effect(state, terminator, location);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let statement = &block_data.statements[to.statement_index];
|
let statement = &block_data.statements[to.statement_index];
|
||||||
analysis.apply_before_statement_effect(state, statement, location);
|
analysis.apply_early_statement_effect(state, statement, location);
|
||||||
|
|
||||||
if to.effect == Effect::Primary {
|
if to.effect == Effect::Primary {
|
||||||
analysis.apply_statement_effect(state, statement, location);
|
analysis.apply_primary_statement_effect(state, statement, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -438,18 +438,18 @@ impl Direction for Forward {
|
||||||
|
|
||||||
for (statement_index, stmt) in block_data.statements.iter().enumerate() {
|
for (statement_index, stmt) in block_data.statements.iter().enumerate() {
|
||||||
let loc = Location { block, statement_index };
|
let loc = Location { block, statement_index };
|
||||||
results.analysis.apply_before_statement_effect(state, stmt, loc);
|
results.analysis.apply_early_statement_effect(state, stmt, loc);
|
||||||
vis.visit_statement_before_primary_effect(results, state, stmt, loc);
|
vis.visit_after_early_statement_effect(results, state, stmt, loc);
|
||||||
results.analysis.apply_statement_effect(state, stmt, loc);
|
results.analysis.apply_primary_statement_effect(state, stmt, loc);
|
||||||
vis.visit_statement_after_primary_effect(results, state, stmt, loc);
|
vis.visit_after_primary_statement_effect(results, state, stmt, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
let loc = Location { block, statement_index: block_data.statements.len() };
|
let loc = Location { block, statement_index: block_data.statements.len() };
|
||||||
let term = block_data.terminator();
|
let term = block_data.terminator();
|
||||||
results.analysis.apply_before_terminator_effect(state, term, loc);
|
results.analysis.apply_early_terminator_effect(state, term, loc);
|
||||||
vis.visit_terminator_before_primary_effect(results, state, term, loc);
|
vis.visit_after_early_terminator_effect(results, state, term, loc);
|
||||||
results.analysis.apply_terminator_effect(state, term, loc);
|
results.analysis.apply_primary_terminator_effect(state, term, loc);
|
||||||
vis.visit_terminator_after_primary_effect(results, state, term, loc);
|
vis.visit_after_primary_terminator_effect(results, state, term, loc);
|
||||||
|
|
||||||
vis.visit_block_end(state);
|
vis.visit_block_end(state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -557,7 +557,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_statement_before_primary_effect(
|
fn visit_after_early_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
results: &mut Results<'tcx, A>,
|
results: &mut Results<'tcx, A>,
|
||||||
state: &A::Domain,
|
state: &A::Domain,
|
||||||
|
@ -570,7 +570,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_statement_after_primary_effect(
|
fn visit_after_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
results: &mut Results<'tcx, A>,
|
results: &mut Results<'tcx, A>,
|
||||||
state: &A::Domain,
|
state: &A::Domain,
|
||||||
|
@ -581,7 +581,7 @@ where
|
||||||
self.prev_state.clone_from(state)
|
self.prev_state.clone_from(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator_before_primary_effect(
|
fn visit_after_early_terminator_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
results: &mut Results<'tcx, A>,
|
results: &mut Results<'tcx, A>,
|
||||||
state: &A::Domain,
|
state: &A::Domain,
|
||||||
|
@ -594,7 +594,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator_after_primary_effect(
|
fn visit_after_primary_terminator_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
results: &mut Results<'tcx, A>,
|
results: &mut Results<'tcx, A>,
|
||||||
state: &A::Domain,
|
state: &A::Domain,
|
||||||
|
|
|
@ -123,20 +123,21 @@ pub trait Analysis<'tcx> {
|
||||||
fn initialize_start_block(&self, body: &mir::Body<'tcx>, state: &mut Self::Domain);
|
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.
|
/// Updates the current dataflow state with the effect of evaluating a statement.
|
||||||
fn apply_statement_effect(
|
fn apply_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
statement: &mir::Statement<'tcx>,
|
statement: &mir::Statement<'tcx>,
|
||||||
location: Location,
|
location: Location,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Updates the current dataflow state with an effect that occurs immediately *before* the
|
/// Updates the current dataflow state with an "early" effect, i.e. one
|
||||||
/// given statement.
|
/// that occurs immediately before the given statement.
|
||||||
///
|
///
|
||||||
/// This method is useful if the consumer of the results of this analysis only needs to observe
|
/// This method is useful if the consumer of the results of this analysis only needs to observe
|
||||||
/// *part* of the effect of a statement (e.g. for two-phase borrows). As a general rule,
|
/// *part* of the effect of a statement (e.g. for two-phase borrows). As a general rule,
|
||||||
/// analyses should not implement this without also implementing `apply_statement_effect`.
|
/// analyses should not implement this without also implementing
|
||||||
fn apply_before_statement_effect(
|
/// `apply_primary_statement_effect`.
|
||||||
|
fn apply_early_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
_state: &mut Self::Domain,
|
_state: &mut Self::Domain,
|
||||||
_statement: &mir::Statement<'tcx>,
|
_statement: &mir::Statement<'tcx>,
|
||||||
|
@ -150,7 +151,7 @@ pub trait Analysis<'tcx> {
|
||||||
/// in this function. That should go in `apply_call_return_effect`. For example, in the
|
/// 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
|
/// `InitializedPlaces` analyses, the return place for a function call is not marked as
|
||||||
/// initialized here.
|
/// initialized here.
|
||||||
fn apply_terminator_effect<'mir>(
|
fn apply_primary_terminator_effect<'mir>(
|
||||||
&mut self,
|
&mut self,
|
||||||
_state: &mut Self::Domain,
|
_state: &mut Self::Domain,
|
||||||
terminator: &'mir mir::Terminator<'tcx>,
|
terminator: &'mir mir::Terminator<'tcx>,
|
||||||
|
@ -164,8 +165,9 @@ pub trait Analysis<'tcx> {
|
||||||
///
|
///
|
||||||
/// This method is useful if the consumer of the results of this analysis needs only to observe
|
/// This method is useful if the consumer of the results of this analysis needs only to observe
|
||||||
/// *part* of the effect of a terminator (e.g. for two-phase borrows). As a general rule,
|
/// *part* of the effect of a terminator (e.g. for two-phase borrows). As a general rule,
|
||||||
/// analyses should not implement this without also implementing `apply_terminator_effect`.
|
/// analyses should not implement this without also implementing
|
||||||
fn apply_before_terminator_effect(
|
/// `apply_primary_terminator_effect`.
|
||||||
|
fn apply_early_terminator_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
_state: &mut Self::Domain,
|
_state: &mut Self::Domain,
|
||||||
_terminator: &mir::Terminator<'tcx>,
|
_terminator: &mir::Terminator<'tcx>,
|
||||||
|
@ -178,8 +180,8 @@ pub trait Analysis<'tcx> {
|
||||||
/// Updates the current dataflow state with the effect of a successful return from a `Call`
|
/// Updates the current dataflow state with the effect of a successful return from a `Call`
|
||||||
/// terminator.
|
/// terminator.
|
||||||
///
|
///
|
||||||
/// This is separate from `apply_terminator_effect` to properly track state across unwind
|
/// This is separate from `apply_primary_terminator_effect` to properly track state across
|
||||||
/// edges.
|
/// unwind edges.
|
||||||
fn apply_call_return_effect(
|
fn apply_call_return_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
_state: &mut Self::Domain,
|
_state: &mut Self::Domain,
|
||||||
|
@ -359,11 +361,10 @@ impl<T, S: GenKill<T>> GenKill<T> for MaybeReachable<S> {
|
||||||
// NOTE: DO NOT CHANGE VARIANT ORDER. The derived `Ord` impls rely on the current order.
|
// NOTE: DO NOT CHANGE VARIANT ORDER. The derived `Ord` impls rely on the current order.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
enum Effect {
|
enum Effect {
|
||||||
/// The "before" effect (e.g., `apply_before_statement_effect`) for a statement (or
|
/// The "early" effect (e.g., `apply_early_statement_effect`) for a statement/terminator.
|
||||||
/// terminator).
|
Early,
|
||||||
Before,
|
|
||||||
|
|
||||||
/// The "primary" effect (e.g., `apply_statement_effect`) for a statement (or terminator).
|
/// The "primary" effect (e.g., `apply_primary_statement_effect`) for a statement/terminator.
|
||||||
Primary,
|
Primary,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,15 +383,15 @@ pub struct EffectIndex {
|
||||||
impl EffectIndex {
|
impl EffectIndex {
|
||||||
fn next_in_forward_order(self) -> Self {
|
fn next_in_forward_order(self) -> Self {
|
||||||
match self.effect {
|
match self.effect {
|
||||||
Effect::Before => Effect::Primary.at_index(self.statement_index),
|
Effect::Early => Effect::Primary.at_index(self.statement_index),
|
||||||
Effect::Primary => Effect::Before.at_index(self.statement_index + 1),
|
Effect::Primary => Effect::Early.at_index(self.statement_index + 1),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_in_backward_order(self) -> Self {
|
fn next_in_backward_order(self) -> Self {
|
||||||
match self.effect {
|
match self.effect {
|
||||||
Effect::Before => Effect::Primary.at_index(self.statement_index),
|
Effect::Early => Effect::Primary.at_index(self.statement_index),
|
||||||
Effect::Primary => Effect::Before.at_index(self.statement_index - 1),
|
Effect::Primary => Effect::Early.at_index(self.statement_index - 1),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ impl<D: Direction> MockAnalysis<'_, D> {
|
||||||
/// Returns the index that should be added to the dataflow state at the given target.
|
/// Returns the index that should be added to the dataflow state at the given target.
|
||||||
fn effect(&self, loc: EffectIndex) -> usize {
|
fn effect(&self, loc: EffectIndex) -> usize {
|
||||||
let idx = match loc.effect {
|
let idx = match loc.effect {
|
||||||
Effect::Before => loc.statement_index * 2,
|
Effect::Early => loc.statement_index * 2,
|
||||||
Effect::Primary => loc.statement_index * 2 + 1,
|
Effect::Primary => loc.statement_index * 2 + 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -128,14 +128,14 @@ impl<D: Direction> MockAnalysis<'_, D> {
|
||||||
|
|
||||||
let target = match target {
|
let target = match target {
|
||||||
SeekTarget::BlockEntry { .. } => return ret,
|
SeekTarget::BlockEntry { .. } => return ret,
|
||||||
SeekTarget::Before(loc) => Effect::Before.at_index(loc.statement_index),
|
SeekTarget::Early(loc) => Effect::Early.at_index(loc.statement_index),
|
||||||
SeekTarget::After(loc) => Effect::Primary.at_index(loc.statement_index),
|
SeekTarget::After(loc) => Effect::Primary.at_index(loc.statement_index),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut pos = if D::IS_FORWARD {
|
let mut pos = if D::IS_FORWARD {
|
||||||
Effect::Before.at_index(0)
|
Effect::Early.at_index(0)
|
||||||
} else {
|
} else {
|
||||||
Effect::Before.at_index(self.body[block].statements.len())
|
Effect::Early.at_index(self.body[block].statements.len())
|
||||||
};
|
};
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -168,7 +168,7 @@ impl<'tcx, D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
|
||||||
unimplemented!("This is never called since `MockAnalysis` is never iterated to fixpoint");
|
unimplemented!("This is never called since `MockAnalysis` is never iterated to fixpoint");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_statement_effect(
|
fn apply_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
_statement: &mir::Statement<'tcx>,
|
_statement: &mir::Statement<'tcx>,
|
||||||
|
@ -178,17 +178,17 @@ impl<'tcx, D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
|
||||||
assert!(state.insert(idx));
|
assert!(state.insert(idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_before_statement_effect(
|
fn apply_early_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
_statement: &mir::Statement<'tcx>,
|
_statement: &mir::Statement<'tcx>,
|
||||||
location: Location,
|
location: Location,
|
||||||
) {
|
) {
|
||||||
let idx = self.effect(Effect::Before.at_index(location.statement_index));
|
let idx = self.effect(Effect::Early.at_index(location.statement_index));
|
||||||
assert!(state.insert(idx));
|
assert!(state.insert(idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_terminator_effect<'mir>(
|
fn apply_primary_terminator_effect<'mir>(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
terminator: &'mir mir::Terminator<'tcx>,
|
terminator: &'mir mir::Terminator<'tcx>,
|
||||||
|
@ -199,13 +199,13 @@ impl<'tcx, D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
|
||||||
terminator.edges()
|
terminator.edges()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_before_terminator_effect(
|
fn apply_early_terminator_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
_terminator: &mir::Terminator<'tcx>,
|
_terminator: &mir::Terminator<'tcx>,
|
||||||
location: Location,
|
location: Location,
|
||||||
) {
|
) {
|
||||||
let idx = self.effect(Effect::Before.at_index(location.statement_index));
|
let idx = self.effect(Effect::Early.at_index(location.statement_index));
|
||||||
assert!(state.insert(idx));
|
assert!(state.insert(idx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ impl<'tcx, D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
enum SeekTarget {
|
enum SeekTarget {
|
||||||
BlockEntry(BasicBlock),
|
BlockEntry(BasicBlock),
|
||||||
Before(Location),
|
Early(Location),
|
||||||
After(Location),
|
After(Location),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ impl SeekTarget {
|
||||||
|
|
||||||
match *self {
|
match *self {
|
||||||
BlockEntry(block) => block,
|
BlockEntry(block) => block,
|
||||||
Before(loc) | After(loc) => loc.block,
|
Early(loc) | After(loc) => loc.block,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ impl SeekTarget {
|
||||||
.map(move |(i, kind)| {
|
.map(move |(i, kind)| {
|
||||||
let loc = Location { block, statement_index: i };
|
let loc = Location { block, statement_index: i };
|
||||||
match kind {
|
match kind {
|
||||||
0 => SeekTarget::Before(loc),
|
0 => SeekTarget::Early(loc),
|
||||||
1 => SeekTarget::After(loc),
|
1 => SeekTarget::After(loc),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ fn test_cursor<D: Direction>(analysis: MockAnalysis<'_, D>) {
|
||||||
|
|
||||||
match targ {
|
match targ {
|
||||||
BlockEntry(block) => cursor.seek_to_block_entry(block),
|
BlockEntry(block) => cursor.seek_to_block_entry(block),
|
||||||
Before(loc) => cursor.seek_before_primary_effect(loc),
|
Early(loc) => cursor.seek_before_primary_effect(loc),
|
||||||
After(loc) => cursor.seek_after_primary_effect(loc),
|
After(loc) => cursor.seek_after_primary_effect(loc),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,9 +35,9 @@ where
|
||||||
{
|
{
|
||||||
fn visit_block_start(&mut self, _state: &A::Domain) {}
|
fn visit_block_start(&mut self, _state: &A::Domain) {}
|
||||||
|
|
||||||
/// Called with the `before_statement_effect` of the given statement applied to `state` but not
|
/// // njn: grep for "before", "primary", etc.
|
||||||
/// its `statement_effect`.
|
/// Called after the "early" effect of the given statement is applied to `state`.
|
||||||
fn visit_statement_before_primary_effect(
|
fn visit_after_early_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
_results: &mut Results<'tcx, A>,
|
_results: &mut Results<'tcx, A>,
|
||||||
_state: &A::Domain,
|
_state: &A::Domain,
|
||||||
|
@ -46,9 +46,8 @@ where
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called with both the `before_statement_effect` and the `statement_effect` of the given
|
/// Called after the "primary" effect of the given statement is applied to `state`.
|
||||||
/// statement applied to `state`.
|
fn visit_after_primary_statement_effect(
|
||||||
fn visit_statement_after_primary_effect(
|
|
||||||
&mut self,
|
&mut self,
|
||||||
_results: &mut Results<'tcx, A>,
|
_results: &mut Results<'tcx, A>,
|
||||||
_state: &A::Domain,
|
_state: &A::Domain,
|
||||||
|
@ -57,9 +56,8 @@ where
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called with the `before_terminator_effect` of the given terminator applied to `state` but
|
/// Called after the "early" effect of the given terminator is applied to `state`.
|
||||||
/// not its `terminator_effect`.
|
fn visit_after_early_terminator_effect(
|
||||||
fn visit_terminator_before_primary_effect(
|
|
||||||
&mut self,
|
&mut self,
|
||||||
_results: &mut Results<'tcx, A>,
|
_results: &mut Results<'tcx, A>,
|
||||||
_state: &A::Domain,
|
_state: &A::Domain,
|
||||||
|
@ -68,11 +66,10 @@ where
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called with both the `before_terminator_effect` and the `terminator_effect` of the given
|
/// Called after the "primary" effect of the given terminator is applied to `state`.
|
||||||
/// terminator applied to `state`.
|
|
||||||
///
|
///
|
||||||
/// The `call_return_effect` (if one exists) will *not* be applied to `state`.
|
/// The `call_return_effect` (if one exists) will *not* be applied to `state`.
|
||||||
fn visit_terminator_after_primary_effect(
|
fn visit_after_primary_terminator_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
_results: &mut Results<'tcx, A>,
|
_results: &mut Results<'tcx, A>,
|
||||||
_state: &A::Domain,
|
_state: &A::Domain,
|
||||||
|
|
|
@ -33,7 +33,7 @@ impl<'tcx> Analysis<'tcx> for MaybeBorrowedLocals {
|
||||||
// No locals are aliased on function entry
|
// No locals are aliased on function entry
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_statement_effect(
|
fn apply_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
statement: &Statement<'tcx>,
|
statement: &Statement<'tcx>,
|
||||||
|
@ -42,7 +42,7 @@ impl<'tcx> Analysis<'tcx> for MaybeBorrowedLocals {
|
||||||
Self::transfer_function(state).visit_statement(statement, location);
|
Self::transfer_function(state).visit_statement(statement, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_terminator_effect<'mir>(
|
fn apply_primary_terminator_effect<'mir>(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
terminator: &'mir Terminator<'tcx>,
|
terminator: &'mir Terminator<'tcx>,
|
||||||
|
|
|
@ -263,7 +263,7 @@ impl<'tcx> Analysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_statement_effect(
|
fn apply_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
statement: &mir::Statement<'tcx>,
|
statement: &mir::Statement<'tcx>,
|
||||||
|
@ -287,7 +287,7 @@ impl<'tcx> Analysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_terminator_effect<'mir>(
|
fn apply_primary_terminator_effect<'mir>(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
terminator: &'mir mir::Terminator<'tcx>,
|
terminator: &'mir mir::Terminator<'tcx>,
|
||||||
|
@ -394,7 +394,7 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_statement_effect(
|
fn apply_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
_statement: &mir::Statement<'tcx>,
|
_statement: &mir::Statement<'tcx>,
|
||||||
|
@ -408,7 +408,7 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
|
||||||
// mutable borrow occurs. Places cannot become uninitialized through a mutable reference.
|
// mutable borrow occurs. Places cannot become uninitialized through a mutable reference.
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_terminator_effect<'mir>(
|
fn apply_primary_terminator_effect<'mir>(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
terminator: &'mir mir::Terminator<'tcx>,
|
terminator: &'mir mir::Terminator<'tcx>,
|
||||||
|
@ -513,7 +513,7 @@ impl<'tcx> Analysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip(self, state), level = "debug")]
|
#[instrument(skip(self, state), level = "debug")]
|
||||||
fn apply_statement_effect(
|
fn apply_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
stmt: &mir::Statement<'tcx>,
|
stmt: &mir::Statement<'tcx>,
|
||||||
|
@ -541,7 +541,7 @@ impl<'tcx> Analysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip(self, state, terminator), level = "debug")]
|
#[instrument(skip(self, state, terminator), level = "debug")]
|
||||||
fn apply_terminator_effect<'mir>(
|
fn apply_primary_terminator_effect<'mir>(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
terminator: &'mir mir::Terminator<'tcx>,
|
terminator: &'mir mir::Terminator<'tcx>,
|
||||||
|
|
|
@ -40,7 +40,7 @@ impl<'tcx> Analysis<'tcx> for MaybeLiveLocals {
|
||||||
// No variables are live until we observe a use
|
// No variables are live until we observe a use
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_statement_effect(
|
fn apply_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
statement: &mir::Statement<'tcx>,
|
statement: &mir::Statement<'tcx>,
|
||||||
|
@ -49,7 +49,7 @@ impl<'tcx> Analysis<'tcx> for MaybeLiveLocals {
|
||||||
TransferFunction(state).visit_statement(statement, location);
|
TransferFunction(state).visit_statement(statement, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_terminator_effect<'mir>(
|
fn apply_primary_terminator_effect<'mir>(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
terminator: &'mir mir::Terminator<'tcx>,
|
terminator: &'mir mir::Terminator<'tcx>,
|
||||||
|
@ -232,7 +232,7 @@ impl<'a, 'tcx> Analysis<'tcx> for MaybeTransitiveLiveLocals<'a> {
|
||||||
// No variables are live until we observe a use
|
// No variables are live until we observe a use
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_statement_effect(
|
fn apply_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
statement: &mir::Statement<'tcx>,
|
statement: &mir::Statement<'tcx>,
|
||||||
|
@ -268,7 +268,7 @@ impl<'a, 'tcx> Analysis<'tcx> for MaybeTransitiveLiveLocals<'a> {
|
||||||
TransferFunction(state).visit_statement(statement, location);
|
TransferFunction(state).visit_statement(statement, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_terminator_effect<'mir>(
|
fn apply_primary_terminator_effect<'mir>(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
terminator: &'mir mir::Terminator<'tcx>,
|
terminator: &'mir mir::Terminator<'tcx>,
|
||||||
|
|
|
@ -52,7 +52,7 @@ impl<'a, 'tcx> Analysis<'tcx> for MaybeStorageLive<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_statement_effect(
|
fn apply_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
stmt: &Statement<'tcx>,
|
stmt: &Statement<'tcx>,
|
||||||
|
@ -96,7 +96,7 @@ impl<'a, 'tcx> Analysis<'tcx> for MaybeStorageDead<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_statement_effect(
|
fn apply_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
stmt: &Statement<'tcx>,
|
stmt: &Statement<'tcx>,
|
||||||
|
@ -142,7 +142,7 @@ impl<'tcx> Analysis<'tcx> for MaybeRequiresStorage<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_before_statement_effect(
|
fn apply_early_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
stmt: &Statement<'tcx>,
|
stmt: &Statement<'tcx>,
|
||||||
|
@ -176,7 +176,7 @@ impl<'tcx> Analysis<'tcx> for MaybeRequiresStorage<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_statement_effect(
|
fn apply_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
_: &Statement<'tcx>,
|
_: &Statement<'tcx>,
|
||||||
|
@ -187,7 +187,7 @@ impl<'tcx> Analysis<'tcx> for MaybeRequiresStorage<'_, 'tcx> {
|
||||||
self.check_for_move(state, loc);
|
self.check_for_move(state, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_before_terminator_effect(
|
fn apply_early_terminator_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
terminator: &Terminator<'tcx>,
|
terminator: &Terminator<'tcx>,
|
||||||
|
@ -242,7 +242,7 @@ impl<'tcx> Analysis<'tcx> for MaybeRequiresStorage<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_terminator_effect<'t>(
|
fn apply_primary_terminator_effect<'t>(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
terminator: &'t Terminator<'tcx>,
|
terminator: &'t Terminator<'tcx>,
|
||||||
|
|
|
@ -125,7 +125,7 @@ where
|
||||||
A: Analysis<'tcx, Domain = BitSet<N>>,
|
A: Analysis<'tcx, Domain = BitSet<N>>,
|
||||||
N: Idx,
|
N: Idx,
|
||||||
{
|
{
|
||||||
fn visit_statement_after_primary_effect(
|
fn visit_after_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
_results: &mut Results<'tcx, A>,
|
_results: &mut Results<'tcx, A>,
|
||||||
state: &A::Domain,
|
state: &A::Domain,
|
||||||
|
@ -139,7 +139,7 @@ where
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator_after_primary_effect(
|
fn visit_after_primary_terminator_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
_results: &mut Results<'tcx, A>,
|
_results: &mut Results<'tcx, A>,
|
||||||
state: &A::Domain,
|
state: &A::Domain,
|
||||||
|
|
|
@ -878,7 +878,7 @@ struct StorageConflictVisitor<'a, 'tcx> {
|
||||||
impl<'a, 'tcx> ResultsVisitor<'a, 'tcx, MaybeRequiresStorage<'a, 'tcx>>
|
impl<'a, 'tcx> ResultsVisitor<'a, 'tcx, MaybeRequiresStorage<'a, 'tcx>>
|
||||||
for StorageConflictVisitor<'a, 'tcx>
|
for StorageConflictVisitor<'a, 'tcx>
|
||||||
{
|
{
|
||||||
fn visit_statement_before_primary_effect(
|
fn visit_after_early_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
_results: &mut Results<'tcx, MaybeRequiresStorage<'a, 'tcx>>,
|
_results: &mut Results<'tcx, MaybeRequiresStorage<'a, 'tcx>>,
|
||||||
state: &BitSet<Local>,
|
state: &BitSet<Local>,
|
||||||
|
@ -888,7 +888,7 @@ impl<'a, 'tcx> ResultsVisitor<'a, 'tcx, MaybeRequiresStorage<'a, 'tcx>>
|
||||||
self.apply_state(state, loc);
|
self.apply_state(state, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator_before_primary_effect(
|
fn visit_after_early_terminator_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
_results: &mut Results<'tcx, MaybeRequiresStorage<'a, 'tcx>>,
|
_results: &mut Results<'tcx, MaybeRequiresStorage<'a, 'tcx>>,
|
||||||
state: &BitSet<Local>,
|
state: &BitSet<Local>,
|
||||||
|
|
|
@ -106,7 +106,7 @@ impl<'tcx> Analysis<'tcx> for ConstAnalysis<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_statement_effect(
|
fn apply_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
statement: &Statement<'tcx>,
|
statement: &Statement<'tcx>,
|
||||||
|
@ -117,7 +117,7 @@ impl<'tcx> Analysis<'tcx> for ConstAnalysis<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_terminator_effect<'mir>(
|
fn apply_primary_terminator_effect<'mir>(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut Self::Domain,
|
state: &mut Self::Domain,
|
||||||
terminator: &'mir Terminator<'tcx>,
|
terminator: &'mir Terminator<'tcx>,
|
||||||
|
@ -224,7 +224,7 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The effect of a successful function call return should not be
|
/// The effect of a successful function call return should not be
|
||||||
/// applied here, see [`Analysis::apply_terminator_effect`].
|
/// applied here, see [`Analysis::apply_primary_terminator_effect`].
|
||||||
fn handle_terminator<'mir>(
|
fn handle_terminator<'mir>(
|
||||||
&self,
|
&self,
|
||||||
terminator: &'mir Terminator<'tcx>,
|
terminator: &'mir Terminator<'tcx>,
|
||||||
|
@ -949,7 +949,7 @@ fn try_write_constant<'tcx>(
|
||||||
|
|
||||||
impl<'mir, 'tcx> ResultsVisitor<'mir, 'tcx, ConstAnalysis<'_, 'tcx>> for Collector<'_, 'tcx> {
|
impl<'mir, 'tcx> ResultsVisitor<'mir, 'tcx, ConstAnalysis<'_, 'tcx>> for Collector<'_, 'tcx> {
|
||||||
#[instrument(level = "trace", skip(self, results, statement))]
|
#[instrument(level = "trace", skip(self, results, statement))]
|
||||||
fn visit_statement_before_primary_effect(
|
fn visit_after_early_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
results: &mut Results<'tcx, ConstAnalysis<'_, 'tcx>>,
|
results: &mut Results<'tcx, ConstAnalysis<'_, 'tcx>>,
|
||||||
state: &State<FlatSet<Scalar>>,
|
state: &State<FlatSet<Scalar>>,
|
||||||
|
@ -971,7 +971,7 @@ impl<'mir, 'tcx> ResultsVisitor<'mir, 'tcx, ConstAnalysis<'_, 'tcx>> for Collect
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(level = "trace", skip(self, results, statement))]
|
#[instrument(level = "trace", skip(self, results, statement))]
|
||||||
fn visit_statement_after_primary_effect(
|
fn visit_after_primary_statement_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
results: &mut Results<'tcx, ConstAnalysis<'_, 'tcx>>,
|
results: &mut Results<'tcx, ConstAnalysis<'_, 'tcx>>,
|
||||||
state: &State<FlatSet<Scalar>>,
|
state: &State<FlatSet<Scalar>>,
|
||||||
|
@ -996,7 +996,7 @@ impl<'mir, 'tcx> ResultsVisitor<'mir, 'tcx, ConstAnalysis<'_, 'tcx>> for Collect
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator_before_primary_effect(
|
fn visit_after_early_terminator_effect(
|
||||||
&mut self,
|
&mut self,
|
||||||
results: &mut Results<'tcx, ConstAnalysis<'_, 'tcx>>,
|
results: &mut Results<'tcx, ConstAnalysis<'_, 'tcx>>,
|
||||||
state: &State<FlatSet<Scalar>>,
|
state: &State<FlatSet<Scalar>>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue