Skip to content

Commit 16bd6e2

Browse files
Rollup merge of #126911 - oli-obk:do_not_count_errors, r=compiler-errors
Split the lifetimes of `MirBorrowckCtxt` These lifetimes are sometimes too general and will link things together that are independent. These are a blocker for actually finishing tracking more state (e.g. error tainting) in the diagnostic context handle, and I'd rather land it in its own PR instead of together with functional changes. Also changes a bunch of named lifetimes to `'_` where they were irrelevant follow-up to #126623
2 parents 59c258f + 8fc6b3d commit 16bd6e2

13 files changed

+73
-62
lines changed

compiler/rustc_borrowck/src/borrowck_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_middle::span_bug;
66
use rustc_middle::ty::{self, Ty, TyCtxt};
77
use rustc_span::Span;
88

9-
impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
9+
impl<'tcx> crate::MirBorrowckCtxt<'_, '_, '_, 'tcx> {
1010
pub fn dcx(&self) -> DiagCtxtHandle<'tcx> {
1111
self.infcx.dcx()
1212
}

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

+7-7
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(
153153
&self,
154-
mbcx: &mut MirBorrowckCtxt<'_, 'tcx>,
154+
mbcx: &mut MirBorrowckCtxt<'_, '_, '_, '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(
235235
&self,
236-
mbcx: &mut MirBorrowckCtxt<'_, 'tcx>,
236+
mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>,
237237
cause: ObligationCause<'tcx>,
238238
placeholder_region: ty::Region<'tcx>,
239239
error_region: Option<ty::Region<'tcx>>,
@@ -270,7 +270,7 @@ where
270270

271271
fn nice_error(
272272
&self,
273-
mbcx: &mut MirBorrowckCtxt<'_, 'tcx>,
273+
mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>,
274274
cause: ObligationCause<'tcx>,
275275
placeholder_region: ty::Region<'tcx>,
276276
error_region: Option<ty::Region<'tcx>>,
@@ -310,7 +310,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
310310

311311
fn nice_error(
312312
&self,
313-
mbcx: &mut MirBorrowckCtxt<'_, 'tcx>,
313+
mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>,
314314
cause: ObligationCause<'tcx>,
315315
placeholder_region: ty::Region<'tcx>,
316316
error_region: Option<ty::Region<'tcx>>,
@@ -336,7 +336,7 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
336336

337337
fn nice_error(
338338
&self,
339-
mbcx: &mut MirBorrowckCtxt<'_, 'tcx>,
339+
mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>,
340340
_cause: ObligationCause<'tcx>,
341341
placeholder_region: ty::Region<'tcx>,
342342
error_region: Option<ty::Region<'tcx>>,

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ enum StorageDeadOrDrop<'tcx> {
7373
Destructor(Ty<'tcx>),
7474
}
7575

76-
impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
76+
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
7777
pub(crate) fn report_use_of_moved_or_uninitialized(
7878
&mut self,
7979
location: Location,
@@ -4243,7 +4243,11 @@ enum AnnotatedBorrowFnSignature<'tcx> {
42434243
impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
42444244
/// Annotate the provided diagnostic with information about borrow from the fn signature that
42454245
/// helps explain.
4246-
pub(crate) fn emit(&self, cx: &MirBorrowckCtxt<'_, 'tcx>, diag: &mut Diag<'_>) -> String {
4246+
pub(crate) fn emit(
4247+
&self,
4248+
cx: &MirBorrowckCtxt<'_, '_, '_, 'tcx>,
4249+
diag: &mut Diag<'_>,
4250+
) -> String {
42474251
match self {
42484252
&AnnotatedBorrowFnSignature::Closure { argument_ty, argument_span } => {
42494253
diag.span_label(

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
389389
}
390390
}
391391

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

compiler/rustc_borrowck/src/diagnostics/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub(super) struct DescribePlaceOpt {
6969

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

72-
impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
72+
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
7373
/// Adds a suggestion when a closure is invoked twice with a moved variable or when a closure
7474
/// is moved after being invoked.
7575
///
@@ -771,7 +771,7 @@ struct CapturedMessageOpt {
771771
maybe_reinitialized_locations_is_empty: bool,
772772
}
773773

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

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ enum GroupedMoveError<'tcx> {
9393
},
9494
}
9595

96-
impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
96+
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, '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

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub(crate) enum AccessKind {
3030
Mutate,
3131
}
3232

33-
impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
33+
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
3434
pub(crate) fn report_mutability_error(
3535
&mut self,
3636
access_place: Place<'tcx>,

compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs

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

@@ -160,7 +160,7 @@ impl OutlivesSuggestionBuilder {
160160
/// Emit an intermediate note on the given `Diag` if the involved regions are suggestable.
161161
pub(crate) fn intermediate_suggestion(
162162
&mut self,
163-
mbcx: &MirBorrowckCtxt<'_, '_>,
163+
mbcx: &MirBorrowckCtxt<'_, '_, '_, '_>,
164164
errci: &ErrorConstraintInfo<'_>,
165165
diag: &mut Diag<'_>,
166166
) {
@@ -179,7 +179,7 @@ impl OutlivesSuggestionBuilder {
179179

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

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub struct ErrorConstraintInfo<'tcx> {
160160
pub(super) span: Span,
161161
}
162162

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

compiler/rustc_borrowck/src/diagnostics/region_name.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl rustc_errors::IntoDiagArg for RegionName {
198198
}
199199
}
200200

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

0 commit comments

Comments
 (0)