Skip to content

Commit ee8fd33

Browse files
authored
Rollup merge of #130022 - nnethercote:dataflow-borrowck-lifetimes, r=oli-obk
Dataflow/borrowck lifetime cleanups These commits remove a bunch of unnecessary lifetimes from structs involved in dataflow/borrowck. r? ``@lqd``
2 parents 3e3b148 + 5c35027 commit ee8fd33

25 files changed

Lines changed: 209 additions & 248 deletions

‎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)fndcx(&self) -> DiagCtxtHandle<'infcx>{
1313
self.infcx.dcx()
1414
}

‎compiler/rustc_borrowck/src/dataflow.rs‎

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@ use tracing::debug;
1515
usecrate::{places_conflict,BorrowSet,PlaceConflictBias,PlaceExt,RegionInferenceContext};
1616

1717
/// The results of the dataflow analyses used by the borrow checker.
18-
pub(crate)structBorrowckResults<'a,'mir,'tcx>{
19-
pub(crate)borrows:Results<'tcx,Borrows<'a,'mir,'tcx>>,
20-
pub(crate)uninits:Results<'tcx,MaybeUninitializedPlaces<'a,'mir,'tcx>>,
21-
pub(crate)ever_inits:Results<'tcx,EverInitializedPlaces<'a,'mir,'tcx>>,
18+
pub(crate)structBorrowckResults<'a,'tcx>{
19+
pub(crate)borrows:Results<'tcx,Borrows<'a,'tcx>>,
20+
pub(crate)uninits:Results<'tcx,MaybeUninitializedPlaces<'a,'tcx>>,
21+
pub(crate)ever_inits:Results<'tcx,EverInitializedPlaces<'a,'tcx>>,
2222
}
2323

2424
/// The transient state of the dataflow analyses used by the borrow checker.
2525
#[derive(Debug)]
26-
pub(crate)structBorrowckFlowState<'a,'mir,'tcx>{
27-
pub(crate)borrows: <Borrows<'a,'mir,'tcx>asAnalysisDomain<'tcx>>::Domain,
28-
pub(crate)uninits: <MaybeUninitializedPlaces<'a,'mir,'tcx>asAnalysisDomain<'tcx>>::Domain,
29-
pub(crate)ever_inits: <EverInitializedPlaces<'a,'mir,'tcx>asAnalysisDomain<'tcx>>::Domain,
26+
pub(crate)structBorrowckFlowState<'a,'tcx>{
27+
pub(crate)borrows: <Borrows<'a,'tcx>asAnalysisDomain<'tcx>>::Domain,
28+
pub(crate)uninits: <MaybeUninitializedPlaces<'a,'tcx>asAnalysisDomain<'tcx>>::Domain,
29+
pub(crate)ever_inits: <EverInitializedPlaces<'a,'tcx>asAnalysisDomain<'tcx>>::Domain,
3030
}
3131

32-
impl<'a,'mir,'tcx>ResultsVisitable<'tcx>forBorrowckResults<'a,'mir,'tcx>{
32+
impl<'a,'tcx>ResultsVisitable<'tcx>forBorrowckResults<'a,'tcx>{
3333
// All three analyses are forward, but we have to use just one here.
34-
typeDirection = <Borrows<'a,'mir,'tcx>asAnalysisDomain<'tcx>>::Direction;
35-
typeFlowState = BorrowckFlowState<'a,'mir,'tcx>;
34+
typeDirection = <Borrows<'a,'tcx>asAnalysisDomain<'tcx>>::Direction;
35+
typeFlowState = BorrowckFlowState<'a,'tcx>;
3636

3737
fnnew_flow_state(&self,body:&mir::Body<'tcx>) -> Self::FlowState{
3838
BorrowckFlowState{
@@ -106,10 +106,9 @@ rustc_index::newtype_index! {
106106
/// `BorrowIndex`, and maps each such index to a `BorrowData`
107107
/// describing the borrow. These indexes are used for representing the
108108
/// borrows in compact bitvectors.
109-
pubstructBorrows<'a,'mir,'tcx>{
109+
pubstructBorrows<'a,'tcx>{
110110
tcx:TyCtxt<'tcx>,
111-
body:&'mirBody<'tcx>,
112-
111+
body:&'aBody<'tcx>,
113112
borrow_set:&'aBorrowSet<'tcx>,
114113
borrows_out_of_scope_at_location:FxIndexMap<Location,Vec<BorrowIndex>>,
115114
}
@@ -389,10 +388,10 @@ impl<'tcx> PoloniusOutOfScopePrecomputer<'_, 'tcx> {
389388
}
390389
}
391390

392-
impl<'a,'mir,'tcx>Borrows<'a,'mir,'tcx>{
391+
impl<'a,'tcx>Borrows<'a,'tcx>{
393392
pubfnnew(
394393
tcx:TyCtxt<'tcx>,
395-
body:&'mirBody<'tcx>,
394+
body:&'aBody<'tcx>,
396395
regioncx:&RegionInferenceContext<'tcx>,
397396
borrow_set:&'aBorrowSet<'tcx>,
398397
) -> Self{
@@ -494,7 +493,7 @@ impl<'a, 'mir, 'tcx> Borrows<'a, 'mir, 'tcx> {
494493
}
495494
}
496495

497-
impl<'tcx> rustc_mir_dataflow::AnalysisDomain<'tcx>forBorrows<'_,'_,'tcx>{
496+
impl<'tcx> rustc_mir_dataflow::AnalysisDomain<'tcx>forBorrows<'_,'tcx>{
498497
typeDomain = BitSet<BorrowIndex>;
499498

500499
constNAME:&'staticstr = "borrows";
@@ -517,7 +516,7 @@ impl<'tcx> rustc_mir_dataflow::AnalysisDomain<'tcx> for Borrows<'_, '_, 'tcx> {
517516
/// region stops containing the CFG points reachable from the issuing location.
518517
/// - we also kill loans of conflicting places when overwriting a shared path: e.g. borrows of
519518
/// `a.b.c` when `a` is overwritten.
520-
impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx>forBorrows<'_,'_,'tcx>{
519+
impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx>forBorrows<'_,'tcx>{
521520
typeIdx = BorrowIndex;
522521

523522
fndomain_size(&self, _:&mir::Body<'tcx>) -> usize{
@@ -617,8 +616,8 @@ impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx> for Borrows<'_, '_, 'tcx> {
617616
}
618617
}
619618

620-
implDebugWithContext<Borrows<'_,'_,'_>>forBorrowIndex{
621-
fnfmt_with(&self,ctxt:&Borrows<'_,'_,'_>,f:&mut fmt::Formatter<'_>) -> fmt::Result{
619+
implDebugWithContext<Borrows<'_,'_>>forBorrowIndex{
620+
fnfmt_with(&self,ctxt:&Borrows<'_,'_>,f:&mut fmt::Formatter<'_>) -> fmt::Result{
622621
write!(f,"{:?}", ctxt.location(*self))
623622
}
624623
}

‎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)fnreport_error(
5454
&self,
55-
mbcx:&mutMirBorrowckCtxt<'_,'_,'_,'tcx>,
55+
mbcx:&mutMirBorrowckCtxt<'_,'_,'tcx>,
5656
placeholder: ty::PlaceholderRegion,
5757
error_element:RegionElement,
5858
cause:ObligationCause<'tcx>,
@@ -151,7 +151,7 @@ trait TypeOpInfo<'tcx> {
151151

152152
fnnice_error<'infcx>(
153153
&self,
154-
mbcx:&mutMirBorrowckCtxt<'_,'_,'infcx,'tcx>,
154+
mbcx:&mutMirBorrowckCtxt<'_,'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
fnreport_error(
162162
&self,
163-
mbcx:&mutMirBorrowckCtxt<'_,'_,'_,'tcx>,
163+
mbcx:&mutMirBorrowckCtxt<'_,'_,'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
fnnice_error<'infcx>(
235235
&self,
236-
mbcx:&mutMirBorrowckCtxt<'_,'_,'infcx,'tcx>,
236+
mbcx:&mutMirBorrowckCtxt<'_,'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
fnnice_error<'infcx>(
279279
&self,
280-
mbcx:&mutMirBorrowckCtxt<'_,'_,'infcx,'tcx>,
280+
mbcx:&mutMirBorrowckCtxt<'_,'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
fnnice_error<'infcx>(
326326
&self,
327-
mbcx:&mutMirBorrowckCtxt<'_,'_,'infcx,'tcx>,
327+
mbcx:&mutMirBorrowckCtxt<'_,'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
fnnice_error<'infcx>(
359359
&self,
360-
mbcx:&mutMirBorrowckCtxt<'_,'_,'infcx,'tcx>,
360+
mbcx:&mutMirBorrowckCtxt<'_,'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)fnreport_use_of_moved_or_uninitialized(
7474
&mutself,
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)fnemit(
4362-
&self,
4363-
cx:&MirBorrowckCtxt<'_,'_,'_,'tcx>,
4364-
diag:&mutDiag<'_>,
4365-
) -> String{
4361+
pub(crate)fnemit(&self,cx:&MirBorrowckCtxt<'_,'_,'tcx>,diag:&mutDiag<'_>) -> String{
43664362
matchself{
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
fnfree_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)structIncludingTupleField(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)fnmove_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)fnreport_move_errors(&mutself){
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)fnreport_mutability_error(
3737
&mutself,
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
fnregion_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
fncompile_all_suggestions(
8787
&self,
88-
mbcx:&MirBorrowckCtxt<'_,'_,'_,'_>,
88+
mbcx:&MirBorrowckCtxt<'_,'_,'_>,
8989
) -> SmallVec<[SuggestedConstraint;2]>{
9090
letmut 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)fnintermediate_suggestion(
163163
&mutself,
164-
mbcx:&MirBorrowckCtxt<'_,'_,'_,'_>,
164+
mbcx:&MirBorrowckCtxt<'_,'_,'_>,
165165
errci:&ErrorConstraintInfo<'_>,
166166
diag:&mutDiag<'_>,
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)fnadd_suggestion(&self,mbcx:&mutMirBorrowckCtxt<'_,'_,'_,'_>){
183+
pub(crate)fnadd_suggestion(&self,mbcx:&mutMirBorrowckCtxt<'_,'_,'_>){
184184
// No constraints to add? Done.
185185
ifself.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

0 commit comments

Comments
 (0)