Skip to content

Commit f450bf4

Browse files
committed
Use 'mir lifetime name more.
Some types have a `body: &'mir Body<'tcx>` and some have `body: &'a Body<'tcx>`. The former is more readable, so this commit converts some fo the latter to the former.
1 parent a65e68a commit f450bf4

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

compiler/rustc_borrowck/src/dataflow.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -120,24 +120,24 @@ rustc_index::newtype_index! {
120120
/// `BorrowIndex`, and maps each such index to a `BorrowData`
121121
/// describing the borrow. These indexes are used for representing the
122122
/// borrows in compact bitvectors.
123-
pub struct Borrows<'a, 'tcx> {
123+
pub struct Borrows<'mir, 'tcx> {
124124
tcx: TyCtxt<'tcx>,
125-
body: &'a Body<'tcx>,
125+
body: &'mir Body<'tcx>,
126126

127-
borrow_set: &'a BorrowSet<'tcx>,
127+
borrow_set: &'mir BorrowSet<'tcx>,
128128
borrows_out_of_scope_at_location: FxIndexMap<Location, Vec<BorrowIndex>>,
129129
}
130130

131-
struct OutOfScopePrecomputer<'a, 'tcx> {
131+
struct OutOfScopePrecomputer<'mir, 'tcx> {
132132
visited: BitSet<mir::BasicBlock>,
133133
visit_stack: Vec<mir::BasicBlock>,
134-
body: &'a Body<'tcx>,
135-
regioncx: &'a RegionInferenceContext<'tcx>,
134+
body: &'mir Body<'tcx>,
135+
regioncx: &'mir RegionInferenceContext<'tcx>,
136136
borrows_out_of_scope_at_location: FxIndexMap<Location, Vec<BorrowIndex>>,
137137
}
138138

139-
impl<'a, 'tcx> OutOfScopePrecomputer<'a, 'tcx> {
140-
fn new(body: &'a Body<'tcx>, regioncx: &'a RegionInferenceContext<'tcx>) -> Self {
139+
impl<'mir, 'tcx> OutOfScopePrecomputer<'mir, 'tcx> {
140+
fn new(body: &'mir Body<'tcx>, regioncx: &'mir RegionInferenceContext<'tcx>) -> Self {
141141
OutOfScopePrecomputer {
142142
visited: BitSet::new_empty(body.basic_blocks.len()),
143143
visit_stack: vec![],
@@ -240,17 +240,17 @@ pub fn calculate_borrows_out_of_scope_at_location<'tcx>(
240240
prec.borrows_out_of_scope_at_location
241241
}
242242

243-
struct PoloniusOutOfScopePrecomputer<'a, 'tcx> {
243+
struct PoloniusOutOfScopePrecomputer<'mir, 'tcx> {
244244
visited: BitSet<mir::BasicBlock>,
245245
visit_stack: Vec<mir::BasicBlock>,
246-
body: &'a Body<'tcx>,
247-
regioncx: &'a RegionInferenceContext<'tcx>,
246+
body: &'mir Body<'tcx>,
247+
regioncx: &'mir RegionInferenceContext<'tcx>,
248248

249249
loans_out_of_scope_at_location: FxIndexMap<Location, Vec<BorrowIndex>>,
250250
}
251251

252-
impl<'a, 'tcx> PoloniusOutOfScopePrecomputer<'a, 'tcx> {
253-
fn new(body: &'a Body<'tcx>, regioncx: &'a RegionInferenceContext<'tcx>) -> Self {
252+
impl<'mir, 'tcx> PoloniusOutOfScopePrecomputer<'mir, 'tcx> {
253+
fn new(body: &'mir Body<'tcx>, regioncx: &'mir RegionInferenceContext<'tcx>) -> Self {
254254
Self {
255255
visited: BitSet::new_empty(body.basic_blocks.len()),
256256
visit_stack: vec![],
@@ -403,12 +403,12 @@ impl<'tcx> PoloniusOutOfScopePrecomputer<'_, 'tcx> {
403403
}
404404
}
405405

406-
impl<'a, 'tcx> Borrows<'a, 'tcx> {
406+
impl<'mir, 'tcx> Borrows<'mir, 'tcx> {
407407
pub fn new(
408408
tcx: TyCtxt<'tcx>,
409-
body: &'a Body<'tcx>,
410-
regioncx: &'a RegionInferenceContext<'tcx>,
411-
borrow_set: &'a BorrowSet<'tcx>,
409+
body: &'mir Body<'tcx>,
410+
regioncx: &'mir RegionInferenceContext<'tcx>,
411+
borrow_set: &'mir BorrowSet<'tcx>,
412412
) -> Self {
413413
let mut borrows_out_of_scope_at_location =
414414
calculate_borrows_out_of_scope_at_location(body, regioncx, borrow_set);

compiler/rustc_mir_dataflow/src/framework/direction.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,12 @@ impl Direction for Backward {
287287
}
288288
}
289289

290-
struct BackwardSwitchIntEdgeEffectsApplier<'a, 'tcx, D, F> {
291-
body: &'a mir::Body<'tcx>,
290+
struct BackwardSwitchIntEdgeEffectsApplier<'mir, 'tcx, D, F> {
291+
body: &'mir mir::Body<'tcx>,
292292
pred: BasicBlock,
293-
exit_state: &'a mut D,
293+
exit_state: &'mir mut D,
294294
bb: BasicBlock,
295-
propagate: &'a mut F,
295+
propagate: &'mir mut F,
296296
effects_applied: bool,
297297
}
298298

@@ -523,9 +523,9 @@ impl Direction for Forward {
523523
}
524524
}
525525

526-
struct ForwardSwitchIntEdgeEffectsApplier<'a, D, F> {
527-
exit_state: &'a mut D,
528-
targets: &'a SwitchTargets,
526+
struct ForwardSwitchIntEdgeEffectsApplier<'mir, D, F> {
527+
exit_state: &'mir mut D,
528+
targets: &'mir SwitchTargets,
529529
propagate: F,
530530

531531
effects_applied: bool,

compiler/rustc_mir_dataflow/src/framework/engine.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ where
128128
}
129129

130130
/// A solver for dataflow problems.
131-
pub struct Engine<'a, 'tcx, A>
131+
pub struct Engine<'mir, 'tcx, A>
132132
where
133133
A: Analysis<'tcx>,
134134
{
135135
tcx: TyCtxt<'tcx>,
136-
body: &'a mir::Body<'tcx>,
136+
body: &'mir mir::Body<'tcx>,
137137
entry_sets: IndexVec<BasicBlock, A::Domain>,
138138
pass_name: Option<&'static str>,
139139
analysis: A,
@@ -147,14 +147,14 @@ where
147147
apply_statement_trans_for_block: Option<Box<dyn Fn(BasicBlock, &mut A::Domain)>>,
148148
}
149149

150-
impl<'a, 'tcx, A, D, T> Engine<'a, 'tcx, A>
150+
impl<'mir, 'tcx, A, D, T> Engine<'mir, 'tcx, A>
151151
where
152152
A: GenKillAnalysis<'tcx, Idx = T, Domain = D>,
153153
D: Clone + JoinSemiLattice + GenKill<T> + BitSetExt<T>,
154154
T: Idx,
155155
{
156156
/// Creates a new `Engine` to solve a gen-kill dataflow problem.
157-
pub fn new_gen_kill(tcx: TyCtxt<'tcx>, body: &'a mir::Body<'tcx>, mut analysis: A) -> Self {
157+
pub fn new_gen_kill(tcx: TyCtxt<'tcx>, body: &'mir mir::Body<'tcx>, mut analysis: A) -> Self {
158158
// If there are no back-edges in the control-flow graph, we only ever need to apply the
159159
// transfer function for each block exactly once (assuming that we process blocks in RPO).
160160
//
@@ -186,7 +186,7 @@ where
186186
}
187187
}
188188

189-
impl<'a, 'tcx, A, D> Engine<'a, 'tcx, A>
189+
impl<'mir, 'tcx, A, D> Engine<'mir, 'tcx, A>
190190
where
191191
A: Analysis<'tcx, Domain = D>,
192192
D: Clone + JoinSemiLattice,
@@ -196,13 +196,13 @@ where
196196
///
197197
/// Gen-kill problems should use `new_gen_kill`, which will coalesce transfer functions for
198198
/// better performance.
199-
pub fn new_generic(tcx: TyCtxt<'tcx>, body: &'a mir::Body<'tcx>, analysis: A) -> Self {
199+
pub fn new_generic(tcx: TyCtxt<'tcx>, body: &'mir mir::Body<'tcx>, analysis: A) -> Self {
200200
Self::new(tcx, body, analysis, None)
201201
}
202202

203203
fn new(
204204
tcx: TyCtxt<'tcx>,
205-
body: &'a mir::Body<'tcx>,
205+
body: &'mir mir::Body<'tcx>,
206206
analysis: A,
207207
apply_statement_trans_for_block: Option<Box<dyn Fn(BasicBlock, &mut A::Domain)>>,
208208
) -> Self {

0 commit comments

Comments
 (0)