Remove `in_band_lifetimes` from `rustc_mir_dataflow`

See #91867 for more information.
This commit is contained in:
LegionMammal978 2021-12-14 12:02:45 -05:00 committed by Matthew House
parent 1d01550f7e
commit fed881aafc
13 changed files with 70 additions and 60 deletions

View File

@ -18,7 +18,7 @@ pub trait Direction {
/// Applies all effects between the given `EffectIndex`s.
///
/// `effects.start()` must precede or equal `effects.end()` in this direction.
fn apply_effects_in_range<A>(
fn apply_effects_in_range<'tcx, A>(
analysis: &A,
state: &mut A::Domain,
block: BasicBlock,
@ -27,7 +27,7 @@ pub trait Direction {
) where
A: Analysis<'tcx>;
fn apply_effects_in_block<A>(
fn apply_effects_in_block<'tcx, A>(
analysis: &A,
state: &mut A::Domain,
block: BasicBlock,
@ -35,7 +35,7 @@ pub trait Direction {
) where
A: Analysis<'tcx>;
fn gen_kill_effects_in_block<A>(
fn gen_kill_effects_in_block<'tcx, A>(
analysis: &A,
trans: &mut GenKillSet<A::Idx>,
block: BasicBlock,
@ -43,7 +43,7 @@ pub trait Direction {
) where
A: GenKillAnalysis<'tcx>;
fn visit_results_in_block<F, R>(
fn visit_results_in_block<'mir, 'tcx, F, R>(
state: &mut F,
block: BasicBlock,
block_data: &'mir mir::BasicBlockData<'tcx>,
@ -52,7 +52,7 @@ pub trait Direction {
) where
R: ResultsVisitable<'tcx, FlowState = F>;
fn join_state_into_successors_of<A>(
fn join_state_into_successors_of<'tcx, A>(
analysis: &A,
tcx: TyCtxt<'tcx>,
body: &mir::Body<'tcx>,
@ -72,7 +72,7 @@ impl Direction for Backward {
false
}
fn apply_effects_in_block<A>(
fn apply_effects_in_block<'tcx, A>(
analysis: &A,
state: &mut A::Domain,
block: BasicBlock,
@ -92,7 +92,7 @@ impl Direction for Backward {
}
}
fn gen_kill_effects_in_block<A>(
fn gen_kill_effects_in_block<'tcx, A>(
analysis: &A,
trans: &mut GenKillSet<A::Idx>,
block: BasicBlock,
@ -112,7 +112,7 @@ impl Direction for Backward {
}
}
fn apply_effects_in_range<A>(
fn apply_effects_in_range<'tcx, A>(
analysis: &A,
state: &mut A::Domain,
block: BasicBlock,
@ -189,7 +189,7 @@ impl Direction for Backward {
analysis.apply_statement_effect(state, statement, location);
}
fn visit_results_in_block<F, R>(
fn visit_results_in_block<'mir, 'tcx, F, R>(
state: &mut F,
block: BasicBlock,
block_data: &'mir mir::BasicBlockData<'tcx>,
@ -221,7 +221,7 @@ impl Direction for Backward {
vis.visit_block_start(state, block_data, block);
}
fn join_state_into_successors_of<A>(
fn join_state_into_successors_of<'tcx, A>(
analysis: &A,
_tcx: TyCtxt<'tcx>,
body: &mir::Body<'tcx>,
@ -294,7 +294,7 @@ impl Direction for Forward {
true
}
fn apply_effects_in_block<A>(
fn apply_effects_in_block<'tcx, A>(
analysis: &A,
state: &mut A::Domain,
block: BasicBlock,
@ -314,7 +314,7 @@ impl Direction for Forward {
analysis.apply_terminator_effect(state, terminator, location);
}
fn gen_kill_effects_in_block<A>(
fn gen_kill_effects_in_block<'tcx, A>(
analysis: &A,
trans: &mut GenKillSet<A::Idx>,
block: BasicBlock,
@ -334,7 +334,7 @@ impl Direction for Forward {
analysis.terminator_effect(trans, terminator, location);
}
fn apply_effects_in_range<A>(
fn apply_effects_in_range<'tcx, A>(
analysis: &A,
state: &mut A::Domain,
block: BasicBlock,
@ -407,7 +407,7 @@ impl Direction for Forward {
}
}
fn visit_results_in_block<F, R>(
fn visit_results_in_block<'mir, 'tcx, F, R>(
state: &mut F,
block: BasicBlock,
block_data: &'mir mir::BasicBlockData<'tcx>,
@ -438,7 +438,7 @@ impl Direction for Forward {
vis.visit_block_end(state, block_data, block);
}
fn join_state_into_successors_of<A>(
fn join_state_into_successors_of<'tcx, A>(
analysis: &A,
_tcx: TyCtxt<'tcx>,
_body: &mir::Body<'tcx>,
@ -591,7 +591,7 @@ where
//
// FIXME: Figure out how to express this using `Option::clone_from`, or maybe lift it into the
// standard library?
fn opt_clone_from_or_clone<T: Clone>(opt: &'a mut Option<T>, val: &T) -> &'a mut T {
fn opt_clone_from_or_clone<'a, T: Clone>(opt: &'a mut Option<T>, val: &T) -> &'a mut T {
if opt.is_some() {
let ret = opt.as_mut().unwrap();
ret.clone_from(val);

View File

@ -31,12 +31,15 @@ where
pub(super) entry_sets: IndexVec<BasicBlock, A::Domain>,
}
impl<A> Results<'tcx, A>
impl<'tcx, A> Results<'tcx, A>
where
A: Analysis<'tcx>,
{
/// Creates a `ResultsCursor` that can inspect these `Results`.
pub fn into_results_cursor(self, body: &'mir mir::Body<'tcx>) -> ResultsCursor<'mir, 'tcx, A> {
pub fn into_results_cursor<'mir>(
self,
body: &'mir mir::Body<'tcx>,
) -> ResultsCursor<'mir, 'tcx, A> {
ResultsCursor::new(body, self)
}
@ -45,7 +48,7 @@ where
&self.entry_sets[block]
}
pub fn visit_with(
pub fn visit_with<'mir>(
&self,
body: &'mir mir::Body<'tcx>,
blocks: impl IntoIterator<Item = BasicBlock>,
@ -54,7 +57,7 @@ where
visit_results(body, blocks, self, vis)
}
pub fn visit_reachable_with(
pub fn visit_reachable_with<'mir>(
&self,
body: &'mir mir::Body<'tcx>,
vis: &mut impl ResultsVisitor<'mir, 'tcx, FlowState = A::Domain>,
@ -85,7 +88,7 @@ where
apply_trans_for_block: Option<Box<dyn Fn(BasicBlock, &mut A::Domain)>>,
}
impl<A, D, T> Engine<'a, 'tcx, A>
impl<'a, 'tcx, A, D, T> Engine<'a, 'tcx, A>
where
A: GenKillAnalysis<'tcx, Idx = T, Domain = D>,
D: Clone + JoinSemiLattice + GenKill<T> + BorrowMut<BitSet<T>>,
@ -119,7 +122,7 @@ where
}
}
impl<A, D> Engine<'a, 'tcx, A>
impl<'a, 'tcx, A, D> Engine<'a, 'tcx, A>
where
A: Analysis<'tcx, Domain = D>,
D: Clone + JoinSemiLattice,
@ -257,7 +260,7 @@ where
/// Writes a DOT file containing the results of a dataflow analysis if the user requested it via
/// `rustc_mir` attributes.
fn write_graphviz_results<A>(
fn write_graphviz_results<'tcx, A>(
tcx: TyCtxt<'tcx>,
body: &mir::Body<'tcx>,
results: &Results<'tcx, A>,
@ -330,7 +333,7 @@ struct RustcMirAttrs {
}
impl RustcMirAttrs {
fn parse(tcx: TyCtxt<'tcx>, def_id: DefId) -> Result<Self, ()> {
fn parse(tcx: TyCtxt<'_>, def_id: DefId) -> Result<Self, ()> {
let attrs = tcx.get_attrs(def_id);
let mut result = Ok(());
@ -373,7 +376,7 @@ impl RustcMirAttrs {
fn set_field<T>(
field: &mut Option<T>,
tcx: TyCtxt<'tcx>,
tcx: TyCtxt<'_>,
attr: &ast::NestedMetaItem,
mapper: impl FnOnce(Symbol) -> Result<T, ()>,
) -> Result<(), ()> {

View File

@ -36,7 +36,7 @@ where
style: OutputStyle,
}
impl<A> Formatter<'a, 'tcx, A>
impl<'a, 'tcx, A> Formatter<'a, 'tcx, A>
where
A: Analysis<'tcx>,
{
@ -52,7 +52,7 @@ pub struct CfgEdge {
index: usize,
}
fn dataflow_successors(body: &Body<'tcx>, bb: BasicBlock) -> Vec<CfgEdge> {
fn dataflow_successors(body: &Body<'_>, bb: BasicBlock) -> Vec<CfgEdge> {
body[bb]
.terminator()
.successors()
@ -61,7 +61,7 @@ fn dataflow_successors(body: &Body<'tcx>, bb: BasicBlock) -> Vec<CfgEdge> {
.collect()
}
impl<A> dot::Labeller<'_> for Formatter<'a, 'tcx, A>
impl<'tcx, A> dot::Labeller<'_> for Formatter<'_, 'tcx, A>
where
A: Analysis<'tcx>,
A::Domain: DebugWithContext<A>,
@ -100,7 +100,7 @@ where
}
}
impl<A> dot::GraphWalk<'a> for Formatter<'a, 'tcx, A>
impl<'a, 'tcx, A> dot::GraphWalk<'a> for Formatter<'a, 'tcx, A>
where
A: Analysis<'tcx>,
{
@ -138,7 +138,7 @@ where
style: OutputStyle,
}
impl<A> BlockFormatter<'a, 'tcx, A>
impl<'a, 'tcx, A> BlockFormatter<'a, 'tcx, A>
where
A: Analysis<'tcx>,
A::Domain: DebugWithContext<A>,
@ -491,7 +491,7 @@ where
after: Vec<String>,
}
impl<A> StateDiffCollector<'a, 'tcx, A>
impl<'a, 'tcx, A> StateDiffCollector<'a, 'tcx, A>
where
A: Analysis<'tcx>,
A::Domain: DebugWithContext<A>,
@ -514,7 +514,7 @@ where
}
}
impl<A> ResultsVisitor<'a, 'tcx> for StateDiffCollector<'a, 'tcx, A>
impl<'a, 'tcx, A> ResultsVisitor<'a, 'tcx> for StateDiffCollector<'a, 'tcx, A>
where
A: Analysis<'tcx>,
A::Domain: DebugWithContext<A>,
@ -524,7 +524,7 @@ where
fn visit_block_start(
&mut self,
state: &Self::FlowState,
_block_data: &'mir mir::BasicBlockData<'tcx>,
_block_data: &mir::BasicBlockData<'tcx>,
_block: BasicBlock,
) {
if A::Direction::is_forward() {
@ -535,7 +535,7 @@ where
fn visit_block_end(
&mut self,
state: &Self::FlowState,
_block_data: &'mir mir::BasicBlockData<'tcx>,
_block_data: &mir::BasicBlockData<'tcx>,
_block: BasicBlock,
) {
if A::Direction::is_backward() {
@ -546,7 +546,7 @@ where
fn visit_statement_before_primary_effect(
&mut self,
state: &Self::FlowState,
_statement: &'mir mir::Statement<'tcx>,
_statement: &mir::Statement<'tcx>,
_location: Location,
) {
if let Some(before) = self.before.as_mut() {
@ -558,7 +558,7 @@ where
fn visit_statement_after_primary_effect(
&mut self,
state: &Self::FlowState,
_statement: &'mir mir::Statement<'tcx>,
_statement: &mir::Statement<'tcx>,
_location: Location,
) {
self.after.push(diff_pretty(state, &self.prev_state, self.analysis));
@ -568,7 +568,7 @@ where
fn visit_terminator_before_primary_effect(
&mut self,
state: &Self::FlowState,
_terminator: &'mir mir::Terminator<'tcx>,
_terminator: &mir::Terminator<'tcx>,
_location: Location,
) {
if let Some(before) = self.before.as_mut() {
@ -580,7 +580,7 @@ where
fn visit_terminator_after_primary_effect(
&mut self,
state: &Self::FlowState,
_terminator: &'mir mir::Terminator<'tcx>,
_terminator: &mir::Terminator<'tcx>,
_location: Location,
) {
self.after.push(diff_pretty(state, &self.prev_state, self.analysis));

View File

@ -214,7 +214,11 @@ pub trait Analysis<'tcx>: AnalysisDomain<'tcx> {
/// .iterate_to_fixpoint()
/// .into_results_cursor(body);
/// ```
fn into_engine(self, tcx: TyCtxt<'tcx>, body: &'mir mir::Body<'tcx>) -> Engine<'mir, 'tcx, Self>
fn into_engine<'mir>(
self,
tcx: TyCtxt<'tcx>,
body: &'mir mir::Body<'tcx>,
) -> Engine<'mir, 'tcx, Self>
where
Self: Sized,
{
@ -296,7 +300,7 @@ pub trait GenKillAnalysis<'tcx>: Analysis<'tcx> {
}
}
impl<A> Analysis<'tcx> for A
impl<'tcx, A> Analysis<'tcx> for A
where
A: GenKillAnalysis<'tcx>,
A::Domain: GenKill<A::Idx> + BorrowMut<BitSet<A::Idx>>,
@ -368,7 +372,11 @@ where
/* Extension methods */
fn into_engine(self, tcx: TyCtxt<'tcx>, body: &'mir mir::Body<'tcx>) -> Engine<'mir, 'tcx, Self>
fn into_engine<'mir>(
self,
tcx: TyCtxt<'tcx>,
body: &'mir mir::Body<'tcx>,
) -> Engine<'mir, 'tcx, Self>
where
Self: Sized,
{

View File

@ -85,7 +85,7 @@ struct MockAnalysis<'tcx, D> {
dir: PhantomData<D>,
}
impl<D: Direction> MockAnalysis<'tcx, D> {
impl<D: Direction> MockAnalysis<'_, D> {
const BASIC_BLOCK_OFFSET: usize = 100;
/// The entry set for each `BasicBlock` is the ID of that block offset by a fixed amount to
@ -160,7 +160,7 @@ impl<D: Direction> MockAnalysis<'tcx, D> {
}
}
impl<D: Direction> AnalysisDomain<'tcx> for MockAnalysis<'tcx, D> {
impl<'tcx, D: Direction> AnalysisDomain<'tcx> for MockAnalysis<'tcx, D> {
type Domain = BitSet<usize>;
type Direction = D;
@ -175,7 +175,7 @@ impl<D: Direction> AnalysisDomain<'tcx> for MockAnalysis<'tcx, D> {
}
}
impl<D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
impl<'tcx, D: Direction> Analysis<'tcx> for MockAnalysis<'tcx, D> {
fn apply_statement_effect(
&self,
state: &mut Self::Domain,
@ -260,7 +260,7 @@ impl SeekTarget {
}
}
fn test_cursor<D: Direction>(analysis: MockAnalysis<'tcx, D>) {
fn test_cursor<D: Direction>(analysis: MockAnalysis<'_, D>) {
let body = analysis.body;
let mut cursor =

View File

@ -4,7 +4,7 @@ use super::{Analysis, Direction, Results};
/// Calls the corresponding method in `ResultsVisitor` for every location in a `mir::Body` with the
/// dataflow state at that location.
pub fn visit_results<F, V>(
pub fn visit_results<'mir, 'tcx, F, V>(
body: &'mir mir::Body<'tcx>,
blocks: impl IntoIterator<Item = BasicBlock>,
results: &V,

View File

@ -45,7 +45,7 @@ impl MaybeBorrowedLocals {
}
}
impl AnalysisDomain<'tcx> for MaybeBorrowedLocals {
impl<'tcx> AnalysisDomain<'tcx> for MaybeBorrowedLocals {
type Domain = BitSet<Local>;
const NAME: &'static str = "maybe_borrowed_locals";
@ -59,7 +59,7 @@ impl AnalysisDomain<'tcx> for MaybeBorrowedLocals {
}
}
impl GenKillAnalysis<'tcx> for MaybeBorrowedLocals {
impl<'tcx> GenKillAnalysis<'tcx> for MaybeBorrowedLocals {
type Idx = Local;
fn statement_effect(
@ -95,7 +95,7 @@ struct TransferFunction<'a, T> {
ignore_borrow_on_drop: bool,
}
impl<T> Visitor<'tcx> for TransferFunction<'a, T>
impl<'tcx, T> Visitor<'tcx> for TransferFunction<'_, T>
where
T: GenKill<Local>,
{

View File

@ -10,7 +10,7 @@ use rustc_middle::mir::{self, BasicBlock, Local, Location};
pub struct MaybeInitializedLocals;
impl crate::AnalysisDomain<'tcx> for MaybeInitializedLocals {
impl<'tcx> crate::AnalysisDomain<'tcx> for MaybeInitializedLocals {
type Domain = BitSet<Local>;
const NAME: &'static str = "maybe_init_locals";
@ -28,7 +28,7 @@ impl crate::AnalysisDomain<'tcx> for MaybeInitializedLocals {
}
}
impl crate::GenKillAnalysis<'tcx> for MaybeInitializedLocals {
impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeInitializedLocals {
type Idx = Local;
fn statement_effect(
@ -73,7 +73,7 @@ struct TransferFunction<'a, T> {
trans: &'a mut T,
}
impl<T> Visitor<'tcx> for TransferFunction<'a, T>
impl<T> Visitor<'_> for TransferFunction<'_, T>
where
T: GenKill<Local>,
{

View File

@ -48,12 +48,12 @@ use crate::{AnalysisDomain, Backward, CallReturnPlaces, GenKill, GenKillAnalysis
pub struct MaybeLiveLocals;
impl MaybeLiveLocals {
fn transfer_function<T>(&self, trans: &'a mut T) -> TransferFunction<'a, T> {
fn transfer_function<'a, T>(&self, trans: &'a mut T) -> TransferFunction<'a, T> {
TransferFunction(trans)
}
}
impl AnalysisDomain<'tcx> for MaybeLiveLocals {
impl<'tcx> AnalysisDomain<'tcx> for MaybeLiveLocals {
type Domain = BitSet<Local>;
type Direction = Backward;
@ -69,7 +69,7 @@ impl AnalysisDomain<'tcx> for MaybeLiveLocals {
}
}
impl GenKillAnalysis<'tcx> for MaybeLiveLocals {
impl<'tcx> GenKillAnalysis<'tcx> for MaybeLiveLocals {
type Idx = Local;
fn statement_effect(

View File

@ -704,7 +704,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for EverInitializedPlaces<'_, 'tcx> {
///
/// If the basic block matches this pattern, this function returns the place corresponding to the
/// enum (`_1` in the example above) as well as the `AdtDef` of that enum.
fn switch_on_enum_discriminant(
fn switch_on_enum_discriminant<'mir, 'tcx>(
tcx: TyCtxt<'tcx>,
body: &'mir mir::Body<'tcx>,
block: &'mir mir::BasicBlockData<'tcx>,

View File

@ -17,7 +17,7 @@ impl MaybeStorageLive {
}
}
impl crate::AnalysisDomain<'tcx> for MaybeStorageLive {
impl<'tcx> crate::AnalysisDomain<'tcx> for MaybeStorageLive {
type Domain = BitSet<Local>;
const NAME: &'static str = "maybe_storage_live";
@ -39,7 +39,7 @@ impl crate::AnalysisDomain<'tcx> for MaybeStorageLive {
}
}
impl crate::GenKillAnalysis<'tcx> for MaybeStorageLive {
impl<'tcx> crate::GenKillAnalysis<'tcx> for MaybeStorageLive {
type Idx = Local;
fn statement_effect(

View File

@ -3,7 +3,6 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(exact_size_is_empty)]
#![feature(in_band_lifetimes)]
#![feature(let_else)]
#![feature(min_specialization)]
#![feature(once_cell)]

View File

@ -11,7 +11,7 @@ use rustc_middle::mir::{self, Local};
pub struct AlwaysLiveLocals(BitSet<Local>);
impl AlwaysLiveLocals {
pub fn new(body: &mir::Body<'tcx>) -> Self {
pub fn new(body: &mir::Body<'_>) -> Self {
let mut always_live_locals = AlwaysLiveLocals(BitSet::new_filled(body.local_decls.len()));
for block in body.basic_blocks() {