Skip to content

Commit 9ed1e9c

Browse files
committed
Remove unnecessary lifetimes in more borrowck structs.
Repeat the same trick with `MirBorrowCtxt`, which then results in lifetimes removed from `MoveVisitor` and `GatherUsedMutsVisitor`
1 parent 8607cb4 commit 9ed1e9c

13 files changed

+38
-42
lines changed

compiler/rustc_borrowck/src/borrowck_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_middle::span_bug;
88
use rustc_middle::ty::{self, Ty, TyCtxt};
99
use rustc_span::Span;
1010

11-
impl<'infcx, 'tcx> crate::MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
11+
impl<'infcx, 'tcx> crate::MirBorrowckCtxt<'_, 'infcx, 'tcx> {
1212
pub(crate) fn dcx(&self) -> DiagCtxtHandle<'infcx> {
1313
self.infcx.dcx()
1414
}

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'tcx> UniverseInfo<'tcx> {
5252

5353
pub(crate) fn report_error(
5454
&self,
55-
mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>,
55+
mbcx: &mut MirBorrowckCtxt<'_, '_, 'tcx>,
5656
placeholder: ty::PlaceholderRegion,
5757
error_element: RegionElement,
5858
cause: ObligationCause<'tcx>,
@@ -151,7 +151,7 @@ trait TypeOpInfo<'tcx> {
151151

152152
fn nice_error<'infcx>(
153153
&self,
154-
mbcx: &mut MirBorrowckCtxt<'_, '_, 'infcx, 'tcx>,
154+
mbcx: &mut MirBorrowckCtxt<'_, 'infcx, 'tcx>,
155155
cause: ObligationCause<'tcx>,
156156
placeholder_region: ty::Region<'tcx>,
157157
error_region: Option<ty::Region<'tcx>>,
@@ -160,7 +160,7 @@ trait TypeOpInfo<'tcx> {
160160
#[instrument(level = "debug", skip(self, mbcx))]
161161
fn report_error(
162162
&self,
163-
mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>,
163+
mbcx: &mut MirBorrowckCtxt<'_, '_, 'tcx>,
164164
placeholder: ty::PlaceholderRegion,
165165
error_element: RegionElement,
166166
cause: ObligationCause<'tcx>,
@@ -233,7 +233,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
233233

234234
fn nice_error<'infcx>(
235235
&self,
236-
mbcx: &mut MirBorrowckCtxt<'_, '_, 'infcx, 'tcx>,
236+
mbcx: &mut MirBorrowckCtxt<'_, 'infcx, 'tcx>,
237237
cause: ObligationCause<'tcx>,
238238
placeholder_region: ty::Region<'tcx>,
239239
error_region: Option<ty::Region<'tcx>>,
@@ -277,7 +277,7 @@ where
277277

278278
fn nice_error<'infcx>(
279279
&self,
280-
mbcx: &mut MirBorrowckCtxt<'_, '_, 'infcx, 'tcx>,
280+
mbcx: &mut MirBorrowckCtxt<'_, 'infcx, 'tcx>,
281281
cause: ObligationCause<'tcx>,
282282
placeholder_region: ty::Region<'tcx>,
283283
error_region: Option<ty::Region<'tcx>>,
@@ -324,7 +324,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
324324

325325
fn nice_error<'infcx>(
326326
&self,
327-
mbcx: &mut MirBorrowckCtxt<'_, '_, 'infcx, 'tcx>,
327+
mbcx: &mut MirBorrowckCtxt<'_, 'infcx, 'tcx>,
328328
cause: ObligationCause<'tcx>,
329329
placeholder_region: ty::Region<'tcx>,
330330
error_region: Option<ty::Region<'tcx>>,
@@ -357,7 +357,7 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
357357

358358
fn nice_error<'infcx>(
359359
&self,
360-
mbcx: &mut MirBorrowckCtxt<'_, '_, 'infcx, 'tcx>,
360+
mbcx: &mut MirBorrowckCtxt<'_, 'infcx, 'tcx>,
361361
_cause: ObligationCause<'tcx>,
362362
placeholder_region: ty::Region<'tcx>,
363363
error_region: Option<ty::Region<'tcx>>,

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ enum StorageDeadOrDrop<'tcx> {
6969
Destructor(Ty<'tcx>),
7070
}
7171

72-
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
72+
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
7373
pub(crate) fn report_use_of_moved_or_uninitialized(
7474
&mut self,
7575
location: Location,
@@ -4358,11 +4358,7 @@ enum AnnotatedBorrowFnSignature<'tcx> {
43584358
impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
43594359
/// Annotate the provided diagnostic with information about borrow from the fn signature that
43604360
/// helps explain.
4361-
pub(crate) fn emit(
4362-
&self,
4363-
cx: &MirBorrowckCtxt<'_, '_, '_, 'tcx>,
4364-
diag: &mut Diag<'_>,
4365-
) -> String {
4361+
pub(crate) fn emit(&self, cx: &MirBorrowckCtxt<'_, '_, 'tcx>, diag: &mut Diag<'_>) -> String {
43664362
match self {
43674363
&AnnotatedBorrowFnSignature::Closure { argument_ty, argument_span } => {
43684364
diag.span_label(

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
390390
}
391391
}
392392

393-
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
393+
impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
394394
fn free_region_constraint_info(
395395
&self,
396396
borrow_region: RegionVid,

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub(super) struct DescribePlaceOpt {
6868

6969
pub(super) struct IncludingTupleField(pub(super) bool);
7070

71-
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
71+
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
7272
/// Adds a suggestion when a closure is invoked twice with a moved variable or when a closure
7373
/// is moved after being invoked.
7474
///
@@ -772,7 +772,7 @@ struct CapturedMessageOpt {
772772
maybe_reinitialized_locations_is_empty: bool,
773773
}
774774

775-
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
775+
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
776776
/// Finds the spans associated to a move or copy of move_place at location.
777777
pub(super) fn move_spans(
778778
&self,

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ enum GroupedMoveError<'tcx> {
9393
},
9494
}
9595

96-
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
96+
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
9797
pub(crate) fn report_move_errors(&mut self) {
9898
let grouped_errors = self.group_move_errors();
9999
for error in grouped_errors {

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub(crate) enum AccessKind {
3232
Mutate,
3333
}
3434

35-
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
35+
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
3636
pub(crate) fn report_mutability_error(
3737
&mut self,
3838
access_place: Place<'tcx>,

compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl OutlivesSuggestionBuilder {
7676
/// Returns a name for the region if it is suggestable. See `region_name_is_suggestable`.
7777
fn region_vid_to_name(
7878
&self,
79-
mbcx: &MirBorrowckCtxt<'_, '_, '_, '_>,
79+
mbcx: &MirBorrowckCtxt<'_, '_, '_>,
8080
region: RegionVid,
8181
) -> Option<RegionName> {
8282
mbcx.give_region_a_name(region).filter(Self::region_name_is_suggestable)
@@ -85,7 +85,7 @@ impl OutlivesSuggestionBuilder {
8585
/// Compiles a list of all suggestions to be printed in the final big suggestion.
8686
fn compile_all_suggestions(
8787
&self,
88-
mbcx: &MirBorrowckCtxt<'_, '_, '_, '_>,
88+
mbcx: &MirBorrowckCtxt<'_, '_, '_>,
8989
) -> SmallVec<[SuggestedConstraint; 2]> {
9090
let mut suggested = SmallVec::new();
9191

@@ -161,7 +161,7 @@ impl OutlivesSuggestionBuilder {
161161
/// Emit an intermediate note on the given `Diag` if the involved regions are suggestable.
162162
pub(crate) fn intermediate_suggestion(
163163
&mut self,
164-
mbcx: &MirBorrowckCtxt<'_, '_, '_, '_>,
164+
mbcx: &MirBorrowckCtxt<'_, '_, '_>,
165165
errci: &ErrorConstraintInfo<'_>,
166166
diag: &mut Diag<'_>,
167167
) {
@@ -180,7 +180,7 @@ impl OutlivesSuggestionBuilder {
180180

181181
/// If there is a suggestion to emit, add a diagnostic to the buffer. This is the final
182182
/// suggestion including all collected constraints.
183-
pub(crate) fn add_suggestion(&self, mbcx: &mut MirBorrowckCtxt<'_, '_, '_, '_>) {
183+
pub(crate) fn add_suggestion(&self, mbcx: &mut MirBorrowckCtxt<'_, '_, '_>) {
184184
// No constraints to add? Done.
185185
if self.constraints_to_add.is_empty() {
186186
debug!("No constraints to suggest.");

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub(crate) struct ErrorConstraintInfo<'tcx> {
156156
pub(super) span: Span,
157157
}
158158

159-
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
159+
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
160160
/// Converts a region inference variable into a `ty::Region` that
161161
/// we can use for error reporting. If `r` is universally bound,
162162
/// then we use the name that we have on record for it. If `r` is

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl rustc_errors::IntoDiagArg for RegionName {
200200
}
201201
}
202202

203-
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
203+
impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
204204
pub(crate) fn mir_def_id(&self) -> hir::def_id::LocalDefId {
205205
self.body.source.def_id().expect_local()
206206
}

compiler/rustc_borrowck/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,11 @@ fn do_mir_borrowck<'tcx>(
304304
promoted_mbcx.report_move_errors();
305305
diags = promoted_mbcx.diags;
306306

307-
struct MoveVisitor<'a, 'b, 'mir, 'infcx, 'tcx> {
308-
ctxt: &'a mut MirBorrowckCtxt<'b, 'mir, 'infcx, 'tcx>,
307+
struct MoveVisitor<'a, 'mir, 'infcx, 'tcx> {
308+
ctxt: &'a mut MirBorrowckCtxt<'mir, 'infcx, 'tcx>,
309309
}
310310

311-
impl<'tcx> Visitor<'tcx> for MoveVisitor<'_, '_, '_, '_, 'tcx> {
311+
impl<'tcx> Visitor<'tcx> for MoveVisitor<'_, '_, '_, 'tcx> {
312312
fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) {
313313
if let Operand::Move(place) = operand {
314314
self.ctxt.check_movable_place(location, *place);
@@ -522,15 +522,15 @@ impl<'tcx> Deref for BorrowckInferCtxt<'tcx> {
522522
}
523523
}
524524

525-
struct MirBorrowckCtxt<'a, 'mir, 'infcx, 'tcx> {
525+
struct MirBorrowckCtxt<'mir, 'infcx, 'tcx> {
526526
infcx: &'infcx BorrowckInferCtxt<'tcx>,
527527
param_env: ParamEnv<'tcx>,
528528
body: &'mir Body<'tcx>,
529-
move_data: &'a MoveData<'tcx>,
529+
move_data: &'mir MoveData<'tcx>,
530530

531531
/// Map from MIR `Location` to `LocationIndex`; created
532532
/// when MIR borrowck begins.
533-
location_table: &'a LocationTable,
533+
location_table: &'mir LocationTable,
534534

535535
movable_coroutine: bool,
536536
/// This keeps track of whether local variables are free-ed when the function
@@ -599,8 +599,8 @@ struct MirBorrowckCtxt<'a, 'mir, 'infcx, 'tcx> {
599599
// 2. loans made in overlapping scopes do not conflict
600600
// 3. assignments do not affect things loaned out as immutable
601601
// 4. moves do not affect things loaned out in any way
602-
impl<'a, 'mir, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'mir, 'tcx, R>
603-
for MirBorrowckCtxt<'a, 'mir, '_, 'tcx>
602+
impl<'mir, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'mir, 'tcx, R>
603+
for MirBorrowckCtxt<'mir, '_, 'tcx>
604604
{
605605
type FlowState = Flows<'mir, 'tcx>;
606606

@@ -972,7 +972,7 @@ impl InitializationRequiringAction {
972972
}
973973
}
974974

975-
impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> {
975+
impl<'mir, 'tcx> MirBorrowckCtxt<'mir, '_, 'tcx> {
976976
fn body(&self) -> &'mir Body<'tcx> {
977977
self.body
978978
}
@@ -2010,7 +2010,7 @@ impl<'mir, 'tcx> MirBorrowckCtxt<'_, 'mir, '_, 'tcx> {
20102010
}
20112011

20122012
fn check_parent_of_field<'mir, 'tcx>(
2013-
this: &mut MirBorrowckCtxt<'_, 'mir, '_, 'tcx>,
2013+
this: &mut MirBorrowckCtxt<'mir, '_, 'tcx>,
20142014
location: Location,
20152015
base: PlaceRef<'tcx>,
20162016
span: Span,
@@ -2484,7 +2484,7 @@ mod diags {
24842484
}
24852485
}
24862486

2487-
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
2487+
impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
24882488
pub(crate) fn buffer_error(&mut self, diag: Diag<'infcx>) {
24892489
self.diags.buffer_error(diag);
24902490
}

compiler/rustc_borrowck/src/prefixes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub(super) enum PrefixSet {
3434
Shallow,
3535
}
3636

37-
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
37+
impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
3838
/// Returns an iterator over the prefixes of `place`
3939
/// (inclusive) from longest to smallest, potentially
4040
/// terminating the iteration early based on `kind`.

compiler/rustc_borrowck/src/used_muts.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use tracing::debug;
77

88
use crate::MirBorrowckCtxt;
99

10-
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
10+
impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
1111
/// Walks the MIR adding to the set of `used_mut` locals that will be ignored for the purposes
1212
/// of the `unused_mut` lint.
1313
///
@@ -46,13 +46,13 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
4646

4747
/// MIR visitor for collecting used mutable variables.
4848
/// The 'visit lifetime represents the duration of the MIR walk.
49-
struct GatherUsedMutsVisitor<'visit, 'a, 'mir, 'infcx, 'tcx> {
49+
struct GatherUsedMutsVisitor<'visit, 'mir, 'infcx, 'tcx> {
5050
temporary_used_locals: FxIndexSet<Local>,
5151
never_initialized_mut_locals: &'visit mut FxIndexSet<Local>,
52-
mbcx: &'visit mut MirBorrowckCtxt<'a, 'mir, 'infcx, 'tcx>,
52+
mbcx: &'visit mut MirBorrowckCtxt<'mir, 'infcx, 'tcx>,
5353
}
5454

55-
impl GatherUsedMutsVisitor<'_, '_, '_, '_, '_> {
55+
impl GatherUsedMutsVisitor<'_, '_, '_, '_> {
5656
fn remove_never_initialized_mut_locals(&mut self, into: Place<'_>) {
5757
// Remove any locals that we found were initialized from the
5858
// `never_initialized_mut_locals` set. At the end, the only remaining locals will
@@ -64,7 +64,7 @@ impl GatherUsedMutsVisitor<'_, '_, '_, '_, '_> {
6464
}
6565
}
6666

67-
impl<'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'_, '_, '_, '_, 'tcx> {
67+
impl<'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'_, '_, '_, 'tcx> {
6868
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
6969
debug!("visit_terminator: terminator={:?}", terminator);
7070
match &terminator.kind {

0 commit comments

Comments
 (0)