Skip to content

Commit fed881a

Browse files
Remove in_band_lifetimes from rustc_mir_dataflow
See #91867 for more information.
1 parent 1d01550 commit fed881a

13 files changed

+70
-60
lines changed

compiler/rustc_mir_dataflow/src/framework/direction.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub trait Direction {
1818
/// Applies all effects between the given `EffectIndex`s.
1919
///
2020
/// `effects.start()` must precede or equal `effects.end()` in this direction.
21-
fn apply_effects_in_range<A>(
21+
fn apply_effects_in_range<'tcx, A>(
2222
analysis: &A,
2323
state: &mut A::Domain,
2424
block: BasicBlock,
@@ -27,23 +27,23 @@ pub trait Direction {
2727
) where
2828
A: Analysis<'tcx>;
2929

30-
fn apply_effects_in_block<A>(
30+
fn apply_effects_in_block<'tcx, A>(
3131
analysis: &A,
3232
state: &mut A::Domain,
3333
block: BasicBlock,
3434
block_data: &mir::BasicBlockData<'tcx>,
3535
) where
3636
A: Analysis<'tcx>;
3737

38-
fn gen_kill_effects_in_block<A>(
38+
fn gen_kill_effects_in_block<'tcx, A>(
3939
analysis: &A,
4040
trans: &mut GenKillSet<A::Idx>,
4141
block: BasicBlock,
4242
block_data: &mir::BasicBlockData<'tcx>,
4343
) where
4444
A: GenKillAnalysis<'tcx>;
4545

46-
fn visit_results_in_block<F, R>(
46+
fn visit_results_in_block<'mir, 'tcx, F, R>(
4747
state: &mut F,
4848
block: BasicBlock,
4949
block_data: &'mir mir::BasicBlockData<'tcx>,
@@ -52,7 +52,7 @@ pub trait Direction {
5252
) where
5353
R: ResultsVisitable<'tcx, FlowState = F>;
5454

55-
fn join_state_into_successors_of<A>(
55+
fn join_state_into_successors_of<'tcx, A>(
5656
analysis: &A,
5757
tcx: TyCtxt<'tcx>,
5858
body: &mir::Body<'tcx>,
@@ -72,7 +72,7 @@ impl Direction for Backward {
7272
false
7373
}
7474

75-
fn apply_effects_in_block<A>(
75+
fn apply_effects_in_block<'tcx, A>(
7676
analysis: &A,
7777
state: &mut A::Domain,
7878
block: BasicBlock,
@@ -92,7 +92,7 @@ impl Direction for Backward {
9292
}
9393
}
9494

95-
fn gen_kill_effects_in_block<A>(
95+
fn gen_kill_effects_in_block<'tcx, A>(
9696
analysis: &A,
9797
trans: &mut GenKillSet<A::Idx>,
9898
block: BasicBlock,
@@ -112,7 +112,7 @@ impl Direction for Backward {
112112
}
113113
}
114114

115-
fn apply_effects_in_range<A>(
115+
fn apply_effects_in_range<'tcx, A>(
116116
analysis: &A,
117117
state: &mut A::Domain,
118118
block: BasicBlock,
@@ -189,7 +189,7 @@ impl Direction for Backward {
189189
analysis.apply_statement_effect(state, statement, location);
190190
}
191191

192-
fn visit_results_in_block<F, R>(
192+
fn visit_results_in_block<'mir, 'tcx, F, R>(
193193
state: &mut F,
194194
block: BasicBlock,
195195
block_data: &'mir mir::BasicBlockData<'tcx>,
@@ -221,7 +221,7 @@ impl Direction for Backward {
221221
vis.visit_block_start(state, block_data, block);
222222
}
223223

224-
fn join_state_into_successors_of<A>(
224+
fn join_state_into_successors_of<'tcx, A>(
225225
analysis: &A,
226226
_tcx: TyCtxt<'tcx>,
227227
body: &mir::Body<'tcx>,
@@ -294,7 +294,7 @@ impl Direction for Forward {
294294
true
295295
}
296296

297-
fn apply_effects_in_block<A>(
297+
fn apply_effects_in_block<'tcx, A>(
298298
analysis: &A,
299299
state: &mut A::Domain,
300300
block: BasicBlock,
@@ -314,7 +314,7 @@ impl Direction for Forward {
314314
analysis.apply_terminator_effect(state, terminator, location);
315315
}
316316

317-
fn gen_kill_effects_in_block<A>(
317+
fn gen_kill_effects_in_block<'tcx, A>(
318318
analysis: &A,
319319
trans: &mut GenKillSet<A::Idx>,
320320
block: BasicBlock,
@@ -334,7 +334,7 @@ impl Direction for Forward {
334334
analysis.terminator_effect(trans, terminator, location);
335335
}
336336

337-
fn apply_effects_in_range<A>(
337+
fn apply_effects_in_range<'tcx, A>(
338338
analysis: &A,
339339
state: &mut A::Domain,
340340
block: BasicBlock,
@@ -407,7 +407,7 @@ impl Direction for Forward {
407407
}
408408
}
409409

410-
fn visit_results_in_block<F, R>(
410+
fn visit_results_in_block<'mir, 'tcx, F, R>(
411411
state: &mut F,
412412
block: BasicBlock,
413413
block_data: &'mir mir::BasicBlockData<'tcx>,
@@ -438,7 +438,7 @@ impl Direction for Forward {
438438
vis.visit_block_end(state, block_data, block);
439439
}
440440

441-
fn join_state_into_successors_of<A>(
441+
fn join_state_into_successors_of<'tcx, A>(
442442
analysis: &A,
443443
_tcx: TyCtxt<'tcx>,
444444
_body: &mir::Body<'tcx>,
@@ -591,7 +591,7 @@ where
591591
//
592592
// FIXME: Figure out how to express this using `Option::clone_from`, or maybe lift it into the
593593
// standard library?
594-
fn opt_clone_from_or_clone<T: Clone>(opt: &'a mut Option<T>, val: &T) -> &'a mut T {
594+
fn opt_clone_from_or_clone<'a, T: Clone>(opt: &'a mut Option<T>, val: &T) -> &'a mut T {
595595
if opt.is_some() {
596596
let ret = opt.as_mut().unwrap();
597597
ret.clone_from(val);

compiler/rustc_mir_dataflow/src/framework/engine.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ where
3131
pub(super) entry_sets: IndexVec<BasicBlock, A::Domain>,
3232
}
3333

34-
impl<A> Results<'tcx, A>
34+
impl<'tcx, A> Results<'tcx, A>
3535
where
3636
A: Analysis<'tcx>,
3737
{
3838
/// Creates a `ResultsCursor` that can inspect these `Results`.
39-
pub fn into_results_cursor(self, body: &'mir mir::Body<'tcx>) -> ResultsCursor<'mir, 'tcx, A> {
39+
pub fn into_results_cursor<'mir>(
40+
self,
41+
body: &'mir mir::Body<'tcx>,
42+
) -> ResultsCursor<'mir, 'tcx, A> {
4043
ResultsCursor::new(body, self)
4144
}
4245

@@ -45,7 +48,7 @@ where
4548
&self.entry_sets[block]
4649
}
4750

48-
pub fn visit_with(
51+
pub fn visit_with<'mir>(
4952
&self,
5053
body: &'mir mir::Body<'tcx>,
5154
blocks: impl IntoIterator<Item = BasicBlock>,
@@ -54,7 +57,7 @@ where
5457
visit_results(body, blocks, self, vis)
5558
}
5659

57-
pub fn visit_reachable_with(
60+
pub fn visit_reachable_with<'mir>(
5861
&self,
5962
body: &'mir mir::Body<'tcx>,
6063
vis: &mut impl ResultsVisitor<'mir, 'tcx, FlowState = A::Domain>,
@@ -85,7 +88,7 @@ where
8588
apply_trans_for_block: Option<Box<dyn Fn(BasicBlock, &mut A::Domain)>>,
8689
}
8790

88-
impl<A, D, T> Engine<'a, 'tcx, A>
91+
impl<'a, 'tcx, A, D, T> Engine<'a, 'tcx, A>
8992
where
9093
A: GenKillAnalysis<'tcx, Idx = T, Domain = D>,
9194
D: Clone + JoinSemiLattice + GenKill<T> + BorrowMut<BitSet<T>>,
@@ -119,7 +122,7 @@ where
119122
}
120123
}
121124

122-
impl<A, D> Engine<'a, 'tcx, A>
125+
impl<'a, 'tcx, A, D> Engine<'a, 'tcx, A>
123126
where
124127
A: Analysis<'tcx, Domain = D>,
125128
D: Clone + JoinSemiLattice,
@@ -257,7 +260,7 @@ where
257260

258261
/// Writes a DOT file containing the results of a dataflow analysis if the user requested it via
259262
/// `rustc_mir` attributes.
260-
fn write_graphviz_results<A>(
263+
fn write_graphviz_results<'tcx, A>(
261264
tcx: TyCtxt<'tcx>,
262265
body: &mir::Body<'tcx>,
263266
results: &Results<'tcx, A>,
@@ -330,7 +333,7 @@ struct RustcMirAttrs {
330333
}
331334

332335
impl RustcMirAttrs {
333-
fn parse(tcx: TyCtxt<'tcx>, def_id: DefId) -> Result<Self, ()> {
336+
fn parse(tcx: TyCtxt<'_>, def_id: DefId) -> Result<Self, ()> {
334337
let attrs = tcx.get_attrs(def_id);
335338

336339
let mut result = Ok(());
@@ -373,7 +376,7 @@ impl RustcMirAttrs {
373376

374377
fn set_field<T>(
375378
field: &mut Option<T>,
376-
tcx: TyCtxt<'tcx>,
379+
tcx: TyCtxt<'_>,
377380
attr: &ast::NestedMetaItem,
378381
mapper: impl FnOnce(Symbol) -> Result<T, ()>,
379382
) -> Result<(), ()> {

compiler/rustc_mir_dataflow/src/framework/graphviz.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ where
3636
style: OutputStyle,
3737
}
3838

39-
impl<A> Formatter<'a, 'tcx, A>
39+
impl<'a, 'tcx, A> Formatter<'a, 'tcx, A>
4040
where
4141
A: Analysis<'tcx>,
4242
{
@@ -52,7 +52,7 @@ pub struct CfgEdge {
5252
index: usize,
5353
}
5454

55-
fn dataflow_successors(body: &Body<'tcx>, bb: BasicBlock) -> Vec<CfgEdge> {
55+
fn dataflow_successors(body: &Body<'_>, bb: BasicBlock) -> Vec<CfgEdge> {
5656
body[bb]
5757
.terminator()
5858
.successors()
@@ -61,7 +61,7 @@ fn dataflow_successors(body: &Body<'tcx>, bb: BasicBlock) -> Vec<CfgEdge> {
6161
.collect()
6262
}
6363

64-
impl<A> dot::Labeller<'_> for Formatter<'a, 'tcx, A>
64+
impl<'tcx, A> dot::Labeller<'_> for Formatter<'_, 'tcx, A>
6565
where
6666
A: Analysis<'tcx>,
6767
A::Domain: DebugWithContext<A>,
@@ -100,7 +100,7 @@ where
100100
}
101101
}
102102

103-
impl<A> dot::GraphWalk<'a> for Formatter<'a, 'tcx, A>
103+
impl<'a, 'tcx, A> dot::GraphWalk<'a> for Formatter<'a, 'tcx, A>
104104
where
105105
A: Analysis<'tcx>,
106106
{
@@ -138,7 +138,7 @@ where
138138
style: OutputStyle,
139139
}
140140

141-
impl<A> BlockFormatter<'a, 'tcx, A>
141+
impl<'a, 'tcx, A> BlockFormatter<'a, 'tcx, A>
142142
where
143143
A: Analysis<'tcx>,
144144
A::Domain: DebugWithContext<A>,
@@ -491,7 +491,7 @@ where
491491
after: Vec<String>,
492492
}
493493

494-
impl<A> StateDiffCollector<'a, 'tcx, A>
494+
impl<'a, 'tcx, A> StateDiffCollector<'a, 'tcx, A>
495495
where
496496
A: Analysis<'tcx>,
497497
A::Domain: DebugWithContext<A>,
@@ -514,7 +514,7 @@ where
514514
}
515515
}
516516

517-
impl<A> ResultsVisitor<'a, 'tcx> for StateDiffCollector<'a, 'tcx, A>
517+
impl<'a, 'tcx, A> ResultsVisitor<'a, 'tcx> for StateDiffCollector<'a, 'tcx, A>
518518
where
519519
A: Analysis<'tcx>,
520520
A::Domain: DebugWithContext<A>,
@@ -524,7 +524,7 @@ where
524524
fn visit_block_start(
525525
&mut self,
526526
state: &Self::FlowState,
527-
_block_data: &'mir mir::BasicBlockData<'tcx>,
527+
_block_data: &mir::BasicBlockData<'tcx>,
528528
_block: BasicBlock,
529529
) {
530530
if A::Direction::is_forward() {
@@ -535,7 +535,7 @@ where
535535
fn visit_block_end(
536536
&mut self,
537537
state: &Self::FlowState,
538-
_block_data: &'mir mir::BasicBlockData<'tcx>,
538+
_block_data: &mir::BasicBlockData<'tcx>,
539539
_block: BasicBlock,
540540
) {
541541
if A::Direction::is_backward() {
@@ -546,7 +546,7 @@ where
546546
fn visit_statement_before_primary_effect(
547547
&mut self,
548548
state: &Self::FlowState,
549-
_statement: &'mir mir::Statement<'tcx>,
549+
_statement: &mir::Statement<'tcx>,
550550
_location: Location,
551551
) {
552552
if let Some(before) = self.before.as_mut() {
@@ -558,7 +558,7 @@ where
558558
fn visit_statement_after_primary_effect(
559559
&mut self,
560560
state: &Self::FlowState,
561-
_statement: &'mir mir::Statement<'tcx>,
561+
_statement: &mir::Statement<'tcx>,
562562
_location: Location,
563563
) {
564564
self.after.push(diff_pretty(state, &self.prev_state, self.analysis));
@@ -568,7 +568,7 @@ where
568568
fn visit_terminator_before_primary_effect(
569569
&mut self,
570570
state: &Self::FlowState,
571-
_terminator: &'mir mir::Terminator<'tcx>,
571+
_terminator: &mir::Terminator<'tcx>,
572572
_location: Location,
573573
) {
574574
if let Some(before) = self.before.as_mut() {
@@ -580,7 +580,7 @@ where
580580
fn visit_terminator_after_primary_effect(
581581
&mut self,
582582
state: &Self::FlowState,
583-
_terminator: &'mir mir::Terminator<'tcx>,
583+
_terminator: &mir::Terminator<'tcx>,
584584
_location: Location,
585585
) {
586586
self.after.push(diff_pretty(state, &self.prev_state, self.analysis));

compiler/rustc_mir_dataflow/src/framework/mod.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ pub trait Analysis<'tcx>: AnalysisDomain<'tcx> {
214214
/// .iterate_to_fixpoint()
215215
/// .into_results_cursor(body);
216216
/// ```
217-
fn into_engine(self, tcx: TyCtxt<'tcx>, body: &'mir mir::Body<'tcx>) -> Engine<'mir, 'tcx, Self>
217+
fn into_engine<'mir>(
218+
self,
219+
tcx: TyCtxt<'tcx>,
220+
body: &'mir mir::Body<'tcx>,
221+
) -> Engine<'mir, 'tcx, Self>
218222
where
219223
Self: Sized,
220224
{
@@ -296,7 +300,7 @@ pub trait GenKillAnalysis<'tcx>: Analysis<'tcx> {
296300
}
297301
}
298302

299-
impl<A> Analysis<'tcx> for A
303+
impl<'tcx, A> Analysis<'tcx> for A
300304
where
301305
A: GenKillAnalysis<'tcx>,
302306
A::Domain: GenKill<A::Idx> + BorrowMut<BitSet<A::Idx>>,
@@ -368,7 +372,11 @@ where
368372

369373
/* Extension methods */
370374

371-
fn into_engine(self, tcx: TyCtxt<'tcx>, body: &'mir mir::Body<'tcx>) -> Engine<'mir, 'tcx, Self>
375+
fn into_engine<'mir>(
376+
self,
377+
tcx: TyCtxt<'tcx>,
378+
body: &'mir mir::Body<'tcx>,
379+
) -> Engine<'mir, 'tcx, Self>
372380
where
373381
Self: Sized,
374382
{

0 commit comments

Comments
 (0)