Skip to content

Commit

Permalink
Auto merge of rust-lang#93244 - mark-i-m:doomed, r=oli-obk
Browse files Browse the repository at this point in the history
Rename `ErrorReported` -> `ErrorGuaranteed`

r? `@eddyb`

cc rust-lang#93222 rust-lang#69426

The idea is that we would like to use it for both errors and `delay_span_bug`. Its semantics indicate a _guarantee_ that compilation will fail.
  • Loading branch information
bors committed Mar 2, 2022
2 parents c42d846 + e489a94 commit 08504c6
Show file tree
Hide file tree
Showing 112 changed files with 580 additions and 559 deletions.
58 changes: 31 additions & 27 deletions compiler/rustc_borrowck/src/borrowck_errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustc_errors::{struct_span_err, DiagnosticBuilder, DiagnosticId, ErrorReported};
use rustc_errors::{struct_span_err, DiagnosticBuilder, DiagnosticId, ErrorGuaranteed};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::{MultiSpan, Span};

Expand All @@ -7,7 +7,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
&self,
span: Span,
desc: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
struct_span_err!(self, span, E0505, "cannot move out of {} because it is borrowed", desc,)
}

Expand All @@ -17,7 +17,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
desc: &str,
borrow_span: Span,
borrow_desc: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!(
self,
span,
Expand All @@ -36,7 +36,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
span: Span,
verb: &str,
desc: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
struct_span_err!(
self,
span,
Expand All @@ -55,7 +55,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
old_loan_span: Span,
old_opt_via: &str,
old_load_end_span: Option<Span>,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let via =
|msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {})", msg) };
let mut err = struct_span_err!(
Expand Down Expand Up @@ -103,7 +103,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
desc: &str,
old_loan_span: Span,
old_load_end_span: Option<Span>,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!(
self,
new_loan_span,
Expand Down Expand Up @@ -136,7 +136,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
noun_old: &str,
old_opt_via: &str,
previous_end_span: Option<Span>,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!(
self,
new_loan_span,
Expand Down Expand Up @@ -168,7 +168,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
old_opt_via: &str,
previous_end_span: Option<Span>,
second_borrow_desc: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!(
self,
new_loan_span,
Expand Down Expand Up @@ -204,7 +204,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
kind_old: &str,
msg_old: &str,
old_load_end_span: Option<Span>,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let via =
|msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {})", msg) };
let mut err = struct_span_err!(
Expand Down Expand Up @@ -247,7 +247,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
span: Span,
borrow_span: Span,
desc: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!(
self,
span,
Expand All @@ -266,20 +266,24 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
span: Span,
desc: &str,
is_arg: bool,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let msg = if is_arg { "to immutable argument" } else { "twice to immutable variable" };
struct_span_err!(self, span, E0384, "cannot assign {} {}", msg, desc)
}

crate fn cannot_assign(&self, span: Span, desc: &str) -> DiagnosticBuilder<'cx, ErrorReported> {
crate fn cannot_assign(
&self,
span: Span,
desc: &str,
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
struct_span_err!(self, span, E0594, "cannot assign to {}", desc)
}

crate fn cannot_move_out_of(
&self,
move_from_span: Span,
move_from_desc: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
struct_span_err!(self, move_from_span, E0507, "cannot move out of {}", move_from_desc,)
}

Expand All @@ -291,7 +295,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
move_from_span: Span,
ty: Ty<'_>,
is_index: Option<bool>,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let type_name = match (&ty.kind(), is_index) {
(&ty::Array(_, _), Some(true)) | (&ty::Array(_, _), None) => "array",
(&ty::Slice(_), _) => "slice",
Expand All @@ -313,7 +317,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
&self,
move_from_span: Span,
container_ty: Ty<'_>,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!(
self,
move_from_span,
Expand All @@ -331,7 +335,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
verb: &str,
optional_adverb_for_moved: &str,
moved_path: Option<String>,
) -> DiagnosticBuilder<'tcx, ErrorReported> {
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let moved_path = moved_path.map(|mp| format!(": `{}`", mp)).unwrap_or_default();

struct_span_err!(
Expand All @@ -350,7 +354,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
span: Span,
path: &str,
reason: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
struct_span_err!(self, span, E0596, "cannot borrow {} as mutable{}", path, reason,)
}

Expand All @@ -361,7 +365,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
immutable_place: &str,
immutable_section: &str,
action: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!(
self,
mutate_span,
Expand All @@ -380,7 +384,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
&self,
span: Span,
yield_span: Span,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!(
self,
span,
Expand All @@ -394,7 +398,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
crate fn cannot_borrow_across_destructor(
&self,
borrow_span: Span,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
struct_span_err!(
self,
borrow_span,
Expand All @@ -407,7 +411,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
&self,
span: Span,
path: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
struct_span_err!(self, span, E0597, "{} does not live long enough", path,)
}

Expand All @@ -417,7 +421,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
return_kind: &str,
reference_desc: &str,
path_desc: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!(
self,
span,
Expand All @@ -442,7 +446,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
closure_kind: &str,
borrowed_path: &str,
capture_span: Span,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!(
self,
closure_span,
Expand All @@ -461,14 +465,14 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
crate fn thread_local_value_does_not_live_long_enough(
&self,
span: Span,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
struct_span_err!(self, span, E0712, "thread-local variable borrowed past end of function",)
}

crate fn temporary_value_borrowed_for_too_long(
&self,
span: Span,
) -> DiagnosticBuilder<'cx, ErrorReported> {
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
struct_span_err!(self, span, E0716, "temporary value dropped while borrowed",)
}

Expand All @@ -477,7 +481,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
sp: S,
msg: &str,
code: DiagnosticId,
) -> DiagnosticBuilder<'tcx, ErrorReported> {
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
self.infcx.tcx.sess.struct_span_err_with_code(sp, msg, code)
}
}
Expand All @@ -486,7 +490,7 @@ crate fn borrowed_data_escapes_closure<'tcx>(
tcx: TyCtxt<'tcx>,
escape_span: Span,
escapes_from: &str,
) -> DiagnosticBuilder<'tcx, ErrorReported> {
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
struct_span_err!(
tcx.sess,
escape_span,
Expand Down
20 changes: 10 additions & 10 deletions compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustc_errors::{DiagnosticBuilder, ErrorReported};
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
use rustc_infer::infer::canonical::Canonical;
use rustc_infer::infer::error_reporting::nice_region_error::NiceRegionError;
use rustc_infer::infer::region_constraints::Constraint;
Expand Down Expand Up @@ -124,7 +124,7 @@ trait TypeOpInfo<'tcx> {
&self,
tcx: TyCtxt<'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported>;
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>;

fn base_universe(&self) -> ty::UniverseIndex;

Expand All @@ -134,7 +134,7 @@ trait TypeOpInfo<'tcx> {
cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>>;
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>>;

fn report_error(
&self,
Expand Down Expand Up @@ -196,7 +196,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
&self,
tcx: TyCtxt<'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> {
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = tcx.sess.struct_span_err(span, "higher-ranked lifetime error");
err.note(&format!("could not prove {}", self.canonical_query.value.value.predicate));
err
Expand All @@ -212,7 +212,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
tcx.infer_ctxt().enter_with_canonical(
cause.span,
&self.canonical_query,
Expand Down Expand Up @@ -243,7 +243,7 @@ where
&self,
tcx: TyCtxt<'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> {
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = tcx.sess.struct_span_err(span, "higher-ranked lifetime error");
err.note(&format!("could not normalize `{}`", self.canonical_query.value.value.value));
err
Expand All @@ -259,7 +259,7 @@ where
cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
tcx.infer_ctxt().enter_with_canonical(
cause.span,
&self.canonical_query,
Expand Down Expand Up @@ -304,7 +304,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
&self,
tcx: TyCtxt<'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> {
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
// FIXME: This error message isn't great, but it doesn't show up in the existing UI tests,
// and is only the fallback when the nice error fails. Consider improving this some more.
tcx.sess.struct_span_err(span, "higher-ranked lifetime error")
Expand All @@ -320,7 +320,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
tcx.infer_ctxt().enter_with_canonical(
cause.span,
&self.canonical_query,
Expand All @@ -345,7 +345,7 @@ fn try_extract_error_from_fulfill_cx<'tcx>(
infcx: &InferCtxt<'_, 'tcx>,
placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
let tcx = infcx.tcx;

// We generally shouldn't have errors here because the query was
Expand Down
Loading

0 comments on commit 08504c6

Please sign in to comment.