Skip to content

Commit

Permalink
Rollup merge of rust-lang#126911 - oli-obk:do_not_count_errors, r=com…
Browse files Browse the repository at this point in the history
…piler-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 rust-lang#126623
  • Loading branch information
compiler-errors authored Jun 24, 2024
2 parents 59c258f + 8fc6b3d commit 16bd6e2
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 62 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/borrowck_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_middle::span_bug;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::Span;

impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
impl<'tcx> crate::MirBorrowckCtxt<'_, '_, '_, 'tcx> {
pub fn dcx(&self) -> DiagCtxtHandle<'tcx> {
self.infcx.dcx()
}
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<'tcx> UniverseInfo<'tcx> {

pub(crate) fn report_error(
&self,
mbcx: &mut MirBorrowckCtxt<'_, 'tcx>,
mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>,
placeholder: ty::PlaceholderRegion,
error_element: RegionElement,
cause: ObligationCause<'tcx>,
Expand Down Expand Up @@ -151,7 +151,7 @@ trait TypeOpInfo<'tcx> {

fn nice_error(
&self,
mbcx: &mut MirBorrowckCtxt<'_, 'tcx>,
mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>,
cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>,
Expand All @@ -160,7 +160,7 @@ trait TypeOpInfo<'tcx> {
#[instrument(level = "debug", skip(self, mbcx))]
fn report_error(
&self,
mbcx: &mut MirBorrowckCtxt<'_, 'tcx>,
mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>,
placeholder: ty::PlaceholderRegion,
error_element: RegionElement,
cause: ObligationCause<'tcx>,
Expand Down Expand Up @@ -233,7 +233,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {

fn nice_error(
&self,
mbcx: &mut MirBorrowckCtxt<'_, 'tcx>,
mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>,
cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>,
Expand Down Expand Up @@ -270,7 +270,7 @@ where

fn nice_error(
&self,
mbcx: &mut MirBorrowckCtxt<'_, 'tcx>,
mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>,
cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>,
Expand Down Expand Up @@ -310,7 +310,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {

fn nice_error(
&self,
mbcx: &mut MirBorrowckCtxt<'_, 'tcx>,
mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>,
cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>,
Expand All @@ -336,7 +336,7 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {

fn nice_error(
&self,
mbcx: &mut MirBorrowckCtxt<'_, 'tcx>,
mbcx: &mut MirBorrowckCtxt<'_, '_, '_, 'tcx>,
_cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>,
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ enum StorageDeadOrDrop<'tcx> {
Destructor(Ty<'tcx>),
}

impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
pub(crate) fn report_use_of_moved_or_uninitialized(
&mut self,
location: Location,
Expand Down Expand Up @@ -4243,7 +4243,11 @@ enum AnnotatedBorrowFnSignature<'tcx> {
impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
/// Annotate the provided diagnostic with information about borrow from the fn signature that
/// helps explain.
pub(crate) fn emit(&self, cx: &MirBorrowckCtxt<'_, 'tcx>, diag: &mut Diag<'_>) -> String {
pub(crate) fn emit(
&self,
cx: &MirBorrowckCtxt<'_, '_, '_, 'tcx>,
diag: &mut Diag<'_>,
) -> String {
match self {
&AnnotatedBorrowFnSignature::Closure { argument_ty, argument_span } => {
diag.span_label(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
}
}

impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
fn free_region_constraint_info(
&self,
borrow_region: RegionVid,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub(super) struct DescribePlaceOpt {

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

impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
/// Adds a suggestion when a closure is invoked twice with a moved variable or when a closure
/// is moved after being invoked.
///
Expand Down Expand Up @@ -771,7 +771,7 @@ struct CapturedMessageOpt {
maybe_reinitialized_locations_is_empty: bool,
}

impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
/// Finds the spans associated to a move or copy of move_place at location.
pub(super) fn move_spans(
&self,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/move_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ enum GroupedMoveError<'tcx> {
},
}

impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
pub(crate) fn report_move_errors(&mut self) {
let grouped_errors = self.group_move_errors();
for error in grouped_errors {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub(crate) enum AccessKind {
Mutate,
}

impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
pub(crate) fn report_mutability_error(
&mut self,
access_place: Place<'tcx>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl OutlivesSuggestionBuilder {
/// Returns a name for the region if it is suggestable. See `region_name_is_suggestable`.
fn region_vid_to_name(
&self,
mbcx: &MirBorrowckCtxt<'_, '_>,
mbcx: &MirBorrowckCtxt<'_, '_, '_, '_>,
region: RegionVid,
) -> Option<RegionName> {
mbcx.give_region_a_name(region).filter(Self::region_name_is_suggestable)
Expand All @@ -84,7 +84,7 @@ impl OutlivesSuggestionBuilder {
/// Compiles a list of all suggestions to be printed in the final big suggestion.
fn compile_all_suggestions(
&self,
mbcx: &MirBorrowckCtxt<'_, '_>,
mbcx: &MirBorrowckCtxt<'_, '_, '_, '_>,
) -> SmallVec<[SuggestedConstraint; 2]> {
let mut suggested = SmallVec::new();

Expand Down Expand Up @@ -160,7 +160,7 @@ impl OutlivesSuggestionBuilder {
/// Emit an intermediate note on the given `Diag` if the involved regions are suggestable.
pub(crate) fn intermediate_suggestion(
&mut self,
mbcx: &MirBorrowckCtxt<'_, '_>,
mbcx: &MirBorrowckCtxt<'_, '_, '_, '_>,
errci: &ErrorConstraintInfo<'_>,
diag: &mut Diag<'_>,
) {
Expand All @@ -179,7 +179,7 @@ impl OutlivesSuggestionBuilder {

/// If there is a suggestion to emit, add a diagnostic to the buffer. This is the final
/// suggestion including all collected constraints.
pub(crate) fn add_suggestion(&self, mbcx: &mut MirBorrowckCtxt<'_, '_>) {
pub(crate) fn add_suggestion(&self, mbcx: &mut MirBorrowckCtxt<'_, '_, '_, '_>) {
// No constraints to add? Done.
if self.constraints_to_add.is_empty() {
debug!("No constraints to suggest.");
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub struct ErrorConstraintInfo<'tcx> {
pub(super) span: Span,
}

impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
/// Converts a region inference variable into a `ty::Region` that
/// we can use for error reporting. If `r` is universally bound,
/// then we use the name that we have on record for it. If `r` is
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl rustc_errors::IntoDiagArg for RegionName {
}
}

impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
pub(crate) fn mir_def_id(&self) -> hir::def_id::LocalDefId {
self.body.source.def_id().expect_local()
}
Expand Down
Loading

0 comments on commit 16bd6e2

Please sign in to comment.