1
Fork 0

rename ErrorReported -> ErrorGuaranteed

This commit is contained in:
mark 2022-01-23 12:34:26 -06:00
parent c42d846add
commit e489a94dee
112 changed files with 580 additions and 559 deletions

View file

@ -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_middle::ty::{self, Ty, TyCtxt};
use rustc_span::{MultiSpan, Span}; use rustc_span::{MultiSpan, Span};
@ -7,7 +7,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
&self, &self,
span: Span, span: Span,
desc: &str, desc: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
struct_span_err!(self, span, E0505, "cannot move out of {} because it is borrowed", desc,) struct_span_err!(self, span, E0505, "cannot move out of {} because it is borrowed", desc,)
} }
@ -17,7 +17,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
desc: &str, desc: &str,
borrow_span: Span, borrow_span: Span,
borrow_desc: &str, borrow_desc: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!( let mut err = struct_span_err!(
self, self,
span, span,
@ -36,7 +36,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
span: Span, span: Span,
verb: &str, verb: &str,
desc: &str, desc: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
struct_span_err!( struct_span_err!(
self, self,
span, span,
@ -55,7 +55,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
old_loan_span: Span, old_loan_span: Span,
old_opt_via: &str, old_opt_via: &str,
old_load_end_span: Option<Span>, old_load_end_span: Option<Span>,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let via = let via =
|msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {})", msg) }; |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {})", msg) };
let mut err = struct_span_err!( let mut err = struct_span_err!(
@ -103,7 +103,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
desc: &str, desc: &str,
old_loan_span: Span, old_loan_span: Span,
old_load_end_span: Option<Span>, old_load_end_span: Option<Span>,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!( let mut err = struct_span_err!(
self, self,
new_loan_span, new_loan_span,
@ -136,7 +136,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
noun_old: &str, noun_old: &str,
old_opt_via: &str, old_opt_via: &str,
previous_end_span: Option<Span>, previous_end_span: Option<Span>,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!( let mut err = struct_span_err!(
self, self,
new_loan_span, new_loan_span,
@ -168,7 +168,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
old_opt_via: &str, old_opt_via: &str,
previous_end_span: Option<Span>, previous_end_span: Option<Span>,
second_borrow_desc: &str, second_borrow_desc: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!( let mut err = struct_span_err!(
self, self,
new_loan_span, new_loan_span,
@ -204,7 +204,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
kind_old: &str, kind_old: &str,
msg_old: &str, msg_old: &str,
old_load_end_span: Option<Span>, old_load_end_span: Option<Span>,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let via = let via =
|msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {})", msg) }; |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {})", msg) };
let mut err = struct_span_err!( let mut err = struct_span_err!(
@ -247,7 +247,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
span: Span, span: Span,
borrow_span: Span, borrow_span: Span,
desc: &str, desc: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!( let mut err = struct_span_err!(
self, self,
span, span,
@ -266,12 +266,16 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
span: Span, span: Span,
desc: &str, desc: &str,
is_arg: bool, is_arg: bool,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let msg = if is_arg { "to immutable argument" } else { "twice to immutable variable" }; let msg = if is_arg { "to immutable argument" } else { "twice to immutable variable" };
struct_span_err!(self, span, E0384, "cannot assign {} {}", msg, desc) 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) struct_span_err!(self, span, E0594, "cannot assign to {}", desc)
} }
@ -279,7 +283,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
&self, &self,
move_from_span: Span, move_from_span: Span,
move_from_desc: &str, 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,) struct_span_err!(self, move_from_span, E0507, "cannot move out of {}", move_from_desc,)
} }
@ -291,7 +295,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
move_from_span: Span, move_from_span: Span,
ty: Ty<'_>, ty: Ty<'_>,
is_index: Option<bool>, is_index: Option<bool>,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let type_name = match (&ty.kind(), is_index) { let type_name = match (&ty.kind(), is_index) {
(&ty::Array(_, _), Some(true)) | (&ty::Array(_, _), None) => "array", (&ty::Array(_, _), Some(true)) | (&ty::Array(_, _), None) => "array",
(&ty::Slice(_), _) => "slice", (&ty::Slice(_), _) => "slice",
@ -313,7 +317,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
&self, &self,
move_from_span: Span, move_from_span: Span,
container_ty: Ty<'_>, container_ty: Ty<'_>,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!( let mut err = struct_span_err!(
self, self,
move_from_span, move_from_span,
@ -331,7 +335,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
verb: &str, verb: &str,
optional_adverb_for_moved: &str, optional_adverb_for_moved: &str,
moved_path: Option<String>, moved_path: Option<String>,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let moved_path = moved_path.map(|mp| format!(": `{}`", mp)).unwrap_or_default(); let moved_path = moved_path.map(|mp| format!(": `{}`", mp)).unwrap_or_default();
struct_span_err!( struct_span_err!(
@ -350,7 +354,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
span: Span, span: Span,
path: &str, path: &str,
reason: &str, reason: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
struct_span_err!(self, span, E0596, "cannot borrow {} as mutable{}", path, reason,) struct_span_err!(self, span, E0596, "cannot borrow {} as mutable{}", path, reason,)
} }
@ -361,7 +365,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
immutable_place: &str, immutable_place: &str,
immutable_section: &str, immutable_section: &str,
action: &str, action: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!( let mut err = struct_span_err!(
self, self,
mutate_span, mutate_span,
@ -380,7 +384,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
&self, &self,
span: Span, span: Span,
yield_span: Span, yield_span: Span,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!( let mut err = struct_span_err!(
self, self,
span, span,
@ -394,7 +398,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
crate fn cannot_borrow_across_destructor( crate fn cannot_borrow_across_destructor(
&self, &self,
borrow_span: Span, borrow_span: Span,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
struct_span_err!( struct_span_err!(
self, self,
borrow_span, borrow_span,
@ -407,7 +411,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
&self, &self,
span: Span, span: Span,
path: &str, path: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
struct_span_err!(self, span, E0597, "{} does not live long enough", path,) struct_span_err!(self, span, E0597, "{} does not live long enough", path,)
} }
@ -417,7 +421,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
return_kind: &str, return_kind: &str,
reference_desc: &str, reference_desc: &str,
path_desc: &str, path_desc: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!( let mut err = struct_span_err!(
self, self,
span, span,
@ -442,7 +446,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
closure_kind: &str, closure_kind: &str,
borrowed_path: &str, borrowed_path: &str,
capture_span: Span, capture_span: Span,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let mut err = struct_span_err!( let mut err = struct_span_err!(
self, self,
closure_span, closure_span,
@ -461,14 +465,14 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
crate fn thread_local_value_does_not_live_long_enough( crate fn thread_local_value_does_not_live_long_enough(
&self, &self,
span: Span, span: Span,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
struct_span_err!(self, span, E0712, "thread-local variable borrowed past end of function",) struct_span_err!(self, span, E0712, "thread-local variable borrowed past end of function",)
} }
crate fn temporary_value_borrowed_for_too_long( crate fn temporary_value_borrowed_for_too_long(
&self, &self,
span: Span, span: Span,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
struct_span_err!(self, span, E0716, "temporary value dropped while borrowed",) struct_span_err!(self, span, E0716, "temporary value dropped while borrowed",)
} }
@ -477,7 +481,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
sp: S, sp: S,
msg: &str, msg: &str,
code: DiagnosticId, code: DiagnosticId,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
self.infcx.tcx.sess.struct_span_err_with_code(sp, msg, code) self.infcx.tcx.sess.struct_span_err_with_code(sp, msg, code)
} }
} }
@ -486,7 +490,7 @@ crate fn borrowed_data_escapes_closure<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
escape_span: Span, escape_span: Span,
escapes_from: &str, escapes_from: &str,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
struct_span_err!( struct_span_err!(
tcx.sess, tcx.sess,
escape_span, escape_span,

View file

@ -1,4 +1,4 @@
use rustc_errors::{DiagnosticBuilder, ErrorReported}; use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
use rustc_infer::infer::canonical::Canonical; use rustc_infer::infer::canonical::Canonical;
use rustc_infer::infer::error_reporting::nice_region_error::NiceRegionError; use rustc_infer::infer::error_reporting::nice_region_error::NiceRegionError;
use rustc_infer::infer::region_constraints::Constraint; use rustc_infer::infer::region_constraints::Constraint;
@ -124,7 +124,7 @@ trait TypeOpInfo<'tcx> {
&self, &self,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported>; ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>;
fn base_universe(&self) -> ty::UniverseIndex; fn base_universe(&self) -> ty::UniverseIndex;
@ -134,7 +134,7 @@ trait TypeOpInfo<'tcx> {
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>, placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>, error_region: Option<ty::Region<'tcx>>,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>>; ) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>>;
fn report_error( fn report_error(
&self, &self,
@ -196,7 +196,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
&self, &self,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = tcx.sess.struct_span_err(span, "higher-ranked lifetime error"); 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.note(&format!("could not prove {}", self.canonical_query.value.value.predicate));
err err
@ -212,7 +212,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>, placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>, error_region: Option<ty::Region<'tcx>>,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> { ) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
tcx.infer_ctxt().enter_with_canonical( tcx.infer_ctxt().enter_with_canonical(
cause.span, cause.span,
&self.canonical_query, &self.canonical_query,
@ -243,7 +243,7 @@ where
&self, &self,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = tcx.sess.struct_span_err(span, "higher-ranked lifetime error"); 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.note(&format!("could not normalize `{}`", self.canonical_query.value.value.value));
err err
@ -259,7 +259,7 @@ where
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>, placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>, error_region: Option<ty::Region<'tcx>>,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> { ) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
tcx.infer_ctxt().enter_with_canonical( tcx.infer_ctxt().enter_with_canonical(
cause.span, cause.span,
&self.canonical_query, &self.canonical_query,
@ -304,7 +304,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
&self, &self,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
span: Span, 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, // 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. // 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") tcx.sess.struct_span_err(span, "higher-ranked lifetime error")
@ -320,7 +320,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
placeholder_region: ty::Region<'tcx>, placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>, error_region: Option<ty::Region<'tcx>>,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> { ) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
tcx.infer_ctxt().enter_with_canonical( tcx.infer_ctxt().enter_with_canonical(
cause.span, cause.span,
&self.canonical_query, &self.canonical_query,
@ -345,7 +345,7 @@ fn try_extract_error_from_fulfill_cx<'tcx>(
infcx: &InferCtxt<'_, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
placeholder_region: ty::Region<'tcx>, placeholder_region: ty::Region<'tcx>,
error_region: Option<ty::Region<'tcx>>, error_region: Option<ty::Region<'tcx>>,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> { ) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
let tcx = infcx.tcx; let tcx = infcx.tcx;
// We generally shouldn't have errors here because the query was // We generally shouldn't have errors here because the query was

View file

@ -1,7 +1,7 @@
use either::Either; use either::Either;
use rustc_const_eval::util::{CallDesugaringKind, CallKind}; use rustc_const_eval::util::{CallDesugaringKind, CallKind};
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorReported}; use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_hir::{AsyncGeneratorKind, GeneratorKind}; use rustc_hir::{AsyncGeneratorKind, GeneratorKind};
@ -507,7 +507,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
location: Location, location: Location,
(place, _span): (Place<'tcx>, Span), (place, _span): (Place<'tcx>, Span),
borrow: &BorrowData<'tcx>, borrow: &BorrowData<'tcx>,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let borrow_spans = self.retrieve_borrow_spans(borrow); let borrow_spans = self.retrieve_borrow_spans(borrow);
let borrow_span = borrow_spans.args_or_use(); let borrow_span = borrow_spans.args_or_use();
@ -554,7 +554,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
(place, span): (Place<'tcx>, Span), (place, span): (Place<'tcx>, Span),
gen_borrow_kind: BorrowKind, gen_borrow_kind: BorrowKind,
issued_borrow: &BorrowData<'tcx>, issued_borrow: &BorrowData<'tcx>,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let issued_spans = self.retrieve_borrow_spans(issued_borrow); let issued_spans = self.retrieve_borrow_spans(issued_borrow);
let issued_span = issued_spans.args_or_use(); let issued_span = issued_spans.args_or_use();
@ -1120,7 +1120,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
drop_span: Span, drop_span: Span,
borrow_spans: UseSpans<'tcx>, borrow_spans: UseSpans<'tcx>,
explanation: BorrowExplanation, explanation: BorrowExplanation,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
debug!( debug!(
"report_local_value_does_not_live_long_enough(\ "report_local_value_does_not_live_long_enough(\
{:?}, {:?}, {:?}, {:?}, {:?}\ {:?}, {:?}, {:?}, {:?}, {:?}\
@ -1298,7 +1298,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
&mut self, &mut self,
drop_span: Span, drop_span: Span,
borrow_span: Span, borrow_span: Span,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
debug!( debug!(
"report_thread_local_value_does_not_live_long_enough(\ "report_thread_local_value_does_not_live_long_enough(\
{:?}, {:?}\ {:?}, {:?}\
@ -1325,7 +1325,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
borrow_spans: UseSpans<'tcx>, borrow_spans: UseSpans<'tcx>,
proper_span: Span, proper_span: Span,
explanation: BorrowExplanation, explanation: BorrowExplanation,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
debug!( debug!(
"report_temporary_value_does_not_live_long_enough(\ "report_temporary_value_does_not_live_long_enough(\
{:?}, {:?}, {:?}, {:?}\ {:?}, {:?}, {:?}, {:?}\
@ -1384,7 +1384,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
return_span: Span, return_span: Span,
category: ConstraintCategory, category: ConstraintCategory,
opt_place_desc: Option<&String>, opt_place_desc: Option<&String>,
) -> Option<DiagnosticBuilder<'cx, ErrorReported>> { ) -> Option<DiagnosticBuilder<'cx, ErrorGuaranteed>> {
let return_kind = match category { let return_kind = match category {
ConstraintCategory::Return(_) => "return", ConstraintCategory::Return(_) => "return",
ConstraintCategory::Yield => "yield", ConstraintCategory::Yield => "yield",
@ -1483,7 +1483,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
category: ConstraintCategory, category: ConstraintCategory,
constraint_span: Span, constraint_span: Span,
captured_var: &str, captured_var: &str,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let tcx = self.infcx.tcx; let tcx = self.infcx.tcx;
let args_span = use_span.args_or_use(); let args_span = use_span.args_or_use();
@ -1560,7 +1560,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
upvar_span: Span, upvar_span: Span,
upvar_name: &str, upvar_name: &str,
escape_span: Span, escape_span: Span,
) -> DiagnosticBuilder<'cx, ErrorReported> { ) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
let tcx = self.infcx.tcx; let tcx = self.infcx.tcx;
let (_, escapes_from) = tcx.article_and_description(self.mir_def_id().to_def_id()); let (_, escapes_from) = tcx.article_and_description(self.mir_def_id().to_def_id());

View file

@ -1,5 +1,5 @@
use rustc_const_eval::util::CallDesugaringKind; use rustc_const_eval::util::CallDesugaringKind;
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorReported}; use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::mir::*; use rustc_middle::mir::*;
use rustc_middle::ty; use rustc_middle::ty;
@ -271,7 +271,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
&mut self, &mut self,
place: Place<'tcx>, place: Place<'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'a, ErrorReported> { ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let description = if place.projection.len() == 1 { let description = if place.projection.len() == 1 {
format!("static item {}", self.describe_any_place(place.as_ref())) format!("static item {}", self.describe_any_place(place.as_ref()))
} else { } else {
@ -293,7 +293,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
deref_target_place: Place<'tcx>, deref_target_place: Place<'tcx>,
span: Span, span: Span,
use_spans: Option<UseSpans<'tcx>>, use_spans: Option<UseSpans<'tcx>>,
) -> DiagnosticBuilder<'a, ErrorReported> { ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
// Inspect the type of the content behind the // Inspect the type of the content behind the
// borrow to provide feedback about why this // borrow to provide feedback about why this
// was a move rather than a copy. // was a move rather than a copy.

View file

@ -1,6 +1,6 @@
//! Error reporting machinery for lifetime errors. //! Error reporting machinery for lifetime errors.
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorReported}; use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
use rustc_infer::infer::{ use rustc_infer::infer::{
error_reporting::nice_region_error::NiceRegionError, error_reporting::nice_region_error::NiceRegionError,
error_reporting::unexpected_hidden_region_diagnostic, NllRegionVariableOrigin, error_reporting::unexpected_hidden_region_diagnostic, NllRegionVariableOrigin,
@ -389,7 +389,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
&self, &self,
errci: &ErrorConstraintInfo, errci: &ErrorConstraintInfo,
kind: ReturnConstraint, kind: ReturnConstraint,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let ErrorConstraintInfo { outlived_fr, span, .. } = errci; let ErrorConstraintInfo { outlived_fr, span, .. } = errci;
let mut diag = self let mut diag = self
@ -469,7 +469,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
fn report_escaping_data_error( fn report_escaping_data_error(
&self, &self,
errci: &ErrorConstraintInfo, errci: &ErrorConstraintInfo,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let ErrorConstraintInfo { span, category, .. } = errci; let ErrorConstraintInfo { span, category, .. } = errci;
let fr_name_and_span = self.regioncx.get_var_name_and_span_for_region( let fr_name_and_span = self.regioncx.get_var_name_and_span_for_region(
@ -573,7 +573,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
fn report_general_error( fn report_general_error(
&self, &self,
errci: &ErrorConstraintInfo, errci: &ErrorConstraintInfo,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let ErrorConstraintInfo { let ErrorConstraintInfo {
fr, fr,
fr_is_local, fr_is_local,

View file

@ -19,7 +19,7 @@ extern crate tracing;
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::graph::dominators::Dominators; use rustc_data_structures::graph::dominators::Dominators;
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorReported}; use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId; use rustc_hir::def_id::LocalDefId;
use rustc_hir::Node; use rustc_hir::Node;
@ -178,7 +178,7 @@ fn do_mir_borrowck<'a, 'tcx>(
// Gather the upvars of a closure, if any. // Gather the upvars of a closure, if any.
let tables = tcx.typeck_opt_const_arg(def); let tables = tcx.typeck_opt_const_arg(def);
if let Some(ErrorReported) = tables.tainted_by_errors { if let Some(ErrorGuaranteed) = tables.tainted_by_errors {
infcx.set_tainted_by_errors(); infcx.set_tainted_by_errors();
errors.set_tainted_by_errors(); errors.set_tainted_by_errors();
} }
@ -2292,11 +2292,11 @@ mod error {
/// when errors in the map are being re-added to the error buffer so that errors with the /// when errors in the map are being re-added to the error buffer so that errors with the
/// same primary span come out in a consistent order. /// same primary span come out in a consistent order.
buffered_move_errors: buffered_move_errors:
BTreeMap<Vec<MoveOutIndex>, (PlaceRef<'tcx>, DiagnosticBuilder<'tcx, ErrorReported>)>, BTreeMap<Vec<MoveOutIndex>, (PlaceRef<'tcx>, DiagnosticBuilder<'tcx, ErrorGuaranteed>)>,
/// Diagnostics to be reported buffer. /// Diagnostics to be reported buffer.
buffered: Vec<Diagnostic>, buffered: Vec<Diagnostic>,
/// Set to Some if we emit an error during borrowck /// Set to Some if we emit an error during borrowck
tainted_by_errors: Option<ErrorReported>, tainted_by_errors: Option<ErrorGuaranteed>,
} }
impl BorrowckErrors<'_> { impl BorrowckErrors<'_> {
@ -2310,8 +2310,8 @@ mod error {
// FIXME(eddyb) this is a suboptimal API because `tainted_by_errors` is // FIXME(eddyb) this is a suboptimal API because `tainted_by_errors` is
// set before any emission actually happens (weakening the guarantee). // set before any emission actually happens (weakening the guarantee).
pub fn buffer_error(&mut self, t: DiagnosticBuilder<'_, ErrorReported>) { pub fn buffer_error(&mut self, t: DiagnosticBuilder<'_, ErrorGuaranteed>) {
self.tainted_by_errors = Some(ErrorReported {}); self.tainted_by_errors = Some(ErrorGuaranteed {});
t.buffer(&mut self.buffered); t.buffer(&mut self.buffered);
} }
@ -2320,12 +2320,12 @@ mod error {
} }
pub fn set_tainted_by_errors(&mut self) { pub fn set_tainted_by_errors(&mut self) {
self.tainted_by_errors = Some(ErrorReported {}); self.tainted_by_errors = Some(ErrorGuaranteed {});
} }
} }
impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
pub fn buffer_error(&mut self, t: DiagnosticBuilder<'_, ErrorReported>) { pub fn buffer_error(&mut self, t: DiagnosticBuilder<'_, ErrorGuaranteed>) {
self.errors.buffer_error(t); self.errors.buffer_error(t);
} }
@ -2336,7 +2336,7 @@ mod error {
pub fn buffer_move_error( pub fn buffer_move_error(
&mut self, &mut self,
move_out_indices: Vec<MoveOutIndex>, move_out_indices: Vec<MoveOutIndex>,
place_and_err: (PlaceRef<'tcx>, DiagnosticBuilder<'tcx, ErrorReported>), place_and_err: (PlaceRef<'tcx>, DiagnosticBuilder<'tcx, ErrorGuaranteed>),
) -> bool { ) -> bool {
if let Some((_, diag)) = if let Some((_, diag)) =
self.errors.buffered_move_errors.insert(move_out_indices, place_and_err) self.errors.buffered_move_errors.insert(move_out_indices, place_and_err)
@ -2349,7 +2349,7 @@ mod error {
} }
} }
pub fn emit_errors(&mut self) -> Option<ErrorReported> { pub fn emit_errors(&mut self) -> Option<ErrorGuaranteed> {
// Buffer any move errors that we collected and de-duplicated. // Buffer any move errors that we collected and de-duplicated.
for (_, (_, diag)) in std::mem::take(&mut self.errors.buffered_move_errors) { for (_, (_, diag)) in std::mem::take(&mut self.errors.buffered_move_errors) {
// We have already set tainted for this error, so just buffer it. // We have already set tainted for this error, so just buffer it.
@ -2374,7 +2374,7 @@ mod error {
pub fn has_move_error( pub fn has_move_error(
&self, &self,
move_out_indices: &[MoveOutIndex], move_out_indices: &[MoveOutIndex],
) -> Option<&(PlaceRef<'tcx>, DiagnosticBuilder<'cx, ErrorReported>)> { ) -> Option<&(PlaceRef<'tcx>, DiagnosticBuilder<'cx, ErrorGuaranteed>)> {
self.errors.buffered_move_errors.get(move_out_indices) self.errors.buffered_move_errors.get(move_out_indices)
} }
} }

View file

@ -1,7 +1,7 @@
//! Handling of `static`s, `const`s and promoted allocations //! Handling of `static`s, `const`s and promoted allocations
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::mir::interpret::{ use rustc_middle::mir::interpret::{
read_target_uint, AllocId, Allocation, ConstValue, ErrorHandled, GlobalAlloc, Scalar, read_target_uint, AllocId, Allocation, ConstValue, ErrorHandled, GlobalAlloc, Scalar,
@ -54,7 +54,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, '_>) -> bool {
{ {
all_constants_ok = false; all_constants_ok = false;
match err { match err {
ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => { ErrorHandled::Reported(ErrorGuaranteed) | ErrorHandled::Linted => {
fx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); fx.tcx.sess.span_err(constant.span, "erroneous constant encountered");
} }
ErrorHandled::TooGeneric => { ErrorHandled::TooGeneric => {

View file

@ -29,7 +29,7 @@ use std::cell::Cell;
use rustc_codegen_ssa::traits::CodegenBackend; use rustc_codegen_ssa::traits::CodegenBackend;
use rustc_codegen_ssa::CodegenResults; use rustc_codegen_ssa::CodegenResults;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_metadata::EncodedMetadata; use rustc_metadata::EncodedMetadata;
use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_session::config::OutputFilenames; use rustc_session::config::OutputFilenames;
@ -209,7 +209,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
ongoing_codegen: Box<dyn Any>, ongoing_codegen: Box<dyn Any>,
_sess: &Session, _sess: &Session,
_outputs: &OutputFilenames, _outputs: &OutputFilenames,
) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorReported> { ) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorGuaranteed> {
Ok(*ongoing_codegen Ok(*ongoing_codegen
.downcast::<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>)>() .downcast::<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>)>()
.unwrap()) .unwrap())
@ -220,7 +220,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
sess: &Session, sess: &Session,
codegen_results: CodegenResults, codegen_results: CodegenResults,
outputs: &OutputFilenames, outputs: &OutputFilenames,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
use rustc_codegen_ssa::back::link::link_binary; use rustc_codegen_ssa::back::link::link_binary;
link_binary::<crate::archive::ArArchiveBuilder<'_>>(sess, &codegen_results, outputs) link_binary::<crate::archive::ArArchiveBuilder<'_>>(sess, &codegen_results, outputs)

View file

@ -57,7 +57,7 @@ use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModul
use rustc_codegen_ssa::target_features::supported_target_features; use rustc_codegen_ssa::target_features::supported_target_features;
use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, ModuleBufferMethods, ThinBufferMethods, WriteBackendMethods}; use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, ModuleBufferMethods, ThinBufferMethods, WriteBackendMethods};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{ErrorReported, Handler}; use rustc_errors::{ErrorGuaranteed, Handler};
use rustc_metadata::EncodedMetadata; use rustc_metadata::EncodedMetadata;
use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
@ -93,7 +93,7 @@ impl CodegenBackend for GccCodegenBackend {
Box::new(res) Box::new(res)
} }
fn join_codegen(&self, ongoing_codegen: Box<dyn Any>, sess: &Session, _outputs: &OutputFilenames) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorReported> { fn join_codegen(&self, ongoing_codegen: Box<dyn Any>, sess: &Session, _outputs: &OutputFilenames) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorGuaranteed> {
let (codegen_results, work_products) = ongoing_codegen let (codegen_results, work_products) = ongoing_codegen
.downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<GccCodegenBackend>>() .downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<GccCodegenBackend>>()
.expect("Expected GccCodegenBackend's OngoingCodegen, found Box<Any>") .expect("Expected GccCodegenBackend's OngoingCodegen, found Box<Any>")
@ -102,7 +102,7 @@ impl CodegenBackend for GccCodegenBackend {
Ok((codegen_results, work_products)) Ok((codegen_results, work_products))
} }
fn link(&self, sess: &Session, codegen_results: CodegenResults, outputs: &OutputFilenames) -> Result<(), ErrorReported> { fn link(&self, sess: &Session, codegen_results: CodegenResults, outputs: &OutputFilenames) -> Result<(), ErrorGuaranteed> {
use rustc_codegen_ssa::back::link::link_binary; use rustc_codegen_ssa::back::link::link_binary;
link_binary::<crate::archive::ArArchiveBuilder<'_>>( link_binary::<crate::archive::ArArchiveBuilder<'_>>(

View file

@ -30,7 +30,7 @@ use rustc_codegen_ssa::traits::*;
use rustc_codegen_ssa::ModuleCodegen; use rustc_codegen_ssa::ModuleCodegen;
use rustc_codegen_ssa::{CodegenResults, CompiledModule}; use rustc_codegen_ssa::{CodegenResults, CompiledModule};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{ErrorReported, FatalError, Handler}; use rustc_errors::{ErrorGuaranteed, FatalError, Handler};
use rustc_metadata::EncodedMetadata; use rustc_metadata::EncodedMetadata;
use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_middle::ty::query::Providers; use rustc_middle::ty::query::Providers;
@ -352,7 +352,7 @@ impl CodegenBackend for LlvmCodegenBackend {
ongoing_codegen: Box<dyn Any>, ongoing_codegen: Box<dyn Any>,
sess: &Session, sess: &Session,
outputs: &OutputFilenames, outputs: &OutputFilenames,
) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorReported> { ) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorGuaranteed> {
let (codegen_results, work_products) = ongoing_codegen let (codegen_results, work_products) = ongoing_codegen
.downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<LlvmCodegenBackend>>() .downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<LlvmCodegenBackend>>()
.expect("Expected LlvmCodegenBackend's OngoingCodegen, found Box<Any>") .expect("Expected LlvmCodegenBackend's OngoingCodegen, found Box<Any>")
@ -373,7 +373,7 @@ impl CodegenBackend for LlvmCodegenBackend {
sess: &Session, sess: &Session,
codegen_results: CodegenResults, codegen_results: CodegenResults,
outputs: &OutputFilenames, outputs: &OutputFilenames,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
use crate::back::archive::LlvmArchiveBuilder; use crate::back::archive::LlvmArchiveBuilder;
use rustc_codegen_ssa::back::link::link_binary; use rustc_codegen_ssa::back::link::link_binary;

View file

@ -2,7 +2,7 @@ use rustc_arena::TypedArena;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
use rustc_data_structures::memmap::Mmap; use rustc_data_structures::memmap::Mmap;
use rustc_data_structures::temp_dir::MaybeTempDir; use rustc_data_structures::temp_dir::MaybeTempDir;
use rustc_errors::{ErrorReported, Handler}; use rustc_errors::{ErrorGuaranteed, Handler};
use rustc_fs_util::fix_windows_verbatim_for_gcc; use rustc_fs_util::fix_windows_verbatim_for_gcc;
use rustc_hir::def_id::CrateNum; use rustc_hir::def_id::CrateNum;
use rustc_middle::middle::dependency_format::Linkage; use rustc_middle::middle::dependency_format::Linkage;
@ -57,7 +57,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
sess: &'a Session, sess: &'a Session,
codegen_results: &CodegenResults, codegen_results: &CodegenResults,
outputs: &OutputFilenames, outputs: &OutputFilenames,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
let _timer = sess.timer("link_binary"); let _timer = sess.timer("link_binary");
let output_metadata = sess.opts.output_types.contains_key(&OutputType::Metadata); let output_metadata = sess.opts.output_types.contains_key(&OutputType::Metadata);
for &crate_type in sess.crate_types().iter() { for &crate_type in sess.crate_types().iter() {
@ -260,7 +260,7 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
flavor: RlibFlavor, flavor: RlibFlavor,
out_filename: &Path, out_filename: &Path,
tmpdir: &MaybeTempDir, tmpdir: &MaybeTempDir,
) -> Result<B, ErrorReported> { ) -> Result<B, ErrorGuaranteed> {
info!("preparing rlib to {:?}", out_filename); info!("preparing rlib to {:?}", out_filename);
let lib_search_paths = archive_search_paths(sess); let lib_search_paths = archive_search_paths(sess);
@ -407,7 +407,7 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
fn collate_raw_dylibs( fn collate_raw_dylibs(
sess: &Session, sess: &Session,
used_libraries: &[NativeLib], used_libraries: &[NativeLib],
) -> Result<Vec<(String, Vec<DllImport>)>, ErrorReported> { ) -> Result<Vec<(String, Vec<DllImport>)>, ErrorGuaranteed> {
// Use index maps to preserve original order of imports and libraries. // Use index maps to preserve original order of imports and libraries.
let mut dylib_table = FxIndexMap::<String, FxIndexMap<Symbol, &DllImport>>::default(); let mut dylib_table = FxIndexMap::<String, FxIndexMap<Symbol, &DllImport>>::default();
@ -459,7 +459,7 @@ fn link_staticlib<'a, B: ArchiveBuilder<'a>>(
codegen_results: &CodegenResults, codegen_results: &CodegenResults,
out_filename: &Path, out_filename: &Path,
tempdir: &MaybeTempDir, tempdir: &MaybeTempDir,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
let mut ab = let mut ab =
link_rlib::<B>(sess, codegen_results, RlibFlavor::StaticlibBase, out_filename, tempdir)?; link_rlib::<B>(sess, codegen_results, RlibFlavor::StaticlibBase, out_filename, tempdir)?;
let mut all_native_libs = vec![]; let mut all_native_libs = vec![];

View file

@ -1,5 +1,5 @@
use crate::traits::*; use crate::traits::*;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_middle::mir; use rustc_middle::mir;
use rustc_middle::mir::interpret::ErrorHandled; use rustc_middle::mir::interpret::ErrorHandled;
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, TyAndLayout}; use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, TyAndLayout};
@ -191,7 +191,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
all_consts_ok = false; all_consts_ok = false;
match err { match err {
// errored or at least linted // errored or at least linted
ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => {} ErrorHandled::Reported(ErrorGuaranteed) | ErrorHandled::Linted => {}
ErrorHandled::TooGeneric => { ErrorHandled::TooGeneric => {
span_bug!(const_.span, "codgen encountered polymorphic constant: {:?}", err) span_bug!(const_.span, "codgen encountered polymorphic constant: {:?}", err)
} }

View file

@ -5,7 +5,7 @@ use crate::{CodegenResults, ModuleCodegen};
use rustc_ast::expand::allocator::AllocatorKind; use rustc_ast::expand::allocator::AllocatorKind;
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_metadata::EncodedMetadata; use rustc_metadata::EncodedMetadata;
use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf, TyAndLayout}; use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf, TyAndLayout};
@ -98,7 +98,7 @@ pub trait CodegenBackend {
ongoing_codegen: Box<dyn Any>, ongoing_codegen: Box<dyn Any>,
sess: &Session, sess: &Session,
outputs: &OutputFilenames, outputs: &OutputFilenames,
) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorReported>; ) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorGuaranteed>;
/// This is called on the returned `Box<dyn Any>` from `join_codegen` /// This is called on the returned `Box<dyn Any>` from `join_codegen`
/// ///
@ -110,7 +110,7 @@ pub trait CodegenBackend {
sess: &Session, sess: &Session,
codegen_results: CodegenResults, codegen_results: CodegenResults,
outputs: &OutputFilenames, outputs: &OutputFilenames,
) -> Result<(), ErrorReported>; ) -> Result<(), ErrorGuaranteed>;
} }
pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Send + Sync { pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Send + Sync {

View file

@ -1,4 +1,4 @@
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;
use rustc_middle::mir; use rustc_middle::mir;
use rustc_middle::ty::{self, Ty}; use rustc_middle::ty::{self, Ty};
@ -251,7 +251,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
rustc_span::DUMMY_SP, rustc_span::DUMMY_SP,
"This is likely a const item that is missing from its impl", "This is likely a const item that is missing from its impl",
); );
throw_inval!(AlreadyReported(ErrorReported {})); throw_inval!(AlreadyReported(ErrorGuaranteed {}));
} else { } else {
let path = ecx.tcx.def_path_str(def.did); let path = ecx.tcx.def_path_str(def.did);
Err(ConstEvalErrKind::NeedsRfc(format!("calling extern function `{}`", path)) Err(ConstEvalErrKind::NeedsRfc(format!("calling extern function `{}`", path))

View file

@ -16,7 +16,7 @@
use super::validity::RefTracking; use super::validity::RefTracking;
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_middle::mir::interpret::InterpResult; use rustc_middle::mir::interpret::InterpResult;
use rustc_middle::ty::{self, layout::TyAndLayout, Ty}; use rustc_middle::ty::{self, layout::TyAndLayout, Ty};
@ -297,7 +297,7 @@ pub fn intern_const_alloc_recursive<
ecx: &mut InterpCx<'mir, 'tcx, M>, ecx: &mut InterpCx<'mir, 'tcx, M>,
intern_kind: InternKind, intern_kind: InternKind,
ret: &MPlaceTy<'tcx>, ret: &MPlaceTy<'tcx>,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
let tcx = ecx.tcx; let tcx = ecx.tcx;
let base_intern_mode = match intern_kind { let base_intern_mode = match intern_kind {
InternKind::Static(mutbl) => InternMode::Static(mutbl), InternKind::Static(mutbl) => InternMode::Static(mutbl),
@ -402,7 +402,7 @@ pub fn intern_const_alloc_recursive<
// Codegen does not like dangling pointers, and generally `tcx` assumes that // Codegen does not like dangling pointers, and generally `tcx` assumes that
// all allocations referenced anywhere actually exist. So, make sure we error here. // all allocations referenced anywhere actually exist. So, make sure we error here.
ecx.tcx.sess.span_err(ecx.tcx.span, "encountered dangling pointer in final constant"); ecx.tcx.sess.span_err(ecx.tcx.span, "encountered dangling pointer in final constant");
return Err(ErrorReported); return Err(ErrorGuaranteed);
} else if ecx.tcx.get_global_alloc(alloc_id).is_none() { } else if ecx.tcx.get_global_alloc(alloc_id).is_none() {
// We have hit an `AllocId` that is neither in local or global memory and isn't // We have hit an `AllocId` that is neither in local or global memory and isn't
// marked as dangling by local memory. That should be impossible. // marked as dangling by local memory. That should be impossible.

View file

@ -4,7 +4,7 @@
use std::convert::TryFrom; use std::convert::TryFrom;
use std::fmt::Write; use std::fmt::Write;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir::def::Namespace; use rustc_hir::def::Namespace;
use rustc_macros::HashStable; use rustc_macros::HashStable;
use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt, TyAndLayout}; use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt, TyAndLayout};
@ -565,7 +565,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> { ) -> InterpResult<'tcx, OpTy<'tcx, M::PointerTag>> {
match val.val() { match val.val() {
ty::ConstKind::Param(_) | ty::ConstKind::Bound(..) => throw_inval!(TooGeneric), ty::ConstKind::Param(_) | ty::ConstKind::Bound(..) => throw_inval!(TooGeneric),
ty::ConstKind::Error(_) => throw_inval!(AlreadyReported(ErrorReported)), ty::ConstKind::Error(_) => throw_inval!(AlreadyReported(ErrorGuaranteed)),
ty::ConstKind::Unevaluated(uv) => { ty::ConstKind::Unevaluated(uv) => {
let instance = self.resolve(uv.def, uv.substs)?; let instance = self.resolve(uv.def, uv.substs)?;
Ok(self.eval_to_allocation(GlobalId { instance, promoted: uv.promoted })?.into()) Ok(self.eval_to_allocation(GlobalId { instance, promoted: uv.promoted })?.into())

View file

@ -1,6 +1,6 @@
//! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations. //! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations.
use rustc_errors::{Applicability, Diagnostic, ErrorReported}; use rustc_errors::{Applicability, Diagnostic, ErrorGuaranteed};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_index::bit_set::BitSet; use rustc_index::bit_set::BitSet;
@ -121,7 +121,7 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
fn in_return_place( fn in_return_place(
&mut self, &mut self,
ccx: &'mir ConstCx<'mir, 'tcx>, ccx: &'mir ConstCx<'mir, 'tcx>,
tainted_by_errors: Option<ErrorReported>, tainted_by_errors: Option<ErrorGuaranteed>,
) -> ConstQualifs { ) -> ConstQualifs {
// Find the `Return` terminator if one exists. // Find the `Return` terminator if one exists.
// //
@ -181,7 +181,7 @@ pub struct Checker<'mir, 'tcx> {
/// A set that stores for each local whether it has a `StorageDead` for it somewhere. /// A set that stores for each local whether it has a `StorageDead` for it somewhere.
local_has_storage_dead: Option<BitSet<Local>>, local_has_storage_dead: Option<BitSet<Local>>,
error_emitted: Option<ErrorReported>, error_emitted: Option<ErrorGuaranteed>,
secondary_errors: Vec<Diagnostic>, secondary_errors: Vec<Diagnostic>,
} }
@ -329,7 +329,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
match op.importance() { match op.importance() {
ops::DiagnosticImportance::Primary => { ops::DiagnosticImportance::Primary => {
self.error_emitted = Some(ErrorReported); self.error_emitted = Some(ErrorGuaranteed);
err.emit(); err.emit();
} }

View file

@ -1,6 +1,6 @@
//! Concrete error types for all operations which may be invalid in a certain const context. //! Concrete error types for all operations which may be invalid in a certain const context.
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorReported}; use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::infer::TyCtxtInferExt;
@ -51,7 +51,7 @@ pub trait NonConstOp<'tcx>: std::fmt::Debug {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported>; ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>;
} }
#[derive(Debug)] #[derive(Debug)]
@ -69,7 +69,7 @@ impl<'tcx> NonConstOp<'tcx> for FloatingPointOp {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
feature_err( feature_err(
&ccx.tcx.sess.parse_sess, &ccx.tcx.sess.parse_sess,
sym::const_fn_floating_point_arithmetic, sym::const_fn_floating_point_arithmetic,
@ -87,7 +87,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallIndirect {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
ccx.tcx.sess.struct_span_err(span, "function pointers are not allowed in const fn") ccx.tcx.sess.struct_span_err(span, "function pointers are not allowed in const fn")
} }
} }
@ -107,7 +107,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
_: Span, _: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let FnCallNonConst { caller, callee, substs, span, from_hir_call } = *self; let FnCallNonConst { caller, callee, substs, span, from_hir_call } = *self;
let ConstCx { tcx, param_env, .. } = *ccx; let ConstCx { tcx, param_env, .. } = *ccx;
@ -332,7 +332,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallUnstable {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let FnCallUnstable(def_id, feature) = *self; let FnCallUnstable(def_id, feature) = *self;
let mut err = ccx.tcx.sess.struct_span_err( let mut err = ccx.tcx.sess.struct_span_err(
@ -370,7 +370,7 @@ impl<'tcx> NonConstOp<'tcx> for FnPtrCast {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
feature_err( feature_err(
&ccx.tcx.sess.parse_sess, &ccx.tcx.sess.parse_sess,
sym::const_fn_fn_ptr_basics, sym::const_fn_fn_ptr_basics,
@ -395,7 +395,7 @@ impl<'tcx> NonConstOp<'tcx> for Generator {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let msg = format!("{}s are not allowed in {}s", self.0, ccx.const_kind()); let msg = format!("{}s are not allowed in {}s", self.0, ccx.const_kind());
if let hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) = self.0 { if let hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) = self.0 {
feature_err(&ccx.tcx.sess.parse_sess, sym::const_async_blocks, span, &msg) feature_err(&ccx.tcx.sess.parse_sess, sym::const_async_blocks, span, &msg)
@ -412,7 +412,7 @@ impl<'tcx> NonConstOp<'tcx> for HeapAllocation {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = struct_span_err!( let mut err = struct_span_err!(
ccx.tcx.sess, ccx.tcx.sess,
span, span,
@ -440,7 +440,7 @@ impl<'tcx> NonConstOp<'tcx> for InlineAsm {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
struct_span_err!( struct_span_err!(
ccx.tcx.sess, ccx.tcx.sess,
span, span,
@ -460,7 +460,7 @@ impl<'tcx> NonConstOp<'tcx> for LiveDrop {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = struct_span_err!( let mut err = struct_span_err!(
ccx.tcx.sess, ccx.tcx.sess,
span, span,
@ -492,7 +492,7 @@ impl<'tcx> NonConstOp<'tcx> for TransientCellBorrow {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
feature_err( feature_err(
&ccx.tcx.sess.parse_sess, &ccx.tcx.sess.parse_sess,
sym::const_refs_to_cell, sym::const_refs_to_cell,
@ -512,7 +512,7 @@ impl<'tcx> NonConstOp<'tcx> for CellBorrow {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = struct_span_err!( let mut err = struct_span_err!(
ccx.tcx.sess, ccx.tcx.sess,
span, span,
@ -563,7 +563,7 @@ impl<'tcx> NonConstOp<'tcx> for MutBorrow {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let raw = match self.0 { let raw = match self.0 {
hir::BorrowKind::Raw => "raw ", hir::BorrowKind::Raw => "raw ",
hir::BorrowKind::Ref => "", hir::BorrowKind::Ref => "",
@ -606,7 +606,7 @@ impl<'tcx> NonConstOp<'tcx> for TransientMutBorrow {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let raw = match self.0 { let raw = match self.0 {
hir::BorrowKind::Raw => "raw ", hir::BorrowKind::Raw => "raw ",
hir::BorrowKind::Ref => "", hir::BorrowKind::Ref => "",
@ -637,7 +637,7 @@ impl<'tcx> NonConstOp<'tcx> for MutDeref {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
feature_err( feature_err(
&ccx.tcx.sess.parse_sess, &ccx.tcx.sess.parse_sess,
sym::const_mut_refs, sym::const_mut_refs,
@ -655,7 +655,7 @@ impl<'tcx> NonConstOp<'tcx> for PanicNonStr {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
ccx.tcx.sess.struct_span_err( ccx.tcx.sess.struct_span_err(
span, span,
"argument to `panic!()` in a const context must have type `&str`", "argument to `panic!()` in a const context must have type `&str`",
@ -673,7 +673,7 @@ impl<'tcx> NonConstOp<'tcx> for RawPtrComparison {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = ccx let mut err = ccx
.tcx .tcx
.sess .sess
@ -697,7 +697,7 @@ impl<'tcx> NonConstOp<'tcx> for RawMutPtrDeref {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
feature_err( feature_err(
&ccx.tcx.sess.parse_sess, &ccx.tcx.sess.parse_sess,
sym::const_mut_refs, sym::const_mut_refs,
@ -717,7 +717,7 @@ impl<'tcx> NonConstOp<'tcx> for RawPtrToIntCast {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = ccx let mut err = ccx
.tcx .tcx
.sess .sess
@ -746,7 +746,7 @@ impl<'tcx> NonConstOp<'tcx> for StaticAccess {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = struct_span_err!( let mut err = struct_span_err!(
ccx.tcx.sess, ccx.tcx.sess,
span, span,
@ -776,7 +776,7 @@ impl<'tcx> NonConstOp<'tcx> for ThreadLocalAccess {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
struct_span_err!( struct_span_err!(
ccx.tcx.sess, ccx.tcx.sess,
span, span,
@ -811,7 +811,7 @@ pub mod ty {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
feature_err( feature_err(
&ccx.tcx.sess.parse_sess, &ccx.tcx.sess.parse_sess,
sym::const_mut_refs, sym::const_mut_refs,
@ -845,7 +845,7 @@ pub mod ty {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
feature_err( feature_err(
&ccx.tcx.sess.parse_sess, &ccx.tcx.sess.parse_sess,
sym::const_fn_fn_ptr_basics, sym::const_fn_fn_ptr_basics,
@ -866,7 +866,7 @@ pub mod ty {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
feature_err( feature_err(
&ccx.tcx.sess.parse_sess, &ccx.tcx.sess.parse_sess,
sym::const_impl_trait, sym::const_impl_trait,
@ -900,7 +900,7 @@ pub mod ty {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = feature_err( let mut err = feature_err(
&ccx.tcx.sess.parse_sess, &ccx.tcx.sess.parse_sess,
sym::const_fn_trait_bound, sym::const_fn_trait_bound,
@ -943,7 +943,7 @@ pub mod ty {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = feature_err( let mut err = feature_err(
&ccx.tcx.sess.parse_sess, &ccx.tcx.sess.parse_sess,
sym::const_fn_trait_bound, sym::const_fn_trait_bound,
@ -974,7 +974,7 @@ pub mod ty {
&self, &self,
ccx: &ConstCx<'_, 'tcx>, ccx: &ConstCx<'_, 'tcx>,
span: Span, span: Span,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
feature_err( feature_err(
&ccx.tcx.sess.parse_sess, &ccx.tcx.sess.parse_sess,
sym::const_trait_bound_opt_out, sym::const_trait_bound_opt_out,

View file

@ -2,7 +2,7 @@
//! //!
//! See the `Qualif` trait for more info. //! See the `Qualif` trait for more info.
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::infer::TyCtxtInferExt;
use rustc_infer::traits::TraitEngine; use rustc_infer::traits::TraitEngine;
use rustc_middle::mir::*; use rustc_middle::mir::*;
@ -17,7 +17,7 @@ use super::ConstCx;
pub fn in_any_value_of_ty<'tcx>( pub fn in_any_value_of_ty<'tcx>(
cx: &ConstCx<'_, 'tcx>, cx: &ConstCx<'_, 'tcx>,
ty: Ty<'tcx>, ty: Ty<'tcx>,
tainted_by_errors: Option<ErrorReported>, tainted_by_errors: Option<ErrorGuaranteed>,
) -> ConstQualifs { ) -> ConstQualifs {
ConstQualifs { ConstQualifs {
has_mut_interior: HasMutInterior::in_any_value_of_ty(cx, ty), has_mut_interior: HasMutInterior::in_any_value_of_ty(cx, ty),

View file

@ -21,7 +21,7 @@ use rustc_codegen_ssa::{traits::CodegenBackend, CodegenResults};
use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry}; use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
use rustc_data_structures::sync::SeqCst; use rustc_data_structures::sync::SeqCst;
use rustc_errors::registry::{InvalidErrorCode, Registry}; use rustc_errors::registry::{InvalidErrorCode, Registry};
use rustc_errors::{ErrorReported, PResult}; use rustc_errors::{ErrorGuaranteed, PResult};
use rustc_feature::find_gated_cfg; use rustc_feature::find_gated_cfg;
use rustc_interface::util::{self, collect_crate_types, get_codegen_backend}; use rustc_interface::util::{self, collect_crate_types, get_codegen_backend};
use rustc_interface::{interface, Queries}; use rustc_interface::{interface, Queries};
@ -73,7 +73,7 @@ const ICE_REPORT_COMPILER_FLAGS_EXCLUDE: &[&str] = &["metadata", "extra-filename
const ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE: &[&str] = &["incremental"]; const ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE: &[&str] = &["incremental"];
pub fn abort_on_err<T>(result: Result<T, ErrorReported>, sess: &Session) -> T { pub fn abort_on_err<T>(result: Result<T, ErrorGuaranteed>, sess: &Session) -> T {
match result { match result {
Err(..) => { Err(..) => {
sess.abort_if_errors(); sess.abort_if_errors();
@ -235,7 +235,7 @@ fn run_compiler(
}; };
match make_input(config.opts.error_format, &matches.free) { match make_input(config.opts.error_format, &matches.free) {
Err(ErrorReported) => return Err(ErrorReported), Err(ErrorGuaranteed) => return Err(ErrorGuaranteed),
Ok(Some((input, input_file_path))) => { Ok(Some((input, input_file_path))) => {
config.input = input; config.input = input;
config.input_path = input_file_path; config.input_path = input_file_path;
@ -457,7 +457,7 @@ fn make_output(matches: &getopts::Matches) -> (Option<PathBuf>, Option<PathBuf>)
fn make_input( fn make_input(
error_format: ErrorOutputType, error_format: ErrorOutputType,
free_matches: &[String], free_matches: &[String],
) -> Result<Option<(Input, Option<PathBuf>)>, ErrorReported> { ) -> Result<Option<(Input, Option<PathBuf>)>, ErrorGuaranteed> {
if free_matches.len() == 1 { if free_matches.len() == 1 {
let ifile = &free_matches[0]; let ifile = &free_matches[0];
if ifile == "-" { if ifile == "-" {
@ -469,7 +469,7 @@ fn make_input(
error_format, error_format,
"couldn't read from stdin, as it did not contain valid UTF-8", "couldn't read from stdin, as it did not contain valid UTF-8",
); );
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
if let Ok(path) = env::var("UNSTABLE_RUSTDOC_TEST_PATH") { if let Ok(path) = env::var("UNSTABLE_RUSTDOC_TEST_PATH") {
let line = env::var("UNSTABLE_RUSTDOC_TEST_LINE").expect( let line = env::var("UNSTABLE_RUSTDOC_TEST_LINE").expect(
@ -1125,10 +1125,10 @@ fn extra_compiler_flags() -> Option<(Vec<String>, bool)> {
/// The compiler currently unwinds with a special sentinel value to abort /// The compiler currently unwinds with a special sentinel value to abort
/// compilation on fatal errors. This function catches that sentinel and turns /// compilation on fatal errors. This function catches that sentinel and turns
/// the panic into a `Result` instead. /// the panic into a `Result` instead.
pub fn catch_fatal_errors<F: FnOnce() -> R, R>(f: F) -> Result<R, ErrorReported> { pub fn catch_fatal_errors<F: FnOnce() -> R, R>(f: F) -> Result<R, ErrorGuaranteed> {
catch_unwind(panic::AssertUnwindSafe(f)).map_err(|value| { catch_unwind(panic::AssertUnwindSafe(f)).map_err(|value| {
if value.is::<rustc_errors::FatalErrorMarker>() { if value.is::<rustc_errors::FatalErrorMarker>() {
ErrorReported ErrorGuaranteed
} else { } else {
panic::resume_unwind(value); panic::resume_unwind(value);
} }

View file

@ -2,7 +2,7 @@
use rustc_ast as ast; use rustc_ast as ast;
use rustc_ast_pretty::pprust; use rustc_ast_pretty::pprust;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir_pretty as pprust_hir; use rustc_hir_pretty as pprust_hir;
use rustc_middle::hir::map as hir_map; use rustc_middle::hir::map as hir_map;
@ -479,7 +479,7 @@ fn print_with_analysis(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
ppm: PpMode, ppm: PpMode,
ofile: Option<&Path>, ofile: Option<&Path>,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
tcx.analysis(())?; tcx.analysis(())?;
let out = match ppm { let out = match ppm {
Mir => { Mir => {

View file

@ -1,4 +1,4 @@
use crate::{Diagnostic, DiagnosticId, DiagnosticStyledString, ErrorReported}; use crate::{Diagnostic, DiagnosticId, DiagnosticStyledString, ErrorGuaranteed};
use crate::{Handler, Level, StashKey}; use crate::{Handler, Level, StashKey};
use rustc_lint_defs::Applicability; use rustc_lint_defs::Applicability;
@ -96,7 +96,7 @@ mod sealed_level_is_error {
impl IsError<{ Level::Error { lint: false } }> for () {} impl IsError<{ Level::Error { lint: false } }> for () {}
} }
impl<'a> DiagnosticBuilder<'a, ErrorReported> { impl<'a> DiagnosticBuilder<'a, ErrorGuaranteed> {
/// Convenience function for internal use, clients should use one of the /// Convenience function for internal use, clients should use one of the
/// `struct_*` methods on [`Handler`]. /// `struct_*` methods on [`Handler`].
crate fn new_guaranteeing_error<const L: Level>(handler: &'a Handler, message: &str) -> Self crate fn new_guaranteeing_error<const L: Level>(handler: &'a Handler, message: &str) -> Self
@ -120,8 +120,8 @@ impl<'a> DiagnosticBuilder<'a, ErrorReported> {
} }
} }
// FIXME(eddyb) make `ErrorReported` impossible to create outside `.emit()`. // FIXME(eddyb) make `ErrorGuaranteed` impossible to create outside `.emit()`.
impl EmissionGuarantee for ErrorReported { impl EmissionGuarantee for ErrorGuaranteed {
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self { fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
match db.inner.state { match db.inner.state {
// First `.emit()` call, the `&Handler` is still available. // First `.emit()` call, the `&Handler` is still available.
@ -136,10 +136,10 @@ impl EmissionGuarantee for ErrorReported {
assert!( assert!(
db.inner.diagnostic.is_error(), db.inner.diagnostic.is_error(),
"emitted non-error ({:?}) diagnostic \ "emitted non-error ({:?}) diagnostic \
from `DiagnosticBuilder<ErrorReported>`", from `DiagnosticBuilder<ErrorGuaranteed>`",
db.inner.diagnostic.level, db.inner.diagnostic.level,
); );
ErrorReported ErrorGuaranteed
} }
// `.emit()` was previously called, disallowed from repeating it, // `.emit()` was previously called, disallowed from repeating it,
// but can take advantage of the previous `.emit()`'s guarantee // but can take advantage of the previous `.emit()`'s guarantee
@ -150,11 +150,11 @@ impl EmissionGuarantee for ErrorReported {
// can be overwritten with a new one, thanks to `DerefMut`. // can be overwritten with a new one, thanks to `DerefMut`.
assert!( assert!(
db.inner.diagnostic.is_error(), db.inner.diagnostic.is_error(),
"`DiagnosticBuilder<ErrorReported>`'s diagnostic \ "`DiagnosticBuilder<ErrorGuaranteed>`'s diagnostic \
became non-error ({:?}), after original `.emit()`", became non-error ({:?}), after original `.emit()`",
db.inner.diagnostic.level, db.inner.diagnostic.level,
); );
ErrorReported ErrorGuaranteed
} }
} }
} }
@ -182,7 +182,7 @@ impl<'a> DiagnosticBuilder<'a, ()> {
} }
} }
// FIXME(eddyb) should there be a `Option<ErrorReported>` impl as well? // FIXME(eddyb) should there be a `Option<ErrorGuaranteed>` impl as well?
impl EmissionGuarantee for () { impl EmissionGuarantee for () {
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self { fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
match db.inner.state { match db.inner.state {

View file

@ -54,7 +54,7 @@ mod snippet;
mod styled_buffer; mod styled_buffer;
pub use snippet::Style; pub use snippet::Style;
pub type PResult<'a, T> = Result<T, DiagnosticBuilder<'a, ErrorReported>>; pub type PResult<'a, T> = Result<T, DiagnosticBuilder<'a, ErrorGuaranteed>>;
// `PResult` is used a lot. Make sure it doesn't unintentionally get bigger. // `PResult` is used a lot. Make sure it doesn't unintentionally get bigger.
// (See also the comment on `DiagnosticBuilder`'s `diagnostic` field.) // (See also the comment on `DiagnosticBuilder`'s `diagnostic` field.)
@ -682,7 +682,7 @@ impl Handler {
&self, &self,
span: impl Into<MultiSpan>, span: impl Into<MultiSpan>,
msg: &str, msg: &str,
) -> DiagnosticBuilder<'_, ErrorReported> { ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut result = self.struct_err(msg); let mut result = self.struct_err(msg);
result.set_span(span); result.set_span(span);
result result
@ -694,7 +694,7 @@ impl Handler {
span: impl Into<MultiSpan>, span: impl Into<MultiSpan>,
msg: &str, msg: &str,
code: DiagnosticId, code: DiagnosticId,
) -> DiagnosticBuilder<'_, ErrorReported> { ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut result = self.struct_span_err(span, msg); let mut result = self.struct_span_err(span, msg);
result.code(code); result.code(code);
result result
@ -702,7 +702,7 @@ impl Handler {
/// Construct a builder at the `Error` level with the `msg`. /// Construct a builder at the `Error` level with the `msg`.
// FIXME: This method should be removed (every error should have an associated error code). // FIXME: This method should be removed (every error should have an associated error code).
pub fn struct_err(&self, msg: &str) -> DiagnosticBuilder<'_, ErrorReported> { pub fn struct_err(&self, msg: &str) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
DiagnosticBuilder::new_guaranteeing_error::<{ Level::Error { lint: false } }>(self, msg) DiagnosticBuilder::new_guaranteeing_error::<{ Level::Error { lint: false } }>(self, msg)
} }
@ -717,7 +717,7 @@ impl Handler {
&self, &self,
msg: &str, msg: &str,
code: DiagnosticId, code: DiagnosticId,
) -> DiagnosticBuilder<'_, ErrorReported> { ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut result = self.struct_err(msg); let mut result = self.struct_err(msg);
result.code(code); result.code(code);
result result
@ -728,7 +728,7 @@ impl Handler {
&self, &self,
span: impl Into<MultiSpan>, span: impl Into<MultiSpan>,
msg: &str, msg: &str,
) -> DiagnosticBuilder<'_, ErrorReported> { ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut result = self.struct_fatal(msg); let mut result = self.struct_fatal(msg);
result.set_span(span); result.set_span(span);
result result
@ -740,14 +740,14 @@ impl Handler {
span: impl Into<MultiSpan>, span: impl Into<MultiSpan>,
msg: &str, msg: &str,
code: DiagnosticId, code: DiagnosticId,
) -> DiagnosticBuilder<'_, ErrorReported> { ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut result = self.struct_span_fatal(span, msg); let mut result = self.struct_span_fatal(span, msg);
result.code(code); result.code(code);
result result
} }
/// Construct a builder at the `Error` level with the `msg`. /// Construct a builder at the `Error` level with the `msg`.
pub fn struct_fatal(&self, msg: &str) -> DiagnosticBuilder<'_, ErrorReported> { pub fn struct_fatal(&self, msg: &str) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
DiagnosticBuilder::new_guaranteeing_error::<{ Level::Fatal }>(self, msg) DiagnosticBuilder::new_guaranteeing_error::<{ Level::Fatal }>(self, msg)
} }
@ -1343,6 +1343,6 @@ pub fn add_elided_lifetime_in_path_suggestion(
// Useful type to use with `Result<>` indicate that an error has already // Useful type to use with `Result<>` indicate that an error has already
// been reported to the user, so no need to continue checking. // been reported to the user, so no need to continue checking.
#[derive(Clone, Copy, Debug, Encodable, Decodable, Hash, PartialEq, Eq)] #[derive(Clone, Copy, Debug, Encodable, Decodable, Hash, PartialEq, Eq)]
pub struct ErrorReported; pub struct ErrorGuaranteed;
rustc_data_structures::impl_stable_hash_via_hash!(ErrorReported); rustc_data_structures::impl_stable_hash_via_hash!(ErrorGuaranteed);

View file

@ -10,7 +10,7 @@ use rustc_ast::{self as ast, AstLike, Attribute, Item, NodeId, PatKind};
use rustc_attr::{self as attr, Deprecation, Stability}; use rustc_attr::{self as attr, Deprecation, Stability};
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::{self, Lrc}; use rustc_data_structures::sync::{self, Lrc};
use rustc_errors::{Applicability, DiagnosticBuilder, ErrorReported, PResult}; use rustc_errors::{Applicability, DiagnosticBuilder, ErrorGuaranteed, PResult};
use rustc_lint_defs::builtin::PROC_MACRO_BACK_COMPAT; use rustc_lint_defs::builtin::PROC_MACRO_BACK_COMPAT;
use rustc_lint_defs::BuiltinLintDiagnostics; use rustc_lint_defs::BuiltinLintDiagnostics;
use rustc_parse::{self, nt_to_tokenstream, parser, MACRO_ARGUMENTS}; use rustc_parse::{self, nt_to_tokenstream, parser, MACRO_ARGUMENTS};
@ -275,7 +275,7 @@ pub trait ProcMacro {
ecx: &'cx mut ExtCtxt<'_>, ecx: &'cx mut ExtCtxt<'_>,
span: Span, span: Span,
ts: TokenStream, ts: TokenStream,
) -> Result<TokenStream, ErrorReported>; ) -> Result<TokenStream, ErrorGuaranteed>;
} }
impl<F> ProcMacro for F impl<F> ProcMacro for F
@ -287,7 +287,7 @@ where
_ecx: &'cx mut ExtCtxt<'_>, _ecx: &'cx mut ExtCtxt<'_>,
_span: Span, _span: Span,
ts: TokenStream, ts: TokenStream,
) -> Result<TokenStream, ErrorReported> { ) -> Result<TokenStream, ErrorGuaranteed> {
// FIXME setup implicit context in TLS before calling self. // FIXME setup implicit context in TLS before calling self.
Ok(self(ts)) Ok(self(ts))
} }
@ -300,7 +300,7 @@ pub trait AttrProcMacro {
span: Span, span: Span,
annotation: TokenStream, annotation: TokenStream,
annotated: TokenStream, annotated: TokenStream,
) -> Result<TokenStream, ErrorReported>; ) -> Result<TokenStream, ErrorGuaranteed>;
} }
impl<F> AttrProcMacro for F impl<F> AttrProcMacro for F
@ -313,7 +313,7 @@ where
_span: Span, _span: Span,
annotation: TokenStream, annotation: TokenStream,
annotated: TokenStream, annotated: TokenStream,
) -> Result<TokenStream, ErrorReported> { ) -> Result<TokenStream, ErrorGuaranteed> {
// FIXME setup implicit context in TLS before calling self. // FIXME setup implicit context in TLS before calling self.
Ok(self(annotation, annotated)) Ok(self(annotation, annotated))
} }
@ -1076,7 +1076,7 @@ impl<'a> ExtCtxt<'a> {
&self, &self,
sp: S, sp: S,
msg: &str, msg: &str,
) -> DiagnosticBuilder<'a, ErrorReported> { ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
self.sess.parse_sess.span_diagnostic.struct_span_err(sp, msg) self.sess.parse_sess.span_diagnostic.struct_span_err(sp, msg)
} }
@ -1174,7 +1174,7 @@ pub fn expr_to_spanned_string<'a>(
cx: &'a mut ExtCtxt<'_>, cx: &'a mut ExtCtxt<'_>,
expr: P<ast::Expr>, expr: P<ast::Expr>,
err_msg: &str, err_msg: &str,
) -> Result<(Symbol, ast::StrStyle, Span), Option<(DiagnosticBuilder<'a, ErrorReported>, bool)>> { ) -> Result<(Symbol, ast::StrStyle, Span), Option<(DiagnosticBuilder<'a, ErrorGuaranteed>, bool)>> {
// Perform eager expansion on the expression. // Perform eager expansion on the expression.
// We want to be able to handle e.g., `concat!("foo", "bar")`. // We want to be able to handle e.g., `concat!("foo", "bar")`.
let expr = cx.expander().fully_expand_fragment(AstFragment::Expr(expr)).make_expr(); let expr = cx.expander().fully_expand_fragment(AstFragment::Expr(expr)).make_expr();

View file

@ -62,7 +62,7 @@ crate fn annotate_err_with_kind(err: &mut Diagnostic, kind: AstFragmentKind, spa
} }
fn emit_frag_parse_err( fn emit_frag_parse_err(
mut e: DiagnosticBuilder<'_, rustc_errors::ErrorReported>, mut e: DiagnosticBuilder<'_, rustc_errors::ErrorGuaranteed>,
parser: &Parser<'_>, parser: &Parser<'_>,
orig_parser: &mut Parser<'_>, orig_parser: &mut Parser<'_>,
site_span: Span, site_span: Span,

View file

@ -1,7 +1,7 @@
use crate::base::ModuleData; use crate::base::ModuleData;
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::{token, Attribute, Inline, Item}; use rustc_ast::{token, Attribute, Inline, Item};
use rustc_errors::{struct_span_err, DiagnosticBuilder, ErrorReported}; use rustc_errors::{struct_span_err, DiagnosticBuilder, ErrorGuaranteed};
use rustc_parse::new_parser_from_file; use rustc_parse::new_parser_from_file;
use rustc_parse::validate_attr; use rustc_parse::validate_attr;
use rustc_session::parse::ParseSess; use rustc_session::parse::ParseSess;
@ -39,7 +39,7 @@ pub enum ModError<'a> {
ModInBlock(Option<Ident>), ModInBlock(Option<Ident>),
FileNotFound(Ident, PathBuf, PathBuf), FileNotFound(Ident, PathBuf, PathBuf),
MultipleCandidates(Ident, PathBuf, PathBuf), MultipleCandidates(Ident, PathBuf, PathBuf),
ParserError(DiagnosticBuilder<'a, ErrorReported>), ParserError(DiagnosticBuilder<'a, ErrorGuaranteed>),
} }
crate fn parse_external_mod( crate fn parse_external_mod(
@ -242,7 +242,7 @@ pub fn default_submod_path<'a>(
} }
impl ModError<'_> { impl ModError<'_> {
fn report(self, sess: &Session, span: Span) -> ErrorReported { fn report(self, sess: &Session, span: Span) -> ErrorGuaranteed {
let diag = &sess.parse_sess.span_diagnostic; let diag = &sess.parse_sess.span_diagnostic;
match self { match self {
ModError::CircularInclusion(file_paths) => { ModError::CircularInclusion(file_paths) => {

View file

@ -6,7 +6,7 @@ use rustc_ast::ptr::P;
use rustc_ast::token; use rustc_ast::token;
use rustc_ast::tokenstream::{CanSynthesizeMissingTokens, TokenStream, TokenTree}; use rustc_ast::tokenstream::{CanSynthesizeMissingTokens, TokenStream, TokenTree};
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_parse::nt_to_tokenstream; use rustc_parse::nt_to_tokenstream;
use rustc_parse::parser::ForceCollect; use rustc_parse::parser::ForceCollect;
use rustc_span::{Span, DUMMY_SP}; use rustc_span::{Span, DUMMY_SP};
@ -23,7 +23,7 @@ impl base::ProcMacro for BangProcMacro {
ecx: &'cx mut ExtCtxt<'_>, ecx: &'cx mut ExtCtxt<'_>,
span: Span, span: Span,
input: TokenStream, input: TokenStream,
) -> Result<TokenStream, ErrorReported> { ) -> Result<TokenStream, ErrorGuaranteed> {
let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace; let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace;
let server = proc_macro_server::Rustc::new(ecx); let server = proc_macro_server::Rustc::new(ecx);
self.client.run(&EXEC_STRATEGY, server, input, proc_macro_backtrace).map_err(|e| { self.client.run(&EXEC_STRATEGY, server, input, proc_macro_backtrace).map_err(|e| {
@ -32,7 +32,7 @@ impl base::ProcMacro for BangProcMacro {
err.help(&format!("message: {}", s)); err.help(&format!("message: {}", s));
} }
err.emit(); err.emit();
ErrorReported ErrorGuaranteed
}) })
} }
} }
@ -48,7 +48,7 @@ impl base::AttrProcMacro for AttrProcMacro {
span: Span, span: Span,
annotation: TokenStream, annotation: TokenStream,
annotated: TokenStream, annotated: TokenStream,
) -> Result<TokenStream, ErrorReported> { ) -> Result<TokenStream, ErrorGuaranteed> {
let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace; let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace;
let server = proc_macro_server::Rustc::new(ecx); let server = proc_macro_server::Rustc::new(ecx);
self.client self.client
@ -59,7 +59,7 @@ impl base::AttrProcMacro for AttrProcMacro {
err.help(&format!("message: {}", s)); err.help(&format!("message: {}", s));
} }
err.emit(); err.emit();
ErrorReported ErrorGuaranteed
}) })
} }
} }

View file

@ -106,7 +106,7 @@
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::svh::Svh; use rustc_data_structures::svh::Svh;
use rustc_data_structures::{base_n, flock}; use rustc_data_structures::{base_n, flock};
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_fs_util::{link_or_copy, LinkOrCopy}; use rustc_fs_util::{link_or_copy, LinkOrCopy};
use rustc_session::{Session, StableCrateId}; use rustc_session::{Session, StableCrateId};
@ -204,7 +204,7 @@ pub fn prepare_session_directory(
sess: &Session, sess: &Session,
crate_name: &str, crate_name: &str,
stable_crate_id: StableCrateId, stable_crate_id: StableCrateId,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
if sess.opts.incremental.is_none() { if sess.opts.incremental.is_none() {
return Ok(()); return Ok(());
} }
@ -230,7 +230,7 @@ pub fn prepare_session_directory(
crate_dir.display(), crate_dir.display(),
err err
)); ));
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
}; };
@ -482,7 +482,7 @@ fn generate_session_dir_path(crate_dir: &Path) -> PathBuf {
directory_path directory_path
} }
fn create_dir(sess: &Session, path: &Path, dir_tag: &str) -> Result<(), ErrorReported> { fn create_dir(sess: &Session, path: &Path, dir_tag: &str) -> Result<(), ErrorGuaranteed> {
match std_fs::create_dir_all(path) { match std_fs::create_dir_all(path) {
Ok(()) => { Ok(()) => {
debug!("{} directory created successfully", dir_tag); debug!("{} directory created successfully", dir_tag);
@ -496,7 +496,7 @@ fn create_dir(sess: &Session, path: &Path, dir_tag: &str) -> Result<(), ErrorRep
path.display(), path.display(),
err err
)); ));
Err(ErrorReported) Err(ErrorGuaranteed)
} }
} }
} }
@ -505,7 +505,7 @@ fn create_dir(sess: &Session, path: &Path, dir_tag: &str) -> Result<(), ErrorRep
fn lock_directory( fn lock_directory(
sess: &Session, sess: &Session,
session_dir: &Path, session_dir: &Path,
) -> Result<(flock::Lock, PathBuf), ErrorReported> { ) -> Result<(flock::Lock, PathBuf), ErrorGuaranteed> {
let lock_file_path = lock_file_path(session_dir); let lock_file_path = lock_file_path(session_dir);
debug!("lock_directory() - lock_file: {}", lock_file_path.display()); debug!("lock_directory() - lock_file: {}", lock_file_path.display());
@ -546,7 +546,7 @@ fn lock_directory(
} }
} }
err.emit(); err.emit();
Err(ErrorReported) Err(ErrorGuaranteed)
} }
} }
} }

View file

@ -58,7 +58,7 @@ use crate::traits::{
}; };
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::{pluralize, struct_span_err, Diagnostic, ErrorReported}; use rustc_errors::{pluralize, struct_span_err, Diagnostic, ErrorGuaranteed};
use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString}; use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
@ -230,7 +230,7 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>(
span: Span, span: Span,
hidden_ty: Ty<'tcx>, hidden_ty: Ty<'tcx>,
hidden_region: ty::Region<'tcx>, hidden_region: ty::Region<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = struct_span_err!( let mut err = struct_span_err!(
tcx.sess, tcx.sess,
span, span,
@ -258,7 +258,7 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>(
// explanation. // explanation.
// //
// (*) if not, the `tainted_by_errors` field would be set to // (*) if not, the `tainted_by_errors` field would be set to
// `Some(ErrorReported)` in any case, so we wouldn't be here at all. // `Some(ErrorGuaranteed)` in any case, so we wouldn't be here at all.
explain_free_region( explain_free_region(
tcx, tcx,
&mut err, &mut err,
@ -2013,7 +2013,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
&self, &self,
trace: TypeTrace<'tcx>, trace: TypeTrace<'tcx>,
terr: &TypeError<'tcx>, terr: &TypeError<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
use crate::traits::ObligationCauseCode::MatchExpressionArm; use crate::traits::ObligationCauseCode::MatchExpressionArm;
debug!("report_and_explain_type_error(trace={:?}, terr={:?})", trace, terr); debug!("report_and_explain_type_error(trace={:?}, terr={:?})", trace, terr);
@ -2221,7 +2221,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
origin: Option<SubregionOrigin<'tcx>>, origin: Option<SubregionOrigin<'tcx>>,
bound_kind: GenericKind<'tcx>, bound_kind: GenericKind<'tcx>,
sub: Region<'tcx>, sub: Region<'tcx>,
) -> DiagnosticBuilder<'a, ErrorReported> { ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let hir = self.tcx.hir(); let hir = self.tcx.hir();
// Attempt to obtain the span of the parameter so we can // Attempt to obtain the span of the parameter so we can
// suggest adding an explicit lifetime bound to it. // suggest adding an explicit lifetime bound to it.
@ -2647,7 +2647,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
fn report_inference_failure( fn report_inference_failure(
&self, &self,
var_origin: RegionVariableOrigin, var_origin: RegionVariableOrigin,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let br_string = |br: ty::BoundRegionKind| { let br_string = |br: ty::BoundRegionKind| {
let mut s = match br { let mut s = match br {
ty::BrNamed(_, name) => name.to_string(), ty::BrNamed(_, name) => name.to_string(),

View file

@ -1,7 +1,7 @@
use crate::infer::type_variable::TypeVariableOriginKind; use crate::infer::type_variable::TypeVariableOriginKind;
use crate::infer::{InferCtxt, Symbol}; use crate::infer::{InferCtxt, Symbol};
use rustc_errors::{ use rustc_errors::{
pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorReported, pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
}; };
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{DefKind, Namespace}; use rustc_hir::def::{DefKind, Namespace};
@ -490,7 +490,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
arg: GenericArg<'tcx>, arg: GenericArg<'tcx>,
impl_candidates: Vec<ty::TraitRef<'tcx>>, impl_candidates: Vec<ty::TraitRef<'tcx>>,
error_code: TypeAnnotationNeeded, error_code: TypeAnnotationNeeded,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let arg = self.resolve_vars_if_possible(arg); let arg = self.resolve_vars_if_possible(arg);
let arg_data = self.extract_inference_diagnostics_data(arg, None); let arg_data = self.extract_inference_diagnostics_data(arg, None);
@ -915,7 +915,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
kind: hir::GeneratorKind, kind: hir::GeneratorKind,
span: Span, span: Span,
ty: Ty<'tcx>, ty: Ty<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let ty = self.resolve_vars_if_possible(ty); let ty = self.resolve_vars_if_possible(ty);
let data = self.extract_inference_diagnostics_data(ty.into(), None); let data = self.extract_inference_diagnostics_data(ty.into(), None);

View file

@ -7,7 +7,7 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use crate::infer::lexical_region_resolve::RegionResolutionError; use crate::infer::lexical_region_resolve::RegionResolutionError;
use crate::infer::SubregionOrigin; use crate::infer::SubregionOrigin;
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorReported}; use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::{GenericParamKind, Ty}; use rustc_hir::{GenericParamKind, Ty};
use rustc_middle::ty::Region; use rustc_middle::ty::Region;
@ -49,7 +49,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
/// ``` /// ```
/// ///
/// It will later be extended to trait objects. /// It will later be extended to trait objects.
pub(super) fn try_report_anon_anon_conflict(&self) -> Option<ErrorReported> { pub(super) fn try_report_anon_anon_conflict(&self) -> Option<ErrorGuaranteed> {
let (span, sub, sup) = self.regions()?; let (span, sub, sup) = self.regions()?;
if let Some(RegionResolutionError::ConcreteFailure( if let Some(RegionResolutionError::ConcreteFailure(
@ -148,7 +148,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
self.suggest_adding_lifetime_params(sub, ty_sup, ty_sub, &mut err); self.suggest_adding_lifetime_params(sub, ty_sup, ty_sub, &mut err);
err.emit(); err.emit();
Some(ErrorReported) Some(ErrorGuaranteed)
} }
fn suggest_adding_lifetime_params( fn suggest_adding_lifetime_params(

View file

@ -7,14 +7,14 @@ use crate::infer::lexical_region_resolve::RegionResolutionError;
use crate::infer::{SubregionOrigin, TypeTrace}; use crate::infer::{SubregionOrigin, TypeTrace};
use crate::traits::ObligationCauseCode; use crate::traits::ObligationCauseCode;
use rustc_data_structures::stable_set::FxHashSet; use rustc_data_structures::stable_set::FxHashSet;
use rustc_errors::{Applicability, ErrorReported}; use rustc_errors::{Applicability, ErrorGuaranteed};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::intravisit::Visitor; use rustc_hir::intravisit::Visitor;
use rustc_middle::ty::TypeVisitor; use rustc_middle::ty::TypeVisitor;
use rustc_span::MultiSpan; use rustc_span::MultiSpan;
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
pub(super) fn try_report_mismatched_static_lifetime(&self) -> Option<ErrorReported> { pub(super) fn try_report_mismatched_static_lifetime(&self) -> Option<ErrorGuaranteed> {
let error = self.error.as_ref()?; let error = self.error.as_ref()?;
debug!("try_report_mismatched_static_lifetime {:?}", error); debug!("try_report_mismatched_static_lifetime {:?}", error);
@ -99,6 +99,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
err.span_note(impl_span, "...does not necessarily outlive the static lifetime introduced by the compatible `impl`"); err.span_note(impl_span, "...does not necessarily outlive the static lifetime introduced by the compatible `impl`");
} }
err.emit(); err.emit();
Some(ErrorReported) Some(ErrorGuaranteed)
} }
} }

View file

@ -1,7 +1,7 @@
use crate::infer::lexical_region_resolve::RegionResolutionError; use crate::infer::lexical_region_resolve::RegionResolutionError;
use crate::infer::lexical_region_resolve::RegionResolutionError::*; use crate::infer::lexical_region_resolve::RegionResolutionError::*;
use crate::infer::InferCtxt; use crate::infer::InferCtxt;
use rustc_errors::{DiagnosticBuilder, ErrorReported}; use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
use rustc_middle::ty::{self, TyCtxt}; use rustc_middle::ty::{self, TyCtxt};
use rustc_span::source_map::Span; use rustc_span::source_map::Span;
@ -46,17 +46,17 @@ impl<'cx, 'tcx> NiceRegionError<'cx, 'tcx> {
self.infcx.tcx self.infcx.tcx
} }
pub fn try_report_from_nll(&self) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> { pub fn try_report_from_nll(&self) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
// Due to the improved diagnostics returned by the MIR borrow checker, only a subset of // Due to the improved diagnostics returned by the MIR borrow checker, only a subset of
// the nice region errors are required when running under the MIR borrow checker. // the nice region errors are required when running under the MIR borrow checker.
self.try_report_named_anon_conflict().or_else(|| self.try_report_placeholder_conflict()) self.try_report_named_anon_conflict().or_else(|| self.try_report_placeholder_conflict())
} }
pub fn try_report(&self) -> Option<ErrorReported> { pub fn try_report(&self) -> Option<ErrorGuaranteed> {
self.try_report_from_nll() self.try_report_from_nll()
.map(|mut diag| { .map(|mut diag| {
diag.emit(); diag.emit();
ErrorReported ErrorGuaranteed
}) })
.or_else(|| self.try_report_impl_not_conforming_to_trait()) .or_else(|| self.try_report_impl_not_conforming_to_trait())
.or_else(|| self.try_report_anon_anon_conflict()) .or_else(|| self.try_report_anon_anon_conflict())

View file

@ -2,7 +2,7 @@
//! where one region is named and the other is anonymous. //! where one region is named and the other is anonymous.
use crate::infer::error_reporting::nice_region_error::find_anon_type::find_anon_type; use crate::infer::error_reporting::nice_region_error::find_anon_type::find_anon_type;
use crate::infer::error_reporting::nice_region_error::NiceRegionError; use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorReported}; use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed};
use rustc_middle::ty; use rustc_middle::ty;
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
@ -10,7 +10,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
/// an anonymous region, emit an descriptive diagnostic error. /// an anonymous region, emit an descriptive diagnostic error.
pub(super) fn try_report_named_anon_conflict( pub(super) fn try_report_named_anon_conflict(
&self, &self,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> { ) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
let (span, sub, sup) = self.regions()?; let (span, sub, sup) = self.regions()?;
debug!( debug!(

View file

@ -4,7 +4,7 @@ use crate::infer::ValuePairs;
use crate::infer::{SubregionOrigin, TypeTrace}; use crate::infer::{SubregionOrigin, TypeTrace};
use crate::traits::{ObligationCause, ObligationCauseCode}; use crate::traits::{ObligationCause, ObligationCauseCode};
use rustc_data_structures::intern::Interned; use rustc_data_structures::intern::Interned;
use rustc_errors::{Diagnostic, DiagnosticBuilder, ErrorReported}; use rustc_errors::{Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
use rustc_hir::def::Namespace; use rustc_hir::def::Namespace;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_middle::ty::error::ExpectedFound; use rustc_middle::ty::error::ExpectedFound;
@ -19,7 +19,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
/// an anonymous region, emit a descriptive diagnostic error. /// an anonymous region, emit a descriptive diagnostic error.
pub(super) fn try_report_placeholder_conflict( pub(super) fn try_report_placeholder_conflict(
&self, &self,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> { ) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
match &self.error { match &self.error {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// NB. The ordering of cases in this match is very // NB. The ordering of cases in this match is very
@ -155,7 +155,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
sub_placeholder: Option<Region<'tcx>>, sub_placeholder: Option<Region<'tcx>>,
sup_placeholder: Option<Region<'tcx>>, sup_placeholder: Option<Region<'tcx>>,
value_pairs: &ValuePairs<'tcx>, value_pairs: &ValuePairs<'tcx>,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> { ) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
let (expected_substs, found_substs, trait_def_id) = match value_pairs { let (expected_substs, found_substs, trait_def_id) = match value_pairs {
ValuePairs::TraitRefs(ExpectedFound { expected, found }) ValuePairs::TraitRefs(ExpectedFound { expected, found })
if expected.def_id == found.def_id => if expected.def_id == found.def_id =>
@ -203,7 +203,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
trait_def_id: DefId, trait_def_id: DefId,
expected_substs: SubstsRef<'tcx>, expected_substs: SubstsRef<'tcx>,
actual_substs: SubstsRef<'tcx>, actual_substs: SubstsRef<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let span = cause.span(self.tcx()); let span = cause.span(self.tcx());
let msg = format!( let msg = format!(
"implementation of `{}` is not general enough", "implementation of `{}` is not general enough",

View file

@ -5,7 +5,7 @@ use crate::infer::lexical_region_resolve::RegionResolutionError;
use crate::infer::{SubregionOrigin, TypeTrace}; use crate::infer::{SubregionOrigin, TypeTrace};
use crate::traits::{ObligationCauseCode, UnifyReceiverContext}; use crate::traits::{ObligationCauseCode, UnifyReceiverContext};
use rustc_data_structures::stable_set::FxHashSet; use rustc_data_structures::stable_set::FxHashSet;
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorReported}; use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed};
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::{walk_ty, Visitor}; use rustc_hir::intravisit::{walk_ty, Visitor};
use rustc_hir::{self as hir, GenericBound, Item, ItemKind, Lifetime, LifetimeName, Node, TyKind}; use rustc_hir::{self as hir, GenericBound, Item, ItemKind, Lifetime, LifetimeName, Node, TyKind};
@ -20,7 +20,7 @@ use std::ops::ControlFlow;
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
/// Print the error message for lifetime errors when the return type is a static `impl Trait`, /// Print the error message for lifetime errors when the return type is a static `impl Trait`,
/// `dyn Trait` or if a method call on a trait object introduces a static requirement. /// `dyn Trait` or if a method call on a trait object introduces a static requirement.
pub(super) fn try_report_static_impl_trait(&self) -> Option<ErrorReported> { pub(super) fn try_report_static_impl_trait(&self) -> Option<ErrorGuaranteed> {
debug!("try_report_static_impl_trait(error={:?})", self.error); debug!("try_report_static_impl_trait(error={:?})", self.error);
let tcx = self.tcx(); let tcx = self.tcx();
let (var_origin, sub_origin, sub_r, sup_origin, sup_r, spans) = match self.error.as_ref()? { let (var_origin, sub_origin, sub_r, sup_origin, sup_r, spans) = match self.error.as_ref()? {
@ -85,7 +85,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
); );
if self.find_impl_on_dyn_trait(&mut err, param.param_ty, &ctxt) { if self.find_impl_on_dyn_trait(&mut err, param.param_ty, &ctxt) {
err.emit(); err.emit();
return Some(ErrorReported); return Some(ErrorGuaranteed);
} else { } else {
err.cancel(); err.cancel();
} }
@ -280,7 +280,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
); );
err.emit(); err.emit();
Some(ErrorReported) Some(ErrorGuaranteed)
} }
} }

View file

@ -4,7 +4,7 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError;
use crate::infer::lexical_region_resolve::RegionResolutionError; use crate::infer::lexical_region_resolve::RegionResolutionError;
use crate::infer::{SubregionOrigin, Subtype}; use crate::infer::{SubregionOrigin, Subtype};
use crate::traits::ObligationCauseCode::CompareImplMethodObligation; use crate::traits::ObligationCauseCode::CompareImplMethodObligation;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::Res; use rustc_hir::def::Res;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
@ -19,7 +19,7 @@ use std::ops::ControlFlow;
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
/// Print the error message for lifetime errors when the `impl` doesn't conform to the `trait`. /// Print the error message for lifetime errors when the `impl` doesn't conform to the `trait`.
pub(super) fn try_report_impl_not_conforming_to_trait(&self) -> Option<ErrorReported> { pub(super) fn try_report_impl_not_conforming_to_trait(&self) -> Option<ErrorGuaranteed> {
let error = self.error.as_ref()?; let error = self.error.as_ref()?;
debug!("try_report_impl_not_conforming_to_trait {:?}", error); debug!("try_report_impl_not_conforming_to_trait {:?}", error);
if let RegionResolutionError::SubSupConflict( if let RegionResolutionError::SubSupConflict(
@ -46,7 +46,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
*sub_found, *sub_found,
*trait_item_def_id, *trait_item_def_id,
); );
return Some(ErrorReported); return Some(ErrorGuaranteed);
} }
} }
} }
@ -66,7 +66,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
impl_item_def_id, impl_item_def_id,
trait_item_def_id, trait_item_def_id,
); );
return Some(ErrorReported); return Some(ErrorGuaranteed);
} }
} }
None None

View file

@ -1,6 +1,6 @@
use crate::infer::error_reporting::{note_and_explain_region, ObligationCauseExt}; use crate::infer::error_reporting::{note_and_explain_region, ObligationCauseExt};
use crate::infer::{self, InferCtxt, SubregionOrigin}; use crate::infer::{self, InferCtxt, SubregionOrigin};
use rustc_errors::{struct_span_err, Diagnostic, DiagnosticBuilder, ErrorReported}; use rustc_errors::{struct_span_err, Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
use rustc_middle::traits::ObligationCauseCode; use rustc_middle::traits::ObligationCauseCode;
use rustc_middle::ty::error::TypeError; use rustc_middle::ty::error::TypeError;
use rustc_middle::ty::{self, Region}; use rustc_middle::ty::{self, Region};
@ -109,7 +109,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
origin: SubregionOrigin<'tcx>, origin: SubregionOrigin<'tcx>,
sub: Region<'tcx>, sub: Region<'tcx>,
sup: Region<'tcx>, sup: Region<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
match origin { match origin {
infer::Subtype(box trace) => { infer::Subtype(box trace) => {
let terr = TypeError::RegionsDoesNotOutlive(sup, sub); let terr = TypeError::RegionsDoesNotOutlive(sup, sub);
@ -401,7 +401,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
placeholder_origin: SubregionOrigin<'tcx>, placeholder_origin: SubregionOrigin<'tcx>,
sub: Region<'tcx>, sub: Region<'tcx>,
sup: Region<'tcx>, sup: Region<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
// I can't think how to do better than this right now. -nikomatsakis // I can't think how to do better than this right now. -nikomatsakis
debug!(?placeholder_origin, ?sub, ?sup, "report_placeholder_failure"); debug!(?placeholder_origin, ?sub, ?sup, "report_placeholder_failure");
match placeholder_origin { match placeholder_origin {

View file

@ -14,7 +14,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_data_structures::undo_log::Rollback; use rustc_data_structures::undo_log::Rollback;
use rustc_data_structures::unify as ut; use rustc_data_structures::unify as ut;
use rustc_errors::{DiagnosticBuilder, ErrorReported}; use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues}; use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
@ -1475,9 +1475,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
sp: Span, sp: Span,
mk_diag: M, mk_diag: M,
actual_ty: Ty<'tcx>, actual_ty: Ty<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorReported> ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>
where where
M: FnOnce(String) -> DiagnosticBuilder<'tcx, ErrorReported>, M: FnOnce(String) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>,
{ {
let actual_ty = self.resolve_vars_if_possible(actual_ty); let actual_ty = self.resolve_vars_if_possible(actual_ty);
debug!("type_error_struct_with_diag({:?}, {:?})", sp, actual_ty); debug!("type_error_struct_with_diag({:?}, {:?})", sp, actual_ty);
@ -1498,7 +1498,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
expected: Ty<'tcx>, expected: Ty<'tcx>,
actual: Ty<'tcx>, actual: Ty<'tcx>,
err: TypeError<'tcx>, err: TypeError<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let trace = TypeTrace::types(cause, true, expected, actual); let trace = TypeTrace::types(cause, true, expected, actual);
self.report_and_explain_type_error(trace, &err) self.report_and_explain_type_error(trace, &err)
} }
@ -1509,7 +1509,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
expected: ty::Const<'tcx>, expected: ty::Const<'tcx>,
actual: ty::Const<'tcx>, actual: ty::Const<'tcx>,
err: TypeError<'tcx>, err: TypeError<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let trace = TypeTrace::consts(cause, true, expected, actual); let trace = TypeTrace::consts(cause, true, expected, actual);
self.report_and_explain_type_error(trace, &err) self.report_and_explain_type_error(trace, &err)
} }

View file

@ -2,7 +2,7 @@ use super::ObjectSafetyViolation;
use crate::infer::InferCtxt; use crate::infer::InferCtxt;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{struct_span_err, DiagnosticBuilder, ErrorReported}; use rustc_errors::{struct_span_err, DiagnosticBuilder, ErrorGuaranteed};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
@ -17,7 +17,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
impl_item_def_id: DefId, impl_item_def_id: DefId,
trait_item_def_id: DefId, trait_item_def_id: DefId,
requirement: &dyn fmt::Display, requirement: &dyn fmt::Display,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let msg = "impl has stricter requirements than trait"; let msg = "impl has stricter requirements than trait";
let sp = self.tcx.sess.source_map().guess_head_span(error_span); let sp = self.tcx.sess.source_map().guess_head_span(error_span);
@ -40,7 +40,7 @@ pub fn report_object_safety_error<'tcx>(
span: Span, span: Span,
trait_def_id: DefId, trait_def_id: DefId,
violations: &[ObjectSafetyViolation], violations: &[ObjectSafetyViolation],
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let trait_str = tcx.def_path_str(trait_def_id); let trait_str = tcx.def_path_str(trait_def_id);
let trait_span = tcx.hir().get_if_local(trait_def_id).and_then(|node| match node { let trait_span = tcx.hir().get_if_local(trait_def_id).and_then(|node| match node {
hir::Node::Item(item) => Some(item.ident.span), hir::Node::Item(item) => Some(item.ident.span),

View file

@ -8,7 +8,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_data_structures::OnDrop; use rustc_data_structures::OnDrop;
use rustc_errors::registry::Registry; use rustc_errors::registry::Registry;
use rustc_errors::{ErrorReported, Handler}; use rustc_errors::{ErrorGuaranteed, Handler};
use rustc_lint::LintStore; use rustc_lint::LintStore;
use rustc_middle::ty; use rustc_middle::ty;
use rustc_parse::maybe_new_parser_from_source_str; use rustc_parse::maybe_new_parser_from_source_str;
@ -23,7 +23,7 @@ use rustc_span::symbol::sym;
use std::path::PathBuf; use std::path::PathBuf;
use std::result; use std::result;
pub type Result<T> = result::Result<T, ErrorReported>; pub type Result<T> = result::Result<T, ErrorGuaranteed>;
/// Represents a compiler session. /// Represents a compiler session.
/// ///

View file

@ -10,7 +10,7 @@ use rustc_codegen_ssa::traits::CodegenBackend;
use rustc_data_structures::parallel; use rustc_data_structures::parallel;
use rustc_data_structures::sync::{Lrc, OnceCell, WorkerLocal}; use rustc_data_structures::sync::{Lrc, OnceCell, WorkerLocal};
use rustc_data_structures::temp_dir::MaybeTempDir; use rustc_data_structures::temp_dir::MaybeTempDir;
use rustc_errors::{Applicability, ErrorReported, PResult}; use rustc_errors::{Applicability, ErrorGuaranteed, PResult};
use rustc_expand::base::{ExtCtxt, LintStoreExpand, ResolverExpand}; use rustc_expand::base::{ExtCtxt, LintStoreExpand, ResolverExpand};
use rustc_hir::def_id::{StableCrateId, LOCAL_CRATE}; use rustc_hir::def_id::{StableCrateId, LOCAL_CRATE};
use rustc_hir::Crate; use rustc_hir::Crate;
@ -373,7 +373,7 @@ pub fn configure_and_expand(
if recursion_limit_hit { if recursion_limit_hit {
// If we hit a recursion limit, exit early to avoid later passes getting overwhelmed // If we hit a recursion limit, exit early to avoid later passes getting overwhelmed
// with a large AST // with a large AST
Err(ErrorReported) Err(ErrorGuaranteed)
} else { } else {
Ok(krate) Ok(krate)
} }
@ -758,7 +758,7 @@ pub fn prepare_outputs(
executable", executable",
input_path.display() input_path.display()
)); ));
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
if let Some(dir_path) = output_conflicts_with_dir(&output_paths) { if let Some(dir_path) = output_conflicts_with_dir(&output_paths) {
sess.err(&format!( sess.err(&format!(
@ -767,7 +767,7 @@ pub fn prepare_outputs(
input_path.display(), input_path.display(),
dir_path.display() dir_path.display()
)); ));
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
} }
} }
@ -775,7 +775,7 @@ pub fn prepare_outputs(
if let Some(ref dir) = compiler.temps_dir { if let Some(ref dir) = compiler.temps_dir {
if fs::create_dir_all(dir).is_err() { if fs::create_dir_all(dir).is_err() {
sess.err("failed to find or create the directory specified by `--temps-dir`"); sess.err("failed to find or create the directory specified by `--temps-dir`");
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
} }
@ -788,7 +788,7 @@ pub fn prepare_outputs(
if let Some(ref dir) = compiler.output_dir { if let Some(ref dir) = compiler.output_dir {
if fs::create_dir_all(dir).is_err() { if fs::create_dir_all(dir).is_err() {
sess.err("failed to find or create the directory specified by `--out-dir`"); sess.err("failed to find or create the directory specified by `--out-dir`");
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
} }
} }
@ -993,7 +993,7 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
// lint warnings and so on -- kindck used to do this abort, but // lint warnings and so on -- kindck used to do this abort, but
// kindck is gone now). -nmatsakis // kindck is gone now). -nmatsakis
if sess.has_errors() { if sess.has_errors() {
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
sess.time("misc_checking_3", || { sess.time("misc_checking_3", || {

View file

@ -5,7 +5,7 @@ use rustc_ast as ast;
use rustc_codegen_ssa::traits::CodegenBackend; use rustc_codegen_ssa::traits::CodegenBackend;
use rustc_data_structures::svh::Svh; use rustc_data_structures::svh::Svh;
use rustc_data_structures::sync::{Lrc, OnceCell, WorkerLocal}; use rustc_data_structures::sync::{Lrc, OnceCell, WorkerLocal};
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir::def_id::LOCAL_CRATE; use rustc_hir::def_id::LOCAL_CRATE;
use rustc_incremental::DepGraphFuture; use rustc_incremental::DepGraphFuture;
use rustc_lint::LintStore; use rustc_lint::LintStore;
@ -123,7 +123,7 @@ impl<'tcx> Queries<'tcx> {
self.parse.compute(|| { self.parse.compute(|| {
passes::parse(self.session(), &self.compiler.input).map_err(|mut parse_error| { passes::parse(self.session(), &self.compiler.input).map_err(|mut parse_error| {
parse_error.emit(); parse_error.emit();
ErrorReported ErrorGuaranteed
}) })
}) })
} }

View file

@ -232,7 +232,7 @@ impl<'a> SessionDiagnosticDerive<'a> {
fn into_diagnostic( fn into_diagnostic(
self, self,
#sess: &'__session_diagnostic_sess rustc_session::Session #sess: &'__session_diagnostic_sess rustc_session::Session
) -> rustc_errors::DiagnosticBuilder<'__session_diagnostic_sess, rustc_errors::ErrorReported> { ) -> rustc_errors::DiagnosticBuilder<'__session_diagnostic_sess, rustc_errors::ErrorGuaranteed> {
#implementation #implementation
} }
} }

View file

@ -4,7 +4,7 @@ use crate::mir::interpret::ConstValue;
use crate::ty::{layout, query::TyCtxtAt, tls, FnSig, Ty}; use crate::ty::{layout, query::TyCtxtAt, tls, FnSig, Ty};
use rustc_data_structures::sync::Lock; use rustc_data_structures::sync::Lock;
use rustc_errors::{pluralize, struct_span_err, DiagnosticBuilder, ErrorReported}; use rustc_errors::{pluralize, struct_span_err, DiagnosticBuilder, ErrorGuaranteed};
use rustc_macros::HashStable; use rustc_macros::HashStable;
use rustc_session::CtfeBacktrace; use rustc_session::CtfeBacktrace;
use rustc_span::def_id::DefId; use rustc_span::def_id::DefId;
@ -15,7 +15,7 @@ use std::{any::Any, backtrace::Backtrace, fmt};
pub enum ErrorHandled { pub enum ErrorHandled {
/// Already reported an error for this evaluation, and the compilation is /// Already reported an error for this evaluation, and the compilation is
/// *guaranteed* to fail. Warnings/lints *must not* produce `Reported`. /// *guaranteed* to fail. Warnings/lints *must not* produce `Reported`.
Reported(ErrorReported), Reported(ErrorGuaranteed),
/// Already emitted a lint for this evaluation. /// Already emitted a lint for this evaluation.
Linted, Linted,
/// Don't emit an error, the evaluation failed because the MIR was generic /// Don't emit an error, the evaluation failed because the MIR was generic
@ -23,8 +23,8 @@ pub enum ErrorHandled {
TooGeneric, TooGeneric,
} }
impl From<ErrorReported> for ErrorHandled { impl From<ErrorGuaranteed> for ErrorHandled {
fn from(err: ErrorReported) -> ErrorHandled { fn from(err: ErrorGuaranteed) -> ErrorHandled {
ErrorHandled::Reported(err) ErrorHandled::Reported(err)
} }
} }
@ -39,7 +39,7 @@ pub type EvalToConstValueResult<'tcx> = Result<ConstValue<'tcx>, ErrorHandled>;
pub fn struct_error<'tcx>( pub fn struct_error<'tcx>(
tcx: TyCtxtAt<'tcx>, tcx: TyCtxtAt<'tcx>,
msg: &str, msg: &str,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
struct_span_err!(tcx.sess, tcx.span, E0080, "{}", msg) struct_span_err!(tcx.sess, tcx.span, E0080, "{}", msg)
} }
@ -91,7 +91,7 @@ fn print_backtrace(backtrace: &Backtrace) {
impl From<ErrorHandled> for InterpErrorInfo<'_> { impl From<ErrorHandled> for InterpErrorInfo<'_> {
fn from(err: ErrorHandled) -> Self { fn from(err: ErrorHandled) -> Self {
match err { match err {
ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => { ErrorHandled::Reported(ErrorGuaranteed) | ErrorHandled::Linted => {
err_inval!(ReferencedConstant) err_inval!(ReferencedConstant)
} }
ErrorHandled::TooGeneric => err_inval!(TooGeneric), ErrorHandled::TooGeneric => err_inval!(TooGeneric),
@ -100,8 +100,8 @@ impl From<ErrorHandled> for InterpErrorInfo<'_> {
} }
} }
impl From<ErrorReported> for InterpErrorInfo<'_> { impl From<ErrorGuaranteed> for InterpErrorInfo<'_> {
fn from(err: ErrorReported) -> Self { fn from(err: ErrorGuaranteed) -> Self {
InterpError::InvalidProgram(InvalidProgramInfo::AlreadyReported(err)).into() InterpError::InvalidProgram(InvalidProgramInfo::AlreadyReported(err)).into()
} }
} }
@ -141,7 +141,7 @@ pub enum InvalidProgramInfo<'tcx> {
/// which already produced an error. /// which already produced an error.
ReferencedConstant, ReferencedConstant,
/// Abort in case errors are already reported. /// Abort in case errors are already reported.
AlreadyReported(ErrorReported), AlreadyReported(ErrorGuaranteed),
/// An error occurred during layout computation. /// An error occurred during layout computation.
Layout(layout::LayoutError<'tcx>), Layout(layout::LayoutError<'tcx>),
/// An error occurred during FnAbi computation: the passed --target lacks FFI support /// An error occurred during FnAbi computation: the passed --target lacks FFI support
@ -160,7 +160,7 @@ impl fmt::Display for InvalidProgramInfo<'_> {
match self { match self {
TooGeneric => write!(f, "encountered overly generic constant"), TooGeneric => write!(f, "encountered overly generic constant"),
ReferencedConstant => write!(f, "referenced constant has errors"), ReferencedConstant => write!(f, "referenced constant has errors"),
AlreadyReported(ErrorReported) => { AlreadyReported(ErrorGuaranteed) => {
write!(f, "encountered constants with type errors, stopping evaluation") write!(f, "encountered constants with type errors, stopping evaluation")
} }
Layout(ref err) => write!(f, "{}", err), Layout(ref err) => write!(f, "{}", err),

View file

@ -13,7 +13,7 @@ use crate::ty::subst::{Subst, SubstsRef};
use crate::ty::{self, List, Ty, TyCtxt}; use crate::ty::{self, List, Ty, TyCtxt};
use crate::ty::{AdtDef, InstanceDef, Region, ScalarInt, UserTypeAnnotationIndex}; use crate::ty::{AdtDef, InstanceDef, Region, ScalarInt, UserTypeAnnotationIndex};
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir::def::{CtorKind, Namespace}; use rustc_hir::def::{CtorKind, Namespace};
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX}; use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX};
use rustc_hir::{self, GeneratorKind}; use rustc_hir::{self, GeneratorKind};
@ -286,7 +286,7 @@ pub struct Body<'tcx> {
predecessor_cache: PredecessorCache, predecessor_cache: PredecessorCache,
is_cyclic: GraphIsCyclicCache, is_cyclic: GraphIsCyclicCache,
pub tainted_by_errors: Option<ErrorReported>, pub tainted_by_errors: Option<ErrorGuaranteed>,
} }
impl<'tcx> Body<'tcx> { impl<'tcx> Body<'tcx> {
@ -300,7 +300,7 @@ impl<'tcx> Body<'tcx> {
var_debug_info: Vec<VarDebugInfo<'tcx>>, var_debug_info: Vec<VarDebugInfo<'tcx>>,
span: Span, span: Span,
generator_kind: Option<GeneratorKind>, generator_kind: Option<GeneratorKind>,
tainted_by_errors: Option<ErrorReported>, tainted_by_errors: Option<ErrorGuaranteed>,
) -> Self { ) -> Self {
// We need `arg_count` locals, and one for the return place. // We need `arg_count` locals, and one for the return place.
assert!( assert!(

View file

@ -4,7 +4,7 @@ use crate::mir::{Body, Promoted};
use crate::ty::{self, Ty, TyCtxt}; use crate::ty::{self, Ty, TyCtxt};
use rustc_data_structures::stable_map::FxHashMap; use rustc_data_structures::stable_map::FxHashMap;
use rustc_data_structures::vec_map::VecMap; use rustc_data_structures::vec_map::VecMap;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_index::bit_set::BitMatrix; use rustc_index::bit_set::BitMatrix;
@ -245,7 +245,7 @@ pub struct BorrowCheckResult<'tcx> {
pub concrete_opaque_types: VecMap<OpaqueTypeKey<'tcx>, Ty<'tcx>>, pub concrete_opaque_types: VecMap<OpaqueTypeKey<'tcx>, Ty<'tcx>>,
pub closure_requirements: Option<ClosureRegionRequirements<'tcx>>, pub closure_requirements: Option<ClosureRegionRequirements<'tcx>>,
pub used_mut_upvars: SmallVec<[Field; 8]>, pub used_mut_upvars: SmallVec<[Field; 8]>,
pub tainted_by_errors: Option<ErrorReported>, pub tainted_by_errors: Option<ErrorGuaranteed>,
} }
/// The result of the `mir_const_qualif` query. /// The result of the `mir_const_qualif` query.
@ -259,7 +259,7 @@ pub struct ConstQualifs {
pub needs_drop: bool, pub needs_drop: bool,
pub needs_non_const_drop: bool, pub needs_non_const_drop: bool,
pub custom_eq: bool, pub custom_eq: bool,
pub tainted_by_errors: Option<ErrorReported>, pub tainted_by_errors: Option<ErrorGuaranteed>,
} }
/// After we borrow check a closure, we are left with various /// After we borrow check a closure, we are left with various

View file

@ -142,7 +142,7 @@ rustc_queries! {
separate_provide_extern separate_provide_extern
} }
query analysis(key: ()) -> Result<(), ErrorReported> { query analysis(key: ()) -> Result<(), ErrorGuaranteed> {
eval_always eval_always
desc { "running analysis passes on this crate" } desc { "running analysis passes on this crate" }
} }
@ -312,7 +312,7 @@ rustc_queries! {
/// Try to build an abstract representation of the given constant. /// Try to build an abstract representation of the given constant.
query thir_abstract_const( query thir_abstract_const(
key: DefId key: DefId
) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorReported> { ) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorGuaranteed> {
desc { desc {
|tcx| "building an abstract representation for {}", tcx.def_path_str(key), |tcx| "building an abstract representation for {}", tcx.def_path_str(key),
} }
@ -321,7 +321,7 @@ rustc_queries! {
/// Try to build an abstract representation of the given constant. /// Try to build an abstract representation of the given constant.
query thir_abstract_const_of_const_arg( query thir_abstract_const_of_const_arg(
key: (LocalDefId, DefId) key: (LocalDefId, DefId)
) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorReported> { ) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorGuaranteed> {
desc { desc {
|tcx| |tcx|
"building an abstract representation for the const argument {}", "building an abstract representation for the const argument {}",
@ -1107,7 +1107,7 @@ rustc_queries! {
query codegen_fulfill_obligation( query codegen_fulfill_obligation(
key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
) -> Result<&'tcx ImplSource<'tcx, ()>, ErrorReported> { ) -> Result<&'tcx ImplSource<'tcx, ()>, ErrorGuaranteed> {
cache_on_disk_if { true } cache_on_disk_if { true }
desc { |tcx| desc { |tcx|
"checking if `{}` fulfills its obligations", "checking if `{}` fulfills its obligations",
@ -1890,20 +1890,20 @@ rustc_queries! {
/// * `Ok(Some(instance))` on success /// * `Ok(Some(instance))` on success
/// * `Ok(None)` when the `SubstsRef` are still too generic, /// * `Ok(None)` when the `SubstsRef` are still too generic,
/// and therefore don't allow finding the final `Instance` /// and therefore don't allow finding the final `Instance`
/// * `Err(ErrorReported)` when the `Instance` resolution process /// * `Err(ErrorGuaranteed)` when the `Instance` resolution process
/// couldn't complete due to errors elsewhere - this is distinct /// couldn't complete due to errors elsewhere - this is distinct
/// from `Ok(None)` to avoid misleading diagnostics when an error /// from `Ok(None)` to avoid misleading diagnostics when an error
/// has already been/will be emitted, for the original cause /// has already been/will be emitted, for the original cause
query resolve_instance( query resolve_instance(
key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)> key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>
) -> Result<Option<ty::Instance<'tcx>>, ErrorReported> { ) -> Result<Option<ty::Instance<'tcx>>, ErrorGuaranteed> {
desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) } desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) }
remap_env_constness remap_env_constness
} }
query resolve_instance_of_const_arg( query resolve_instance_of_const_arg(
key: ty::ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)> key: ty::ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)>
) -> Result<Option<ty::Instance<'tcx>>, ErrorReported> { ) -> Result<Option<ty::Instance<'tcx>>, ErrorGuaranteed> {
desc { desc {
"resolving instance of the const argument `{}`", "resolving instance of the const argument `{}`",
ty::Instance::new(key.value.0.to_def_id(), key.value.2), ty::Instance::new(key.value.0.to_def_id(), key.value.2),

View file

@ -1,7 +1,7 @@
//! A subset of a mir body used for const evaluatability checking. //! A subset of a mir body used for const evaluatability checking.
use crate::mir; use crate::mir;
use crate::ty::{self, Ty, TyCtxt}; use crate::ty::{self, Ty, TyCtxt};
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
rustc_index::newtype_index! { rustc_index::newtype_index! {
/// An index into an `AbstractConst`. /// An index into an `AbstractConst`.
@ -31,13 +31,13 @@ pub enum Node<'tcx> {
#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)] #[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
pub enum NotConstEvaluatable { pub enum NotConstEvaluatable {
Error(ErrorReported), Error(ErrorGuaranteed),
MentionsInfer, MentionsInfer,
MentionsParam, MentionsParam,
} }
impl From<ErrorReported> for NotConstEvaluatable { impl From<ErrorGuaranteed> for NotConstEvaluatable {
fn from(e: ErrorReported) -> NotConstEvaluatable { fn from(e: ErrorGuaranteed) -> NotConstEvaluatable {
NotConstEvaluatable::Error(e) NotConstEvaluatable::Error(e)
} }
} }
@ -51,7 +51,7 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn thir_abstract_const_opt_const_arg( pub fn thir_abstract_const_opt_const_arg(
self, self,
def: ty::WithOptConstParam<rustc_hir::def_id::DefId>, def: ty::WithOptConstParam<rustc_hir::def_id::DefId>,
) -> Result<Option<&'tcx [Node<'tcx>]>, ErrorReported> { ) -> Result<Option<&'tcx [Node<'tcx>]>, ErrorGuaranteed> {
if let Some((did, param_did)) = def.as_const_arg() { if let Some((did, param_did)) = def.as_const_arg() {
self.thir_abstract_const_of_const_arg((did, param_did)) self.thir_abstract_const_of_const_arg((did, param_did))
} else { } else {

View file

@ -2,7 +2,7 @@ use crate::ty::fast_reject::SimplifiedType;
use crate::ty::fold::TypeFoldable; use crate::ty::fold::TypeFoldable;
use crate::ty::{self, TyCtxt}; use crate::ty::{self, TyCtxt};
use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir::def_id::{DefId, DefIdMap}; use rustc_hir::def_id::{DefId, DefIdMap};
use rustc_span::symbol::sym; use rustc_span::symbol::sym;
@ -243,11 +243,11 @@ pub fn ancestors<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
trait_def_id: DefId, trait_def_id: DefId,
start_from_impl: DefId, start_from_impl: DefId,
) -> Result<Ancestors<'tcx>, ErrorReported> { ) -> Result<Ancestors<'tcx>, ErrorGuaranteed> {
let specialization_graph = tcx.specialization_graph_of(trait_def_id); let specialization_graph = tcx.specialization_graph_of(trait_def_id);
if specialization_graph.has_errored || tcx.type_of(start_from_impl).references_error() { if specialization_graph.has_errored || tcx.type_of(start_from_impl).references_error() {
Err(ErrorReported) Err(ErrorGuaranteed)
} else { } else {
Ok(Ancestors { Ok(Ancestors {
trait_def_id, trait_def_id,

View file

@ -6,7 +6,7 @@ use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::HashingControls; use rustc_data_structures::stable_hasher::HashingControls;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{CtorKind, DefKind, Res}; use rustc_hir::def::{CtorKind, DefKind, Res};
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
@ -424,7 +424,7 @@ impl<'tcx> AdtDef {
} }
Err(err) => { Err(err) => {
let msg = match err { let msg = match err {
ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => { ErrorHandled::Reported(ErrorGuaranteed) | ErrorHandled::Linted => {
"enum discriminant evaluation failed" "enum discriminant evaluation failed"
} }
ErrorHandled::TooGeneric => "enum discriminant depends on generics", ErrorHandled::TooGeneric => "enum discriminant depends on generics",

View file

@ -5,7 +5,7 @@ use crate::ty::{
TyCtxt, TypeFoldable, TyCtxt, TypeFoldable,
}; };
use rustc_data_structures::intern::Interned; use rustc_data_structures::intern::Interned;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_macros::HashStable; use rustc_macros::HashStable;
@ -264,7 +264,7 @@ impl<'tcx> Const<'tcx> {
if let Some(val) = self.val().try_eval(tcx, param_env) { if let Some(val) = self.val().try_eval(tcx, param_env) {
match val { match val {
Ok(val) => Const::from_value(tcx, val, self.ty()), Ok(val) => Const::from_value(tcx, val, self.ty()),
Err(ErrorReported) => tcx.const_error(self.ty()), Err(ErrorGuaranteed) => tcx.const_error(self.ty()),
} }
} else { } else {
self self

View file

@ -5,7 +5,7 @@ use crate::mir::Promoted;
use crate::ty::subst::{InternalSubsts, SubstsRef}; use crate::ty::subst::{InternalSubsts, SubstsRef};
use crate::ty::ParamEnv; use crate::ty::ParamEnv;
use crate::ty::{self, TyCtxt, TypeFoldable}; use crate::ty::{self, TyCtxt, TypeFoldable};
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_macros::HashStable; use rustc_macros::HashStable;
use rustc_target::abi::Size; use rustc_target::abi::Size;
@ -130,7 +130,7 @@ impl<'tcx> ConstKind<'tcx> {
self, self,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
param_env: ParamEnv<'tcx>, param_env: ParamEnv<'tcx>,
) -> Option<Result<ConstValue<'tcx>, ErrorReported>> { ) -> Option<Result<ConstValue<'tcx>, ErrorGuaranteed>> {
if let ConstKind::Unevaluated(unevaluated) = self { if let ConstKind::Unevaluated(unevaluated) = self {
use crate::mir::interpret::ErrorHandled; use crate::mir::interpret::ErrorHandled;

View file

@ -33,7 +33,7 @@ use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap};
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::steal::Steal; use rustc_data_structures::steal::Steal;
use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal}; use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal};
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res}; use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LOCAL_CRATE}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LOCAL_CRATE};
@ -369,7 +369,7 @@ pub struct TypeckResults<'tcx> {
/// Resolved definitions for `<T>::X` associated paths and /// Resolved definitions for `<T>::X` associated paths and
/// method calls, including those of overloaded operators. /// method calls, including those of overloaded operators.
type_dependent_defs: ItemLocalMap<Result<(DefKind, DefId), ErrorReported>>, type_dependent_defs: ItemLocalMap<Result<(DefKind, DefId), ErrorGuaranteed>>,
/// Resolved field indices for field accesses in expressions (`S { field }`, `obj.field`) /// Resolved field indices for field accesses in expressions (`S { field }`, `obj.field`)
/// or patterns (`S { field }`). The index is often useful by itself, but to learn more /// or patterns (`S { field }`). The index is often useful by itself, but to learn more
@ -479,8 +479,8 @@ pub struct TypeckResults<'tcx> {
pub used_trait_imports: Lrc<FxHashSet<LocalDefId>>, pub used_trait_imports: Lrc<FxHashSet<LocalDefId>>,
/// If any errors occurred while type-checking this body, /// If any errors occurred while type-checking this body,
/// this field will be set to `Some(ErrorReported)`. /// this field will be set to `Some(ErrorGuaranteed)`.
pub tainted_by_errors: Option<ErrorReported>, pub tainted_by_errors: Option<ErrorGuaranteed>,
/// All the opaque types that are restricted to concrete types /// All the opaque types that are restricted to concrete types
/// by this function. /// by this function.
@ -569,7 +569,7 @@ impl<'tcx> TypeckResults<'tcx> {
pub fn type_dependent_defs( pub fn type_dependent_defs(
&self, &self,
) -> LocalTableInContext<'_, Result<(DefKind, DefId), ErrorReported>> { ) -> LocalTableInContext<'_, Result<(DefKind, DefId), ErrorGuaranteed>> {
LocalTableInContext { hir_owner: self.hir_owner, data: &self.type_dependent_defs } LocalTableInContext { hir_owner: self.hir_owner, data: &self.type_dependent_defs }
} }
@ -584,7 +584,7 @@ impl<'tcx> TypeckResults<'tcx> {
pub fn type_dependent_defs_mut( pub fn type_dependent_defs_mut(
&mut self, &mut self,
) -> LocalTableInContextMut<'_, Result<(DefKind, DefId), ErrorReported>> { ) -> LocalTableInContextMut<'_, Result<(DefKind, DefId), ErrorGuaranteed>> {
LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.type_dependent_defs } LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.type_dependent_defs }
} }

View file

@ -2,7 +2,7 @@ use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use crate::ty::print::{FmtPrinter, Printer}; use crate::ty::print::{FmtPrinter, Printer};
use crate::ty::subst::{InternalSubsts, Subst}; use crate::ty::subst::{InternalSubsts, Subst};
use crate::ty::{self, SubstsRef, Ty, TyCtxt, TypeFoldable}; use crate::ty::{self, SubstsRef, Ty, TyCtxt, TypeFoldable};
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir::def::Namespace; use rustc_hir::def::Namespace;
use rustc_hir::def_id::{CrateNum, DefId}; use rustc_hir::def_id::{CrateNum, DefId};
use rustc_hir::lang_items::LangItem; use rustc_hir::lang_items::LangItem;
@ -349,7 +349,7 @@ impl<'tcx> Instance<'tcx> {
/// in a monomorphic context (i.e., like during codegen), then it is guaranteed to return /// in a monomorphic context (i.e., like during codegen), then it is guaranteed to return
/// `Ok(Some(instance))`. /// `Ok(Some(instance))`.
/// ///
/// Returns `Err(ErrorReported)` when the `Instance` resolution process /// Returns `Err(ErrorGuaranteed)` when the `Instance` resolution process
/// couldn't complete due to errors elsewhere - this is distinct /// couldn't complete due to errors elsewhere - this is distinct
/// from `Ok(None)` to avoid misleading diagnostics when an error /// from `Ok(None)` to avoid misleading diagnostics when an error
/// has already been/will be emitted, for the original cause /// has already been/will be emitted, for the original cause
@ -358,7 +358,7 @@ impl<'tcx> Instance<'tcx> {
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
def_id: DefId, def_id: DefId,
substs: SubstsRef<'tcx>, substs: SubstsRef<'tcx>,
) -> Result<Option<Instance<'tcx>>, ErrorReported> { ) -> Result<Option<Instance<'tcx>>, ErrorGuaranteed> {
Instance::resolve_opt_const_arg( Instance::resolve_opt_const_arg(
tcx, tcx,
param_env, param_env,
@ -374,7 +374,7 @@ impl<'tcx> Instance<'tcx> {
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
def: ty::WithOptConstParam<DefId>, def: ty::WithOptConstParam<DefId>,
substs: SubstsRef<'tcx>, substs: SubstsRef<'tcx>,
) -> Result<Option<Instance<'tcx>>, ErrorReported> { ) -> Result<Option<Instance<'tcx>>, ErrorGuaranteed> {
// All regions in the result of this query are erased, so it's // All regions in the result of this query are erased, so it's
// fine to erase all of the input regions. // fine to erase all of the input regions.

View file

@ -37,7 +37,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_data_structures::steal::Steal; use rustc_data_structures::steal::Steal;
use rustc_data_structures::svh::Svh; use rustc_data_structures::svh::Svh;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId};

View file

@ -260,7 +260,7 @@ TrivialTypeFoldableAndLiftImpls! {
crate::ty::UniverseIndex, crate::ty::UniverseIndex,
crate::ty::Variance, crate::ty::Variance,
::rustc_span::Span, ::rustc_span::Span,
::rustc_errors::ErrorReported, ::rustc_errors::ErrorGuaranteed,
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////

View file

@ -7,7 +7,7 @@ use rustc_hir::def_id::DefId;
use rustc_hir::definitions::DefPathHash; use rustc_hir::definitions::DefPathHash;
use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_macros::HashStable; use rustc_macros::HashStable;
/// A trait's definition with type information. /// A trait's definition with type information.
@ -110,7 +110,7 @@ impl<'tcx> TraitDef {
&self, &self,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
of_impl: DefId, of_impl: DefId,
) -> Result<specialization_graph::Ancestors<'tcx>, ErrorReported> { ) -> Result<specialization_graph::Ancestors<'tcx>, ErrorGuaranteed> {
specialization_graph::ancestors(tcx, self.def_id, of_impl) specialization_graph::ancestors(tcx, self.def_id, of_impl)
} }
} }

View file

@ -15,7 +15,7 @@ use rustc_attr::{self as attr, SignedInt, UnsignedInt};
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::intern::Interned; use rustc_data_structures::intern::Interned;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def::{CtorOf, DefKind, Res};
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
@ -352,7 +352,7 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn calculate_dtor( pub fn calculate_dtor(
self, self,
adt_did: DefId, adt_did: DefId,
validate: impl Fn(Self, DefId) -> Result<(), ErrorReported>, validate: impl Fn(Self, DefId) -> Result<(), ErrorGuaranteed>,
) -> Option<ty::Destructor> { ) -> Option<ty::Destructor> {
let drop_trait = self.lang_items().drop_trait()?; let drop_trait = self.lang_items().drop_trait()?;
self.ensure().coherent_trait(drop_trait); self.ensure().coherent_trait(drop_trait);

View file

@ -2,7 +2,7 @@ use crate::build;
use crate::build::expr::as_place::PlaceBuilder; use crate::build::expr::as_place::PlaceBuilder;
use crate::build::scope::DropKind; use crate::build::scope::DropKind;
use crate::thir::pattern::pat_from_hir; use crate::thir::pattern::pat_from_hir;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::lang_items::LangItem; use rustc_hir::lang_items::LangItem;
@ -714,7 +714,7 @@ fn construct_error<'a, 'tcx>(
hir_id: hir::HirId, hir_id: hir::HirId,
body_id: hir::BodyId, body_id: hir::BodyId,
body_owner_kind: hir::BodyOwnerKind, body_owner_kind: hir::BodyOwnerKind,
err: ErrorReported, err: ErrorGuaranteed,
) -> Body<'tcx> { ) -> Body<'tcx> {
let tcx = infcx.tcx; let tcx = infcx.tcx;
let span = tcx.hir().span(hir_id); let span = tcx.hir().span(hir_id);

View file

@ -7,7 +7,7 @@ use super::{PatCtxt, PatternError};
use rustc_arena::TypedArena; use rustc_arena::TypedArena;
use rustc_ast::Mutability; use rustc_ast::Mutability;
use rustc_errors::{ use rustc_errors::{
error_code, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorReported, error_code, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
}; };
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::*; use rustc_hir::def::*;
@ -42,7 +42,7 @@ fn create_e0004(
sess: &Session, sess: &Session,
sp: Span, sp: Span,
error_message: String, error_message: String,
) -> DiagnosticBuilder<'_, ErrorReported> { ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
struct_span_err!(sess, sp, E0004, "{}", &error_message) struct_span_err!(sess, sp, E0004, "{}", &error_message)
} }

View file

@ -180,7 +180,7 @@
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::{par_iter, MTLock, MTRef, ParallelIterator}; use rustc_data_structures::sync::{par_iter, MTLock, MTRef, ParallelIterator};
use rustc_errors::{ErrorReported, FatalError}; use rustc_errors::{ErrorGuaranteed, FatalError};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId, LOCAL_CRATE}; use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId, LOCAL_CRATE};
use rustc_hir::itemlikevisit::ItemLikeVisitor; use rustc_hir::itemlikevisit::ItemLikeVisitor;
@ -716,7 +716,9 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
match self.tcx.const_eval_resolve(param_env, ct, None) { match self.tcx.const_eval_resolve(param_env, ct, None) {
// The `monomorphize` call should have evaluated that constant already. // The `monomorphize` call should have evaluated that constant already.
Ok(val) => val, Ok(val) => val,
Err(ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted) => return, Err(ErrorHandled::Reported(ErrorGuaranteed) | ErrorHandled::Linted) => {
return;
}
Err(ErrorHandled::TooGeneric) => span_bug!( Err(ErrorHandled::TooGeneric) => span_bug!(
self.body.source_info(location).span, self.body.source_info(location).span,
"collection encountered polymorphic constant: {:?}", "collection encountered polymorphic constant: {:?}",
@ -748,7 +750,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
substituted_constant, substituted_constant,
val val
), ),
Err(ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted) => {} Err(ErrorHandled::Reported(ErrorGuaranteed) | ErrorHandled::Linted) => {}
Err(ErrorHandled::TooGeneric) => span_bug!( Err(ErrorHandled::TooGeneric) => span_bug!(
self.body.source_info(location).span, self.body.source_info(location).span,
"collection encountered polymorphic constant: {}", "collection encountered polymorphic constant: {}",

View file

@ -4,7 +4,7 @@ use rustc_ast::token::{self, CommentKind, Token, TokenKind};
use rustc_ast::tokenstream::{Spacing, TokenStream}; use rustc_ast::tokenstream::{Spacing, TokenStream};
use rustc_ast::util::unicode::contains_text_flow_control_chars; use rustc_ast::util::unicode::contains_text_flow_control_chars;
use rustc_errors::{ use rustc_errors::{
error_code, Applicability, DiagnosticBuilder, ErrorReported, FatalError, PResult, error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, FatalError, PResult,
}; };
use rustc_lexer::unescape::{self, Mode}; use rustc_lexer::unescape::{self, Mode};
use rustc_lexer::{Base, DocStyle, RawStrError}; use rustc_lexer::{Base, DocStyle, RawStrError};
@ -129,7 +129,7 @@ impl<'a> StringReader<'a> {
to_pos: BytePos, to_pos: BytePos,
m: &str, m: &str,
c: char, c: char,
) -> DiagnosticBuilder<'a, ErrorReported> { ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
self.sess self.sess
.span_diagnostic .span_diagnostic
.struct_span_fatal(self.mk_sp(from_pos, to_pos), &format!("{}: {}", m, escaped_char(c))) .struct_span_fatal(self.mk_sp(from_pos, to_pos), &format!("{}: {}", m, escaped_char(c)))

View file

@ -16,7 +16,7 @@ use rustc_ast::{
}; };
use rustc_ast_pretty::pprust; use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{pluralize, struct_span_err, Diagnostic, ErrorReported}; use rustc_errors::{pluralize, struct_span_err, Diagnostic, ErrorGuaranteed};
use rustc_errors::{Applicability, DiagnosticBuilder, Handler, PResult}; use rustc_errors::{Applicability, DiagnosticBuilder, Handler, PResult};
use rustc_span::source_map::Spanned; use rustc_span::source_map::Spanned;
use rustc_span::symbol::{kw, Ident}; use rustc_span::symbol::{kw, Ident};
@ -57,7 +57,7 @@ impl Error {
self, self,
sp: impl Into<MultiSpan>, sp: impl Into<MultiSpan>,
handler: &Handler, handler: &Handler,
) -> DiagnosticBuilder<'_, ErrorReported> { ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
match self { match self {
Error::UselessDocComment => { Error::UselessDocComment => {
let mut err = struct_span_err!( let mut err = struct_span_err!(
@ -159,7 +159,7 @@ impl<'a> Parser<'a> {
&self, &self,
sp: S, sp: S,
err: Error, err: Error,
) -> DiagnosticBuilder<'a, ErrorReported> { ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
err.span_err(sp, self.diagnostic()) err.span_err(sp, self.diagnostic())
} }
@ -167,7 +167,7 @@ impl<'a> Parser<'a> {
&self, &self,
sp: S, sp: S,
m: &str, m: &str,
) -> DiagnosticBuilder<'a, ErrorReported> { ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
self.sess.span_diagnostic.struct_span_err(sp, m) self.sess.span_diagnostic.struct_span_err(sp, m)
} }
@ -183,7 +183,7 @@ impl<'a> Parser<'a> {
self.sess.source_map().span_to_snippet(span) self.sess.source_map().span_to_snippet(span)
} }
pub(super) fn expected_ident_found(&self) -> DiagnosticBuilder<'a, ErrorReported> { pub(super) fn expected_ident_found(&self) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let mut err = self.struct_span_err( let mut err = self.struct_span_err(
self.token.span, self.token.span,
&format!("expected identifier, found {}", super::token_descr(&self.token)), &format!("expected identifier, found {}", super::token_descr(&self.token)),
@ -729,7 +729,7 @@ impl<'a> Parser<'a> {
/// encounter a parse error when encountering the first `,`. /// encounter a parse error when encountering the first `,`.
pub(super) fn check_mistyped_turbofish_with_multiple_type_params( pub(super) fn check_mistyped_turbofish_with_multiple_type_params(
&mut self, &mut self,
mut e: DiagnosticBuilder<'a, ErrorReported>, mut e: DiagnosticBuilder<'a, ErrorGuaranteed>,
expr: &mut P<Expr>, expr: &mut P<Expr>,
) -> PResult<'a, ()> { ) -> PResult<'a, ()> {
if let ExprKind::Binary(binop, _, _) = &expr.kind if let ExprKind::Binary(binop, _, _) = &expr.kind
@ -1451,7 +1451,7 @@ impl<'a> Parser<'a> {
pub(super) fn recover_closing_delimiter( pub(super) fn recover_closing_delimiter(
&mut self, &mut self,
tokens: &[TokenKind], tokens: &[TokenKind],
mut err: DiagnosticBuilder<'a, ErrorReported>, mut err: DiagnosticBuilder<'a, ErrorGuaranteed>,
) -> PResult<'a, bool> { ) -> PResult<'a, bool> {
let mut pos = None; let mut pos = None;
// We want to use the last closing delim that would apply. // We want to use the last closing delim that would apply.
@ -1822,7 +1822,7 @@ impl<'a> Parser<'a> {
} }
} }
pub(super) fn expected_expression_found(&self) -> DiagnosticBuilder<'a, ErrorReported> { pub(super) fn expected_expression_found(&self) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let (span, msg) = match (&self.token.kind, self.subparser_name) { let (span, msg) = match (&self.token.kind, self.subparser_name) {
(&token::Eof, Some(origin)) => { (&token::Eof, Some(origin)) => {
let sp = self.sess.source_map().next_point(self.prev_token.span); let sp = self.sess.source_map().next_point(self.prev_token.span);
@ -2028,7 +2028,7 @@ impl<'a> Parser<'a> {
pub fn recover_const_arg( pub fn recover_const_arg(
&mut self, &mut self,
start: Span, start: Span,
mut err: DiagnosticBuilder<'a, ErrorReported>, mut err: DiagnosticBuilder<'a, ErrorGuaranteed>,
) -> PResult<'a, GenericArg> { ) -> PResult<'a, GenericArg> {
let is_op_or_dot = AssocOp::from_token(&self.token) let is_op_or_dot = AssocOp::from_token(&self.token)
.and_then(|op| { .and_then(|op| {
@ -2095,7 +2095,7 @@ impl<'a> Parser<'a> {
/// Creates a dummy const argument, and reports that the expression must be enclosed in braces /// Creates a dummy const argument, and reports that the expression must be enclosed in braces
pub fn dummy_const_arg_needs_braces( pub fn dummy_const_arg_needs_braces(
&self, &self,
mut err: DiagnosticBuilder<'a, ErrorReported>, mut err: DiagnosticBuilder<'a, ErrorGuaranteed>,
span: Span, span: Span,
) -> GenericArg { ) -> GenericArg {
err.multipart_suggestion( err.multipart_suggestion(
@ -2115,7 +2115,7 @@ impl<'a> Parser<'a> {
pub(super) fn incorrect_move_async_order_found( pub(super) fn incorrect_move_async_order_found(
&self, &self,
move_async_span: Span, move_async_span: Span,
) -> DiagnosticBuilder<'a, ErrorReported> { ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let mut err = let mut err =
self.struct_span_err(move_async_span, "the order of `move` and `async` is incorrect"); self.struct_span_err(move_async_span, "the order of `move` and `async` is incorrect");
err.span_suggestion_verbose( err.span_suggestion_verbose(

View file

@ -17,7 +17,7 @@ use rustc_ast::{self as ast, AttrStyle, AttrVec, CaptureBy, ExprField, Lit, UnOp
use rustc_ast::{AnonConst, BinOp, BinOpKind, FnDecl, FnRetTy, MacCall, Param, Ty, TyKind}; use rustc_ast::{AnonConst, BinOp, BinOpKind, FnDecl, FnRetTy, MacCall, Param, Ty, TyKind};
use rustc_ast::{Arm, Async, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLimits}; use rustc_ast::{Arm, Async, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLimits};
use rustc_ast_pretty::pprust; use rustc_ast_pretty::pprust;
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorReported, PResult}; use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, PResult};
use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP; use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP;
use rustc_session::lint::BuiltinLintDiagnostics; use rustc_session::lint::BuiltinLintDiagnostics;
use rustc_span::edition::LATEST_STABLE_EDITION; use rustc_span::edition::LATEST_STABLE_EDITION;
@ -2126,9 +2126,9 @@ impl<'a> Parser<'a> {
fn error_missing_if_then_block( fn error_missing_if_then_block(
&self, &self,
if_span: Span, if_span: Span,
err: Option<DiagnosticBuilder<'a, ErrorReported>>, err: Option<DiagnosticBuilder<'a, ErrorGuaranteed>>,
binop_span: Option<Span>, binop_span: Option<Span>,
) -> DiagnosticBuilder<'a, ErrorReported> { ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let msg = "this `if` expression has a condition, but no block"; let msg = "this `if` expression has a condition, but no block";
let mut err = if let Some(mut err) = err { let mut err = if let Some(mut err) = err {

View file

@ -13,7 +13,7 @@ use rustc_ast::{EnumDef, FieldDef, Generics, TraitRef, Ty, TyKind, Variant, Vari
use rustc_ast::{FnHeader, ForeignItem, Path, PathSegment, Visibility, VisibilityKind}; use rustc_ast::{FnHeader, ForeignItem, Path, PathSegment, Visibility, VisibilityKind};
use rustc_ast::{MacArgs, MacCall, MacDelimiter}; use rustc_ast::{MacArgs, MacCall, MacDelimiter};
use rustc_ast_pretty::pprust; use rustc_ast_pretty::pprust;
use rustc_errors::{struct_span_err, Applicability, ErrorReported, PResult, StashKey}; use rustc_errors::{struct_span_err, Applicability, ErrorGuaranteed, PResult, StashKey};
use rustc_span::edition::{Edition, LATEST_STABLE_EDITION}; use rustc_span::edition::{Edition, LATEST_STABLE_EDITION};
use rustc_span::lev_distance::lev_distance; use rustc_span::lev_distance::lev_distance;
use rustc_span::source_map::{self, Span}; use rustc_span::source_map::{self, Span};
@ -799,7 +799,7 @@ impl<'a> Parser<'a> {
before_where_clause_span: Span, before_where_clause_span: Span,
after_predicates: &[WherePredicate], after_predicates: &[WherePredicate],
after_where_clause_span: Span, after_where_clause_span: Span,
) -> ErrorReported { ) -> ErrorGuaranteed {
let mut err = let mut err =
self.struct_span_err(after_where_clause_span, "where clause not allowed here"); self.struct_span_err(after_where_clause_span, "where clause not allowed here");
if !after_predicates.is_empty() { if !after_predicates.is_empty() {

View file

@ -32,7 +32,9 @@ use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_errors::PResult; use rustc_errors::PResult;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorReported, FatalError}; use rustc_errors::{
struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, FatalError,
};
use rustc_session::parse::ParseSess; use rustc_session::parse::ParseSess;
use rustc_span::source_map::{MultiSpan, Span, DUMMY_SP}; use rustc_span::source_map::{MultiSpan, Span, DUMMY_SP};
use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::symbol::{kw, sym, Ident, Symbol};
@ -877,7 +879,7 @@ impl<'a> Parser<'a> {
fn recover_missing_braces_around_closure_body( fn recover_missing_braces_around_closure_body(
&mut self, &mut self,
closure_spans: ClosureSpans, closure_spans: ClosureSpans,
mut expect_err: DiagnosticBuilder<'_, ErrorReported>, mut expect_err: DiagnosticBuilder<'_, ErrorGuaranteed>,
) -> PResult<'a, ()> { ) -> PResult<'a, ()> {
let initial_semicolon = self.token.span; let initial_semicolon = self.token.span;
@ -1429,7 +1431,7 @@ impl<'a> Parser<'a> {
crate fn make_unclosed_delims_error( crate fn make_unclosed_delims_error(
unmatched: UnmatchedBrace, unmatched: UnmatchedBrace,
sess: &ParseSess, sess: &ParseSess,
) -> Option<DiagnosticBuilder<'_, ErrorReported>> { ) -> Option<DiagnosticBuilder<'_, ErrorGuaranteed>> {
// `None` here means an `Eof` was found. We already emit those errors elsewhere, we add them to // `None` here means an `Eof` was found. We already emit those errors elsewhere, we add them to
// `unmatched_braces` only for error recovery in the `Parser`. // `unmatched_braces` only for error recovery in the `Parser`.
let found_delim = unmatched.found_delim?; let found_delim = unmatched.found_delim?;

View file

@ -8,7 +8,7 @@ use rustc_ast::{
PatField, PatKind, Path, QSelf, RangeEnd, RangeSyntax, PatField, PatKind, Path, QSelf, RangeEnd, RangeSyntax,
}; };
use rustc_ast_pretty::pprust; use rustc_ast_pretty::pprust;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorReported, PResult}; use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, PResult};
use rustc_span::source_map::{respan, Span, Spanned}; use rustc_span::source_map::{respan, Span, Spanned};
use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::symbol::{kw, sym, Ident};
@ -678,7 +678,7 @@ impl<'a> Parser<'a> {
fn fatal_unexpected_non_pat( fn fatal_unexpected_non_pat(
&mut self, &mut self,
err: DiagnosticBuilder<'a, ErrorReported>, err: DiagnosticBuilder<'a, ErrorGuaranteed>,
expected: Expected, expected: Expected,
) -> PResult<'a, P<Pat>> { ) -> PResult<'a, P<Pat>> {
err.cancel(); err.cancel();
@ -914,7 +914,7 @@ impl<'a> Parser<'a> {
let mut fields = Vec::new(); let mut fields = Vec::new();
let mut etc = false; let mut etc = false;
let mut ate_comma = true; let mut ate_comma = true;
let mut delayed_err: Option<DiagnosticBuilder<'a, ErrorReported>> = None; let mut delayed_err: Option<DiagnosticBuilder<'a, ErrorGuaranteed>> = None;
let mut etc_span = None; let mut etc_span = None;
while self.token != token::CloseDelim(token::Brace) { while self.token != token::CloseDelim(token::Brace) {

View file

@ -18,7 +18,7 @@ use rustc_ast::{
}; };
use rustc_ast::{Block, BlockCheckMode, Expr, ExprKind, Local, Stmt}; use rustc_ast::{Block, BlockCheckMode, Expr, ExprKind, Local, Stmt};
use rustc_ast::{StmtKind, DUMMY_NODE_ID}; use rustc_ast::{StmtKind, DUMMY_NODE_ID};
use rustc_errors::{Applicability, DiagnosticBuilder, ErrorReported, PResult}; use rustc_errors::{Applicability, DiagnosticBuilder, ErrorGuaranteed, PResult};
use rustc_span::source_map::{BytePos, Span}; use rustc_span::source_map::{BytePos, Span};
use rustc_span::symbol::{kw, sym}; use rustc_span::symbol::{kw, sym};
@ -415,7 +415,7 @@ impl<'a> Parser<'a> {
fn error_block_no_opening_brace_msg( fn error_block_no_opening_brace_msg(
&mut self, &mut self,
msg: &str, msg: &str,
) -> DiagnosticBuilder<'a, ErrorReported> { ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let sp = self.token.span; let sp = self.token.span;
let mut e = self.struct_span_err(sp, msg); let mut e = self.struct_span_err(sp, msg);
let do_not_suggest_help = self.token.is_keyword(kw::In) || self.token == token::Colon; let do_not_suggest_help = self.token.is_keyword(kw::In) || self.token == token::Colon;

View file

@ -7,7 +7,7 @@ use crate::query::caches::QueryCache;
use crate::query::{QueryContext, QueryState}; use crate::query::{QueryContext, QueryState};
use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fingerprint::Fingerprint;
use rustc_errors::{DiagnosticBuilder, ErrorReported}; use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
use std::fmt::Debug; use std::fmt::Debug;
use std::hash::Hash; use std::hash::Hash;
@ -27,7 +27,7 @@ pub struct QueryVtable<CTX: QueryContext, K, V> {
pub compute: fn(CTX::DepContext, K) -> V, pub compute: fn(CTX::DepContext, K) -> V,
pub hash_result: Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>, pub hash_result: Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>,
pub handle_cycle_error: fn(CTX, DiagnosticBuilder<'_, ErrorReported>) -> V, pub handle_cycle_error: fn(CTX, DiagnosticBuilder<'_, ErrorGuaranteed>) -> V,
pub try_load_from_disk: Option<fn(CTX, SerializedDepNodeIndex) -> Option<V>>, pub try_load_from_disk: Option<fn(CTX, SerializedDepNodeIndex) -> Option<V>>,
} }

View file

@ -4,7 +4,9 @@ use crate::query::{QueryContext, QueryStackFrame};
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{struct_span_err, Diagnostic, DiagnosticBuilder, ErrorReported, Handler, Level}; use rustc_errors::{
struct_span_err, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, Handler, Level,
};
use rustc_session::Session; use rustc_session::Session;
use rustc_span::Span; use rustc_span::Span;
@ -530,7 +532,7 @@ pub fn deadlock<CTX: QueryContext>(tcx: CTX, registry: &rayon_core::Registry) {
pub(crate) fn report_cycle<'a>( pub(crate) fn report_cycle<'a>(
sess: &'a Session, sess: &'a Session,
CycleError { usage, cycle: stack }: CycleError, CycleError { usage, cycle: stack }: CycleError,
) -> DiagnosticBuilder<'a, ErrorReported> { ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
assert!(!stack.is_empty()); assert!(!stack.is_empty());
let fix_span = |span: Span, query: &QueryStackFrame| { let fix_span = |span: Span, query: &QueryStackFrame| {

View file

@ -15,7 +15,7 @@ use rustc_data_structures::profiling::TimingGuard;
use rustc_data_structures::sharded::Sharded; use rustc_data_structures::sharded::Sharded;
use rustc_data_structures::sync::Lock; use rustc_data_structures::sync::Lock;
use rustc_data_structures::thin_vec::ThinVec; use rustc_data_structures::thin_vec::ThinVec;
use rustc_errors::{DiagnosticBuilder, ErrorReported, FatalError}; use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed, FatalError};
use rustc_session::Session; use rustc_session::Session;
use rustc_span::{Span, DUMMY_SP}; use rustc_span::{Span, DUMMY_SP};
use std::cell::Cell; use std::cell::Cell;
@ -118,7 +118,7 @@ where
fn mk_cycle<CTX, V, R>( fn mk_cycle<CTX, V, R>(
tcx: CTX, tcx: CTX,
error: CycleError, error: CycleError,
handle_cycle_error: fn(CTX, DiagnosticBuilder<'_, ErrorReported>) -> V, handle_cycle_error: fn(CTX, DiagnosticBuilder<'_, ErrorGuaranteed>) -> V,
cache: &dyn crate::query::QueryStorage<Value = V, Stored = R>, cache: &dyn crate::query::QueryStorage<Value = V, Stored = R>,
) -> R ) -> R
where where

View file

@ -3,7 +3,9 @@ use std::ptr;
use rustc_ast::{self as ast, Path}; use rustc_ast::{self as ast, Path};
use rustc_ast_pretty::pprust; use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorReported}; use rustc_errors::{
struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
};
use rustc_feature::BUILTIN_ATTRIBUTES; use rustc_feature::BUILTIN_ATTRIBUTES;
use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::Namespace::{self, *};
use rustc_hir::def::{self, CtorKind, CtorOf, DefKind, NonMacroAttrKind}; use rustc_hir::def::{self, CtorKind, CtorOf, DefKind, NonMacroAttrKind};
@ -110,7 +112,7 @@ impl<'a> Resolver<'a> {
&self, &self,
span: Span, span: Span,
resolution_error: ResolutionError<'_>, resolution_error: ResolutionError<'_>,
) -> DiagnosticBuilder<'_, ErrorReported> { ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
match resolution_error { match resolution_error {
ResolutionError::GenericParamsFromOuterFunction(outer_res, has_generic_params) => { ResolutionError::GenericParamsFromOuterFunction(outer_res, has_generic_params) => {
let mut err = struct_span_err!( let mut err = struct_span_err!(
@ -627,7 +629,7 @@ impl<'a> Resolver<'a> {
crate fn report_vis_error( crate fn report_vis_error(
&self, &self,
vis_resolution_error: VisResolutionError<'_>, vis_resolution_error: VisResolutionError<'_>,
) -> ErrorReported { ) -> ErrorGuaranteed {
match vis_resolution_error { match vis_resolution_error {
VisResolutionError::Relative2018(span, path) => { VisResolutionError::Relative2018(span, path) => {
let mut err = self.session.struct_span_err( let mut err = self.session.struct_span_err(

View file

@ -13,7 +13,7 @@ use rustc_ast::{
use rustc_ast_pretty::pprust::path_segment_to_string; use rustc_ast_pretty::pprust::path_segment_to_string;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{ use rustc_errors::{
pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorReported, pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
}; };
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::Namespace::{self, *};
@ -135,7 +135,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
span: Span, span: Span,
source: PathSource<'_>, source: PathSource<'_>,
res: Option<Res>, res: Option<Res>,
) -> (DiagnosticBuilder<'a, ErrorReported>, Vec<ImportSuggestion>) { ) -> (DiagnosticBuilder<'a, ErrorGuaranteed>, Vec<ImportSuggestion>) {
let ident_span = path.last().map_or(span, |ident| ident.ident.span); let ident_span = path.last().map_or(span, |ident| ident.ident.span);
let ns = source.namespace(); let ns = source.namespace();
let is_expected = &|res| source.is_expected(res); let is_expected = &|res| source.is_expected(res);
@ -1819,7 +1819,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
&self, &self,
spans: Vec<Span>, spans: Vec<Span>,
count: usize, count: usize,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
struct_span_err!( struct_span_err!(
self.tcx.sess, self.tcx.sess,
spans, spans,

View file

@ -40,7 +40,9 @@ use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_data_structures::intern::Interned; use rustc_data_structures::intern::Interned;
use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::Lrc;
use rustc_errors::{struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorReported}; use rustc_errors::{
struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
};
use rustc_expand::base::{DeriveResolutions, SyntaxExtension, SyntaxExtensionKind}; use rustc_expand::base::{DeriveResolutions, SyntaxExtension, SyntaxExtensionKind};
use rustc_hir::def::Namespace::*; use rustc_hir::def::Namespace::*;
use rustc_hir::def::{self, CtorOf, DefKind, NonMacroAttrKind, PartialRes}; use rustc_hir::def::{self, CtorOf, DefKind, NonMacroAttrKind, PartialRes};
@ -713,7 +715,7 @@ struct PrivacyError<'a> {
} }
struct UseError<'a> { struct UseError<'a> {
err: DiagnosticBuilder<'a, ErrorReported>, err: DiagnosticBuilder<'a, ErrorGuaranteed>,
/// Candidates which user could `use` to access the missing type. /// Candidates which user could `use` to access the missing type.
candidates: Vec<ImportSuggestion>, candidates: Vec<ImportSuggestion>,
/// The `DefId` of the module to place the use-statements in. /// The `DefId` of the module to place the use-statements in.

View file

@ -7,7 +7,7 @@ use rustc_ast::node_id::NodeId;
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::{Lock, Lrc}; use rustc_data_structures::sync::{Lock, Lrc};
use rustc_errors::{emitter::SilentEmitter, ColorConfig, Handler}; use rustc_errors::{emitter::SilentEmitter, ColorConfig, Handler};
use rustc_errors::{error_code, Applicability, Diagnostic, DiagnosticBuilder, ErrorReported}; use rustc_errors::{error_code, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures}; use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
use rustc_span::edition::Edition; use rustc_span::edition::Edition;
use rustc_span::hygiene::ExpnId; use rustc_span::hygiene::ExpnId;
@ -82,7 +82,7 @@ pub fn feature_err<'a>(
feature: Symbol, feature: Symbol,
span: impl Into<MultiSpan>, span: impl Into<MultiSpan>,
explain: &str, explain: &str,
) -> DiagnosticBuilder<'a, ErrorReported> { ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
feature_err_issue(sess, feature, span, GateIssue::Language, explain) feature_err_issue(sess, feature, span, GateIssue::Language, explain)
} }
@ -96,7 +96,7 @@ pub fn feature_err_issue<'a>(
span: impl Into<MultiSpan>, span: impl Into<MultiSpan>,
issue: GateIssue, issue: GateIssue,
explain: &str, explain: &str,
) -> DiagnosticBuilder<'a, ErrorReported> { ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let mut err = sess.span_diagnostic.struct_span_err_with_code(span, explain, error_code!(E0658)); let mut err = sess.span_diagnostic.struct_span_err_with_code(span, explain, error_code!(E0658));
if let Some(n) = find_feature_issue(feature, issue) { if let Some(n) = find_feature_issue(feature, issue) {

View file

@ -19,7 +19,7 @@ use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitterWriter;
use rustc_errors::emitter::{Emitter, EmitterWriter, HumanReadableErrorType}; use rustc_errors::emitter::{Emitter, EmitterWriter, HumanReadableErrorType};
use rustc_errors::json::JsonEmitter; use rustc_errors::json::JsonEmitter;
use rustc_errors::registry::Registry; use rustc_errors::registry::Registry;
use rustc_errors::{Diagnostic, DiagnosticBuilder, DiagnosticId, ErrorReported}; use rustc_errors::{Diagnostic, DiagnosticBuilder, DiagnosticId, ErrorGuaranteed};
use rustc_macros::HashStable_Generic; use rustc_macros::HashStable_Generic;
pub use rustc_span::def_id::StableCrateId; pub use rustc_span::def_id::StableCrateId;
use rustc_span::edition::Edition; use rustc_span::edition::Edition;
@ -221,7 +221,7 @@ enum DiagnosticBuilderMethod {
pub trait SessionDiagnostic<'a> { pub trait SessionDiagnostic<'a> {
/// Write out as a diagnostic out of `sess`. /// Write out as a diagnostic out of `sess`.
#[must_use] #[must_use]
fn into_diagnostic(self, sess: &'a Session) -> DiagnosticBuilder<'a, ErrorReported>; fn into_diagnostic(self, sess: &'a Session) -> DiagnosticBuilder<'a, ErrorGuaranteed>;
} }
/// Diagnostic message ID, used by `Session.one_time_diagnostics` to avoid /// Diagnostic message ID, used by `Session.one_time_diagnostics` to avoid
@ -335,7 +335,7 @@ impl Session {
&self, &self,
sp: S, sp: S,
msg: &str, msg: &str,
) -> DiagnosticBuilder<'_, ErrorReported> { ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_span_err(sp, msg) self.diagnostic().struct_span_err(sp, msg)
} }
pub fn struct_span_err_with_code<S: Into<MultiSpan>>( pub fn struct_span_err_with_code<S: Into<MultiSpan>>(
@ -343,25 +343,25 @@ impl Session {
sp: S, sp: S,
msg: &str, msg: &str,
code: DiagnosticId, code: DiagnosticId,
) -> DiagnosticBuilder<'_, ErrorReported> { ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_span_err_with_code(sp, msg, code) self.diagnostic().struct_span_err_with_code(sp, msg, code)
} }
// FIXME: This method should be removed (every error should have an associated error code). // FIXME: This method should be removed (every error should have an associated error code).
pub fn struct_err(&self, msg: &str) -> DiagnosticBuilder<'_, ErrorReported> { pub fn struct_err(&self, msg: &str) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_err(msg) self.diagnostic().struct_err(msg)
} }
pub fn struct_err_with_code( pub fn struct_err_with_code(
&self, &self,
msg: &str, msg: &str,
code: DiagnosticId, code: DiagnosticId,
) -> DiagnosticBuilder<'_, ErrorReported> { ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_err_with_code(msg, code) self.diagnostic().struct_err_with_code(msg, code)
} }
pub fn struct_span_fatal<S: Into<MultiSpan>>( pub fn struct_span_fatal<S: Into<MultiSpan>>(
&self, &self,
sp: S, sp: S,
msg: &str, msg: &str,
) -> DiagnosticBuilder<'_, ErrorReported> { ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_span_fatal(sp, msg) self.diagnostic().struct_span_fatal(sp, msg)
} }
pub fn struct_span_fatal_with_code<S: Into<MultiSpan>>( pub fn struct_span_fatal_with_code<S: Into<MultiSpan>>(
@ -369,10 +369,10 @@ impl Session {
sp: S, sp: S,
msg: &str, msg: &str,
code: DiagnosticId, code: DiagnosticId,
) -> DiagnosticBuilder<'_, ErrorReported> { ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_span_fatal_with_code(sp, msg, code) self.diagnostic().struct_span_fatal_with_code(sp, msg, code)
} }
pub fn struct_fatal(&self, msg: &str) -> DiagnosticBuilder<'_, ErrorReported> { pub fn struct_fatal(&self, msg: &str) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_fatal(msg) self.diagnostic().struct_fatal(msg)
} }
@ -406,7 +406,7 @@ impl Session {
pub fn err(&self, msg: &str) { pub fn err(&self, msg: &str) {
self.diagnostic().err(msg) self.diagnostic().err(msg)
} }
pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorReported { pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorGuaranteed {
err.into_diagnostic(self).emit() err.into_diagnostic(self).emit()
} }
#[inline] #[inline]
@ -422,22 +422,22 @@ impl Session {
pub fn abort_if_errors(&self) { pub fn abort_if_errors(&self) {
self.diagnostic().abort_if_errors(); self.diagnostic().abort_if_errors();
} }
pub fn compile_status(&self) -> Result<(), ErrorReported> { pub fn compile_status(&self) -> Result<(), ErrorGuaranteed> {
if self.diagnostic().has_errors_or_lint_errors() { if self.diagnostic().has_errors_or_lint_errors() {
self.diagnostic().emit_stashed_diagnostics(); self.diagnostic().emit_stashed_diagnostics();
Err(ErrorReported) Err(ErrorGuaranteed)
} else { } else {
Ok(()) Ok(())
} }
} }
// FIXME(matthewjasper) Remove this method, it should never be needed. // FIXME(matthewjasper) Remove this method, it should never be needed.
pub fn track_errors<F, T>(&self, f: F) -> Result<T, ErrorReported> pub fn track_errors<F, T>(&self, f: F) -> Result<T, ErrorGuaranteed>
where where
F: FnOnce() -> T, F: FnOnce() -> T,
{ {
let old_count = self.err_count(); let old_count = self.err_count();
let result = f(); let result = f();
if self.err_count() == old_count { Ok(result) } else { Err(ErrorReported) } if self.err_count() == old_count { Ok(result) } else { Err(ErrorGuaranteed) }
} }
pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: &str) { pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
self.diagnostic().span_warn(sp, msg) self.diagnostic().span_warn(sp, msg)

View file

@ -8,7 +8,7 @@ use crate::traits::{
FulfillmentContext, ImplSource, Obligation, ObligationCause, SelectionContext, TraitEngine, FulfillmentContext, ImplSource, Obligation, ObligationCause, SelectionContext, TraitEngine,
Unimplemented, Unimplemented,
}; };
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::{self, TyCtxt}; use rustc_middle::ty::{self, TyCtxt};
@ -22,7 +22,7 @@ use rustc_middle::ty::{self, TyCtxt};
pub fn codegen_fulfill_obligation<'tcx>( pub fn codegen_fulfill_obligation<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
(param_env, trait_ref): (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>), (param_env, trait_ref): (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>),
) -> Result<&'tcx ImplSource<'tcx, ()>, ErrorReported> { ) -> Result<&'tcx ImplSource<'tcx, ()>, ErrorGuaranteed> {
// Remove any references to regions; this helps improve caching. // Remove any references to regions; this helps improve caching.
let trait_ref = tcx.erase_regions(trait_ref); let trait_ref = tcx.erase_regions(trait_ref);
// We expect the input to be fully normalized. // We expect the input to be fully normalized.
@ -59,7 +59,7 @@ pub fn codegen_fulfill_obligation<'tcx>(
trait_ref trait_ref
), ),
); );
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
Err(Unimplemented) => { Err(Unimplemented) => {
// This can trigger when we probe for the source of a `'static` lifetime requirement // This can trigger when we probe for the source of a `'static` lifetime requirement
@ -73,7 +73,7 @@ pub fn codegen_fulfill_obligation<'tcx>(
trait_ref trait_ref
), ),
); );
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
Err(e) => { Err(e) => {
bug!("Encountered error `{:?}` selecting `{:?}` during codegen", e, trait_ref) bug!("Encountered error `{:?}` selecting `{:?}` during codegen", e, trait_ref)

View file

@ -9,7 +9,7 @@
//! `thir_abstract_const` which can then be checked for structural equality with other //! `thir_abstract_const` which can then be checked for structural equality with other
//! generic constants mentioned in the `caller_bounds` of the current environment. //! generic constants mentioned in the `caller_bounds` of the current environment.
use rustc_data_structures::intern::Interned; use rustc_data_structures::intern::Interned;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;
use rustc_index::vec::IndexVec; use rustc_index::vec::IndexVec;
use rustc_infer::infer::InferCtxt; use rustc_infer::infer::InferCtxt;
@ -171,7 +171,7 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
}), }),
Err(ErrorHandled::Linted) => { Err(ErrorHandled::Linted) => {
infcx.tcx.sess.delay_span_bug(span, "constant in type had error reported as lint"); infcx.tcx.sess.delay_span_bug(span, "constant in type had error reported as lint");
Err(NotConstEvaluatable::Error(ErrorReported)) Err(NotConstEvaluatable::Error(ErrorGuaranteed))
} }
Err(ErrorHandled::Reported(e)) => Err(NotConstEvaluatable::Error(e)), Err(ErrorHandled::Reported(e)) => Err(NotConstEvaluatable::Error(e)),
Ok(_) => Ok(()), Ok(_) => Ok(()),
@ -194,7 +194,7 @@ impl<'tcx> AbstractConst<'tcx> {
pub fn new( pub fn new(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
uv: ty::Unevaluated<'tcx, ()>, uv: ty::Unevaluated<'tcx, ()>,
) -> Result<Option<AbstractConst<'tcx>>, ErrorReported> { ) -> Result<Option<AbstractConst<'tcx>>, ErrorGuaranteed> {
let inner = tcx.thir_abstract_const_opt_const_arg(uv.def)?; let inner = tcx.thir_abstract_const_opt_const_arg(uv.def)?;
debug!("AbstractConst::new({:?}) = {:?}", uv, inner); debug!("AbstractConst::new({:?}) = {:?}", uv, inner);
Ok(inner.map(|inner| AbstractConst { inner, substs: uv.substs })) Ok(inner.map(|inner| AbstractConst { inner, substs: uv.substs }))
@ -203,10 +203,10 @@ impl<'tcx> AbstractConst<'tcx> {
pub fn from_const( pub fn from_const(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
ct: ty::Const<'tcx>, ct: ty::Const<'tcx>,
) -> Result<Option<AbstractConst<'tcx>>, ErrorReported> { ) -> Result<Option<AbstractConst<'tcx>>, ErrorGuaranteed> {
match ct.val() { match ct.val() {
ty::ConstKind::Unevaluated(uv) => AbstractConst::new(tcx, uv.shrink()), ty::ConstKind::Unevaluated(uv) => AbstractConst::new(tcx, uv.shrink()),
ty::ConstKind::Error(_) => Err(ErrorReported), ty::ConstKind::Error(_) => Err(ErrorGuaranteed),
_ => Ok(None), _ => Ok(None),
} }
} }
@ -241,7 +241,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
self.body.exprs[self.body_id].span self.body.exprs[self.body_id].span
} }
fn error(&mut self, span: Span, msg: &str) -> Result<!, ErrorReported> { fn error(&mut self, span: Span, msg: &str) -> Result<!, ErrorGuaranteed> {
self.tcx self.tcx
.sess .sess
.struct_span_err(self.root_span(), "overly complex generic constant") .struct_span_err(self.root_span(), "overly complex generic constant")
@ -249,9 +249,9 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
.help("consider moving this anonymous constant into a `const` function") .help("consider moving this anonymous constant into a `const` function")
.emit(); .emit();
Err(ErrorReported) Err(ErrorGuaranteed)
} }
fn maybe_supported_error(&mut self, span: Span, msg: &str) -> Result<!, ErrorReported> { fn maybe_supported_error(&mut self, span: Span, msg: &str) -> Result<!, ErrorGuaranteed> {
self.tcx self.tcx
.sess .sess
.struct_span_err(self.root_span(), "overly complex generic constant") .struct_span_err(self.root_span(), "overly complex generic constant")
@ -260,13 +260,13 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
.note("this operation may be supported in the future") .note("this operation may be supported in the future")
.emit(); .emit();
Err(ErrorReported) Err(ErrorGuaranteed)
} }
fn new( fn new(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
(body, body_id): (&'a thir::Thir<'tcx>, thir::ExprId), (body, body_id): (&'a thir::Thir<'tcx>, thir::ExprId),
) -> Result<Option<AbstractConstBuilder<'a, 'tcx>>, ErrorReported> { ) -> Result<Option<AbstractConstBuilder<'a, 'tcx>>, ErrorGuaranteed> {
let builder = AbstractConstBuilder { tcx, body_id, body, nodes: IndexVec::new() }; let builder = AbstractConstBuilder { tcx, body_id, body, nodes: IndexVec::new() };
struct IsThirPolymorphic<'a, 'tcx> { struct IsThirPolymorphic<'a, 'tcx> {
@ -330,7 +330,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
/// Builds the abstract const by walking the thir and bailing out when /// Builds the abstract const by walking the thir and bailing out when
/// encountering an unspported operation. /// encountering an unspported operation.
fn build(mut self) -> Result<&'tcx [Node<'tcx>], ErrorReported> { fn build(mut self) -> Result<&'tcx [Node<'tcx>], ErrorGuaranteed> {
debug!("Abstractconstbuilder::build: body={:?}", &*self.body); debug!("Abstractconstbuilder::build: body={:?}", &*self.body);
self.recurse_build(self.body_id)?; self.recurse_build(self.body_id)?;
@ -349,7 +349,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
Ok(self.tcx.arena.alloc_from_iter(self.nodes.into_iter())) Ok(self.tcx.arena.alloc_from_iter(self.nodes.into_iter()))
} }
fn recurse_build(&mut self, node: thir::ExprId) -> Result<NodeId, ErrorReported> { fn recurse_build(&mut self, node: thir::ExprId) -> Result<NodeId, ErrorGuaranteed> {
use thir::ExprKind; use thir::ExprKind;
let node = &self.body.exprs[node]; let node = &self.body.exprs[node];
debug!("recurse_build: node={:?}", node); debug!("recurse_build: node={:?}", node);
@ -503,7 +503,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
pub(super) fn thir_abstract_const<'tcx>( pub(super) fn thir_abstract_const<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
def: ty::WithOptConstParam<LocalDefId>, def: ty::WithOptConstParam<LocalDefId>,
) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorReported> { ) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorGuaranteed> {
if tcx.features().generic_const_exprs { if tcx.features().generic_const_exprs {
match tcx.def_kind(def.did) { match tcx.def_kind(def.did) {
// FIXME(generic_const_exprs): We currently only do this for anonymous constants, // FIXME(generic_const_exprs): We currently only do this for anonymous constants,
@ -518,7 +518,7 @@ pub(super) fn thir_abstract_const<'tcx>(
let body = tcx.thir_body(def); let body = tcx.thir_body(def);
if body.0.borrow().exprs.is_empty() { if body.0.borrow().exprs.is_empty() {
// type error in constant, there is no thir // type error in constant, there is no thir
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
AbstractConstBuilder::new(tcx, (&*body.0.borrow(), body.1))? AbstractConstBuilder::new(tcx, (&*body.0.borrow(), body.1))?
@ -542,10 +542,10 @@ pub(super) fn try_unify_abstract_consts<'tcx>(
Ok(false) Ok(false)
})() })()
.unwrap_or_else(|ErrorReported| true) .unwrap_or_else(|ErrorGuaranteed| true)
// FIXME(generic_const_exprs): We should instead have this // FIXME(generic_const_exprs): We should instead have this
// method return the resulting `ty::Const` and return `ConstKind::Error` // method return the resulting `ty::Const` and return `ConstKind::Error`
// on `ErrorReported`. // on `ErrorGuaranteed`.
} }
pub fn walk_abstract_const<'tcx, R, F>( pub fn walk_abstract_const<'tcx, R, F>(

View file

@ -13,7 +13,7 @@ use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use crate::infer::{self, InferCtxt, TyCtxtInferExt}; use crate::infer::{self, InferCtxt, TyCtxtInferExt};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{ use rustc_errors::{
pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorReported, pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
}; };
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
@ -102,7 +102,7 @@ pub trait InferCtxtExt<'tcx> {
expected_args: Vec<ArgKind>, expected_args: Vec<ArgKind>,
found_args: Vec<ArgKind>, found_args: Vec<ArgKind>,
is_closure: bool, is_closure: bool,
) -> DiagnosticBuilder<'tcx, ErrorReported>; ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>;
} }
impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
@ -919,9 +919,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
} }
// Already reported in the query. // Already reported in the query.
SelectionError::NotConstEvaluatable(NotConstEvaluatable::Error(ErrorReported)) => { SelectionError::NotConstEvaluatable(NotConstEvaluatable::Error(ErrorGuaranteed)) => {
// FIXME(eddyb) remove this once `ErrorReported` becomes a proof token. // FIXME(eddyb) remove this once `ErrorGuaranteed` becomes a proof token.
self.tcx.sess.delay_span_bug(span, "`ErrorReported` without an error"); self.tcx.sess.delay_span_bug(span, "`ErrorGuaranteed` without an error");
return; return;
} }
@ -1019,7 +1019,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
expected_args: Vec<ArgKind>, expected_args: Vec<ArgKind>,
found_args: Vec<ArgKind>, found_args: Vec<ArgKind>,
is_closure: bool, is_closure: bool,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let kind = if is_closure { "closure" } else { "function" }; let kind = if is_closure { "closure" } else { "function" };
let args_str = |arguments: &[ArgKind], other: &[ArgKind]| { let args_str = |arguments: &[ArgKind], other: &[ArgKind]| {

View file

@ -11,7 +11,7 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::{ use rustc_errors::{
error_code, pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, error_code, pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder,
ErrorReported, Style, ErrorGuaranteed, Style,
}; };
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;
@ -123,7 +123,7 @@ pub trait InferCtxtExt<'tcx> {
found_span: Option<Span>, found_span: Option<Span>,
expected_ref: ty::PolyTraitRef<'tcx>, expected_ref: ty::PolyTraitRef<'tcx>,
found: ty::PolyTraitRef<'tcx>, found: ty::PolyTraitRef<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorReported>; ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>;
fn suggest_fully_qualified_path( fn suggest_fully_qualified_path(
&self, &self,
@ -1260,7 +1260,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
found_span: Option<Span>, found_span: Option<Span>,
expected_ref: ty::PolyTraitRef<'tcx>, expected_ref: ty::PolyTraitRef<'tcx>,
found: ty::PolyTraitRef<'tcx>, found: ty::PolyTraitRef<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
crate fn build_fn_sig_string<'tcx>( crate fn build_fn_sig_string<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
trait_ref: ty::PolyTraitRef<'tcx>, trait_ref: ty::PolyTraitRef<'tcx>,

View file

@ -3,7 +3,7 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::obligation_forest::ProcessResult; use rustc_data_structures::obligation_forest::ProcessResult;
use rustc_data_structures::obligation_forest::{Error, ForestObligation, Outcome}; use rustc_data_structures::obligation_forest::{Error, ForestObligation, Outcome};
use rustc_data_structures::obligation_forest::{ObligationForest, ObligationProcessor}; use rustc_data_structures::obligation_forest::{ObligationForest, ObligationProcessor};
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_infer::traits::ProjectionCacheKey; use rustc_infer::traits::ProjectionCacheKey;
use rustc_infer::traits::{SelectionError, TraitEngine, TraitEngineExt as _, TraitObligation}; use rustc_infer::traits::{SelectionError, TraitEngine, TraitEngineExt as _, TraitObligation};
use rustc_middle::mir::interpret::ErrorHandled; use rustc_middle::mir::interpret::ErrorHandled;
@ -613,12 +613,14 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
), ),
} }
} }
(Err(ErrorHandled::Reported(ErrorReported)), _) (Err(ErrorHandled::Reported(ErrorGuaranteed)), _)
| (_, Err(ErrorHandled::Reported(ErrorReported))) => ProcessResult::Error( | (_, Err(ErrorHandled::Reported(ErrorGuaranteed))) => {
CodeSelectionError(SelectionError::NotConstEvaluatable( ProcessResult::Error(CodeSelectionError(
NotConstEvaluatable::Error(ErrorReported), SelectionError::NotConstEvaluatable(NotConstEvaluatable::Error(
ErrorGuaranteed,
)), )),
), ))
}
(Err(ErrorHandled::Linted), _) | (_, Err(ErrorHandled::Linted)) => { (Err(ErrorHandled::Linted), _) | (_, Err(ErrorHandled::Linted)) => {
span_bug!( span_bug!(
obligation.cause.span(self.selcx.tcx()), obligation.cause.span(self.selcx.tcx()),

View file

@ -26,7 +26,7 @@ use crate::infer::outlives::env::OutlivesEnvironment;
use crate::infer::{InferCtxt, RegionckMode, TyCtxtInferExt}; use crate::infer::{InferCtxt, RegionckMode, TyCtxtInferExt};
use crate::traits::error_reporting::InferCtxtExt as _; use crate::traits::error_reporting::InferCtxtExt as _;
use crate::traits::query::evaluate_obligation::InferCtxtExt as _; use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_hir::lang_items::LangItem; use rustc_hir::lang_items::LangItem;
@ -206,7 +206,7 @@ fn do_normalize_predicates<'tcx>(
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
elaborated_env: ty::ParamEnv<'tcx>, elaborated_env: ty::ParamEnv<'tcx>,
predicates: Vec<ty::Predicate<'tcx>>, predicates: Vec<ty::Predicate<'tcx>>,
) -> Result<Vec<ty::Predicate<'tcx>>, ErrorReported> { ) -> Result<Vec<ty::Predicate<'tcx>>, ErrorGuaranteed> {
debug!( debug!(
"do_normalize_predicates(predicates={:?}, region_context={:?}, cause={:?})", "do_normalize_predicates(predicates={:?}, region_context={:?}, cause={:?})",
predicates, region_context, cause, predicates, region_context, cause,
@ -232,7 +232,7 @@ fn do_normalize_predicates<'tcx>(
Ok(predicates) => predicates, Ok(predicates) => predicates,
Err(errors) => { Err(errors) => {
infcx.report_fulfillment_errors(&errors, None, false); infcx.report_fulfillment_errors(&errors, None, false);
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
}; };
@ -259,12 +259,12 @@ fn do_normalize_predicates<'tcx>(
// unconstrained variable, and it seems better not to ICE, // unconstrained variable, and it seems better not to ICE,
// all things considered. // all things considered.
tcx.sess.span_err(span, &fixup_err.to_string()); tcx.sess.span_err(span, &fixup_err.to_string());
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
}; };
if predicates.needs_infer() { if predicates.needs_infer() {
tcx.sess.delay_span_bug(span, "encountered inference variables after `fully_resolve`"); tcx.sess.delay_span_bug(span, "encountered inference variables after `fully_resolve`");
Err(ErrorReported) Err(ErrorGuaranteed)
} else { } else {
Ok(predicates) Ok(predicates)
} }

View file

@ -1,7 +1,7 @@
use rustc_ast::{MetaItem, NestedMetaItem}; use rustc_ast::{MetaItem, NestedMetaItem};
use rustc_attr as attr; use rustc_attr as attr;
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{struct_span_err, ErrorReported}; use rustc_errors::{struct_span_err, ErrorGuaranteed};
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_middle::ty::{self, GenericParamDefKind, TyCtxt}; use rustc_middle::ty::{self, GenericParamDefKind, TyCtxt};
use rustc_parse_format::{ParseMode, Parser, Piece, Position}; use rustc_parse_format::{ParseMode, Parser, Piece, Position};
@ -41,14 +41,14 @@ fn parse_error(
message: &str, message: &str,
label: &str, label: &str,
note: Option<&str>, note: Option<&str>,
) -> ErrorReported { ) -> ErrorGuaranteed {
let mut diag = struct_span_err!(tcx.sess, span, E0232, "{}", message); let mut diag = struct_span_err!(tcx.sess, span, E0232, "{}", message);
diag.span_label(span, label); diag.span_label(span, label);
if let Some(note) = note { if let Some(note) = note {
diag.note(note); diag.note(note);
} }
diag.emit(); diag.emit();
ErrorReported ErrorGuaranteed
} }
impl<'tcx> OnUnimplementedDirective { impl<'tcx> OnUnimplementedDirective {
@ -58,7 +58,7 @@ impl<'tcx> OnUnimplementedDirective {
items: &[NestedMetaItem], items: &[NestedMetaItem],
span: Span, span: Span,
is_root: bool, is_root: bool,
) -> Result<Self, ErrorReported> { ) -> Result<Self, ErrorGuaranteed> {
let mut errored = false; let mut errored = false;
let mut item_iter = items.iter(); let mut item_iter = items.iter();
@ -164,7 +164,7 @@ impl<'tcx> OnUnimplementedDirective {
} }
if errored { if errored {
Err(ErrorReported) Err(ErrorGuaranteed)
} else { } else {
Ok(OnUnimplementedDirective { Ok(OnUnimplementedDirective {
condition, condition,
@ -182,7 +182,7 @@ impl<'tcx> OnUnimplementedDirective {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
trait_def_id: DefId, trait_def_id: DefId,
impl_def_id: DefId, impl_def_id: DefId,
) -> Result<Option<Self>, ErrorReported> { ) -> Result<Option<Self>, ErrorGuaranteed> {
let attrs = tcx.get_attrs(impl_def_id); let attrs = tcx.get_attrs(impl_def_id);
let Some(attr) = tcx.sess.find_by_name(&attrs, sym::rustc_on_unimplemented) else { let Some(attr) = tcx.sess.find_by_name(&attrs, sym::rustc_on_unimplemented) else {
@ -207,7 +207,7 @@ impl<'tcx> OnUnimplementedDirective {
append_const_msg: None, append_const_msg: None,
})) }))
} else { } else {
return Err(ErrorReported); return Err(ErrorGuaranteed);
}; };
debug!("of_item({:?}/{:?}) = {:?}", trait_def_id, impl_def_id, result); debug!("of_item({:?}/{:?}) = {:?}", trait_def_id, impl_def_id, result);
result result
@ -283,7 +283,7 @@ impl<'tcx> OnUnimplementedFormatString {
trait_def_id: DefId, trait_def_id: DefId,
from: Symbol, from: Symbol,
err_sp: Span, err_sp: Span,
) -> Result<Self, ErrorReported> { ) -> Result<Self, ErrorGuaranteed> {
let result = OnUnimplementedFormatString(from); let result = OnUnimplementedFormatString(from);
result.verify(tcx, trait_def_id, err_sp)?; result.verify(tcx, trait_def_id, err_sp)?;
Ok(result) Ok(result)
@ -294,7 +294,7 @@ impl<'tcx> OnUnimplementedFormatString {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
trait_def_id: DefId, trait_def_id: DefId,
span: Span, span: Span,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
let name = tcx.item_name(trait_def_id); let name = tcx.item_name(trait_def_id);
let generics = tcx.generics_of(trait_def_id); let generics = tcx.generics_of(trait_def_id);
let s = self.0.as_str(); let s = self.0.as_str();
@ -334,7 +334,7 @@ impl<'tcx> OnUnimplementedFormatString {
name name
) )
.emit(); .emit();
result = Err(ErrorReported); result = Err(ErrorGuaranteed);
} }
} }
} }
@ -347,7 +347,7 @@ impl<'tcx> OnUnimplementedFormatString {
"only named substitution parameters are allowed" "only named substitution parameters are allowed"
) )
.emit(); .emit();
result = Err(ErrorReported); result = Err(ErrorGuaranteed);
} }
}, },
} }

View file

@ -22,7 +22,7 @@ use crate::traits::error_reporting::InferCtxtExt as _;
use crate::traits::select::ProjectionMatchesProjection; use crate::traits::select::ProjectionMatchesProjection;
use rustc_data_structures::sso::SsoHashSet; use rustc_data_structures::sso::SsoHashSet;
use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_hir::lang_items::LangItem; use rustc_hir::lang_items::LangItem;
@ -1326,7 +1326,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
// `rustc_ty_utils::instance::resolve_associated_item()`. // `rustc_ty_utils::instance::resolve_associated_item()`.
let node_item = let node_item =
assoc_def(selcx, impl_data.impl_def_id, obligation.predicate.item_def_id) assoc_def(selcx, impl_data.impl_def_id, obligation.predicate.item_def_id)
.map_err(|ErrorReported| ())?; .map_err(|ErrorGuaranteed| ())?;
if node_item.is_final() { if node_item.is_final() {
// Non-specializable items are always projectable. // Non-specializable items are always projectable.
@ -1918,7 +1918,7 @@ fn assoc_def(
selcx: &SelectionContext<'_, '_>, selcx: &SelectionContext<'_, '_>,
impl_def_id: DefId, impl_def_id: DefId,
assoc_def_id: DefId, assoc_def_id: DefId,
) -> Result<specialization_graph::LeafDef, ErrorReported> { ) -> Result<specialization_graph::LeafDef, ErrorGuaranteed> {
let tcx = selcx.tcx(); let tcx = selcx.tcx();
let trait_def_id = tcx.impl_trait_ref(impl_def_id).unwrap().def_id; let trait_def_id = tcx.impl_trait_ref(impl_def_id).unwrap().def_id;
let trait_def = tcx.trait_def(trait_def_id); let trait_def = tcx.trait_def(trait_def_id);

View file

@ -29,7 +29,7 @@ use crate::traits::project::ProjectionCacheKeyExt;
use crate::traits::ProjectionCacheKey; use crate::traits::ProjectionCacheKey;
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::{Diagnostic, ErrorReported}; use rustc_errors::{Diagnostic, ErrorGuaranteed};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_infer::infer::LateBoundRegionConversionTime; use rustc_infer::infer::LateBoundRegionConversionTime;
@ -674,8 +674,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
Err(_) => Ok(EvaluatedToErr), Err(_) => Ok(EvaluatedToErr),
} }
} }
(Err(ErrorHandled::Reported(ErrorReported)), _) (Err(ErrorHandled::Reported(ErrorGuaranteed)), _)
| (_, Err(ErrorHandled::Reported(ErrorReported))) => Ok(EvaluatedToErr), | (_, Err(ErrorHandled::Reported(ErrorGuaranteed))) => Ok(EvaluatedToErr),
(Err(ErrorHandled::Linted), _) | (_, Err(ErrorHandled::Linted)) => { (Err(ErrorHandled::Linted), _) | (_, Err(ErrorHandled::Linted)) => {
span_bug!( span_bug!(
obligation.cause.span(self.tcx()), obligation.cause.span(self.tcx()),

View file

@ -1,4 +1,4 @@
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::subst::SubstsRef;
@ -114,7 +114,7 @@ impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> {
fn resolve_instance<'tcx>( fn resolve_instance<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>, key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>,
) -> Result<Option<Instance<'tcx>>, ErrorReported> { ) -> Result<Option<Instance<'tcx>>, ErrorGuaranteed> {
let (param_env, (did, substs)) = key.into_parts(); let (param_env, (did, substs)) = key.into_parts();
if let Some(did) = did.as_local() { if let Some(did) = did.as_local() {
if let Some(param_did) = tcx.opt_const_param_of(did) { if let Some(param_did) = tcx.opt_const_param_of(did) {
@ -128,7 +128,7 @@ fn resolve_instance<'tcx>(
fn resolve_instance_of_const_arg<'tcx>( fn resolve_instance_of_const_arg<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
key: ty::ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)>, key: ty::ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)>,
) -> Result<Option<Instance<'tcx>>, ErrorReported> { ) -> Result<Option<Instance<'tcx>>, ErrorGuaranteed> {
let (param_env, (did, const_param_did, substs)) = key.into_parts(); let (param_env, (did, const_param_did, substs)) = key.into_parts();
inner_resolve_instance( inner_resolve_instance(
tcx, tcx,
@ -143,7 +143,7 @@ fn resolve_instance_of_const_arg<'tcx>(
fn inner_resolve_instance<'tcx>( fn inner_resolve_instance<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
key: ty::ParamEnvAnd<'tcx, (ty::WithOptConstParam<DefId>, SubstsRef<'tcx>)>, key: ty::ParamEnvAnd<'tcx, (ty::WithOptConstParam<DefId>, SubstsRef<'tcx>)>,
) -> Result<Option<Instance<'tcx>>, ErrorReported> { ) -> Result<Option<Instance<'tcx>>, ErrorGuaranteed> {
let (param_env, (def, substs)) = key.into_parts(); let (param_env, (def, substs)) = key.into_parts();
let result = if let Some(trait_def_id) = tcx.trait_of_item(def.did) { let result = if let Some(trait_def_id) = tcx.trait_of_item(def.did) {
@ -203,7 +203,7 @@ fn resolve_associated_item<'tcx>(
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
trait_id: DefId, trait_id: DefId,
rcvr_substs: SubstsRef<'tcx>, rcvr_substs: SubstsRef<'tcx>,
) -> Result<Option<Instance<'tcx>>, ErrorReported> { ) -> Result<Option<Instance<'tcx>>, ErrorGuaranteed> {
debug!(?trait_item_id, ?param_env, ?trait_id, ?rcvr_substs, "resolve_associated_item"); debug!(?trait_item_id, ?param_env, ?trait_id, ?rcvr_substs, "resolve_associated_item");
let trait_ref = ty::TraitRef::from_method(tcx, trait_id, rcvr_substs); let trait_ref = ty::TraitRef::from_method(tcx, trait_id, rcvr_substs);
@ -281,7 +281,7 @@ fn resolve_associated_item<'tcx>(
// we know the error would've been caught (e.g. in an upstream crate). // we know the error would've been caught (e.g. in an upstream crate).
// //
// A better approach might be to just introduce a query (returning // A better approach might be to just introduce a query (returning
// `Result<(), ErrorReported>`) for the check that `rustc_typeck` // `Result<(), ErrorGuaranteed>`) for the check that `rustc_typeck`
// performs (i.e. that the definition's type in the `impl` matches // performs (i.e. that the definition's type in the `impl` matches
// the declaration in the `trait`), so that we can cheaply check // the declaration in the `trait`), so that we can cheaply check
// here if it failed, instead of approximating it. // here if it failed, instead of approximating it.
@ -308,7 +308,7 @@ fn resolve_associated_item<'tcx>(
let span = tcx.def_span(leaf_def.item.def_id); let span = tcx.def_span(leaf_def.item.def_id);
tcx.sess.delay_span_bug(span, &msg); tcx.sess.delay_span_bug(span, &msg);
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
} }

View file

@ -6,7 +6,7 @@ use crate::astconv::{
use crate::errors::AssocTypeBindingNotAllowed; use crate::errors::AssocTypeBindingNotAllowed;
use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs}; use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs};
use rustc_ast::ast::ParamKindOrd; use rustc_ast::ast::ParamKindOrd;
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorReported}; use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res}; use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
@ -602,7 +602,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
correct: if lifetimes_correct && args_correct { correct: if lifetimes_correct && args_correct {
Ok(()) Ok(())
} else { } else {
Err(GenericArgCountMismatch { reported: Some(ErrorReported), invalid_args }) Err(GenericArgCountMismatch { reported: Some(ErrorGuaranteed), invalid_args })
}, },
} }
} }

View file

@ -15,7 +15,9 @@ use crate::middle::resolve_lifetime as rl;
use crate::require_c_abi_if_c_variadic; use crate::require_c_abi_if_c_variadic;
use rustc_ast::TraitObjectSyntax; use rustc_ast::TraitObjectSyntax;
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorReported, FatalError}; use rustc_errors::{
struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, FatalError,
};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{CtorOf, DefKind, Namespace, Res}; use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
@ -162,7 +164,7 @@ pub(crate) enum GenericArgPosition {
#[derive(Clone, Default)] #[derive(Clone, Default)]
pub struct GenericArgCountMismatch { pub struct GenericArgCountMismatch {
/// Indicates whether a fatal error was reported (`Some`), or just a lint (`None`). /// Indicates whether a fatal error was reported (`Some`), or just a lint (`None`).
pub reported: Option<ErrorReported>, pub reported: Option<ErrorGuaranteed>,
/// A list of spans of arguments provided that were not valid. /// A list of spans of arguments provided that were not valid.
pub invalid_args: Vec<Span>, pub invalid_args: Vec<Span>,
} }
@ -733,7 +735,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let mut dup_bindings = FxHashMap::default(); let mut dup_bindings = FxHashMap::default();
for binding in &assoc_bindings { for binding in &assoc_bindings {
// Specify type to assert that error was already reported in `Err` case. // Specify type to assert that error was already reported in `Err` case.
let _: Result<_, ErrorReported> = self.add_predicates_for_ast_type_binding( let _: Result<_, ErrorGuaranteed> = self.add_predicates_for_ast_type_binding(
hir_id, hir_id,
poly_trait_ref, poly_trait_ref,
binding, binding,
@ -742,7 +744,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
&mut dup_bindings, &mut dup_bindings,
binding_span.unwrap_or(binding.span), binding_span.unwrap_or(binding.span),
); );
// Okay to ignore `Err` because of `ErrorReported` (see above). // Okay to ignore `Err` because of `ErrorGuaranteed` (see above).
} }
arg_count arg_count
@ -1096,7 +1098,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
speculative: bool, speculative: bool,
dup_bindings: &mut FxHashMap<DefId, Span>, dup_bindings: &mut FxHashMap<DefId, Span>,
path_span: Span, path_span: Span,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
// Given something like `U: SomeTrait<T = X>`, we want to produce a // Given something like `U: SomeTrait<T = X>`, we want to produce a
// predicate like `<U as SomeTrait>::T = X`. This is somewhat // predicate like `<U as SomeTrait>::T = X`. This is somewhat
// subtle in the event that `T` is defined in a supertrait of // subtle in the event that `T` is defined in a supertrait of
@ -1604,7 +1606,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
ty_param_def_id: LocalDefId, ty_param_def_id: LocalDefId,
assoc_name: Ident, assoc_name: Ident,
span: Span, span: Span,
) -> Result<ty::PolyTraitRef<'tcx>, ErrorReported> { ) -> Result<ty::PolyTraitRef<'tcx>, ErrorGuaranteed> {
let tcx = self.tcx(); let tcx = self.tcx();
debug!( debug!(
@ -1646,7 +1648,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
assoc_name: Ident, assoc_name: Ident,
span: Span, span: Span,
is_equality: impl Fn() -> Option<String>, is_equality: impl Fn() -> Option<String>,
) -> Result<ty::PolyTraitRef<'tcx>, ErrorReported> ) -> Result<ty::PolyTraitRef<'tcx>, ErrorGuaranteed>
where where
I: Iterator<Item = ty::PolyTraitRef<'tcx>>, I: Iterator<Item = ty::PolyTraitRef<'tcx>>,
{ {
@ -1665,7 +1667,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
assoc_name, assoc_name,
span, span,
); );
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
}; };
debug!("one_bound_for_assoc_type: bound = {:?}", bound); debug!("one_bound_for_assoc_type: bound = {:?}", bound);
@ -1752,7 +1754,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
} }
err.emit(); err.emit();
if !where_bounds.is_empty() { if !where_bounds.is_empty() {
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
} }
@ -1775,7 +1777,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
qself_res: Res, qself_res: Res,
assoc_segment: &hir::PathSegment<'_>, assoc_segment: &hir::PathSegment<'_>,
permit_variants: bool, permit_variants: bool,
) -> Result<(Ty<'tcx>, DefKind, DefId), ErrorReported> { ) -> Result<(Ty<'tcx>, DefKind, DefId), ErrorGuaranteed> {
let tcx = self.tcx(); let tcx = self.tcx();
let assoc_ident = assoc_segment.ident; let assoc_ident = assoc_segment.ident;
@ -1809,7 +1811,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
// trait reference. // trait reference.
let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) else { let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) else {
// A cycle error occurred, most likely. // A cycle error occurred, most likely.
return Err(ErrorReported); return Err(ErrorGuaranteed);
}; };
self.one_bound_for_assoc_type( self.one_bound_for_assoc_type(
@ -1878,7 +1880,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
assoc_ident.name, assoc_ident.name,
); );
} }
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
}; };
@ -1897,7 +1899,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let Some(item) = item else { let Some(item) = item else {
let msg = format!("found associated const `{assoc_ident}` when type was expected"); let msg = format!("found associated const `{assoc_ident}` when type was expected");
tcx.sess.struct_span_err(span, &msg).emit(); tcx.sess.struct_span_err(span, &msg).emit();
return Err(ErrorReported); return Err(ErrorGuaranteed);
}; };
let ty = self.projected_ty_from_poly_trait_ref(span, item.def_id, assoc_segment, bound); let ty = self.projected_ty_from_poly_trait_ref(span, item.def_id, assoc_segment, bound);
@ -2617,7 +2619,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
&self, &self,
constrained_regions: FxHashSet<ty::BoundRegionKind>, constrained_regions: FxHashSet<ty::BoundRegionKind>,
referenced_regions: FxHashSet<ty::BoundRegionKind>, referenced_regions: FxHashSet<ty::BoundRegionKind>,
generate_err: impl Fn(&str) -> DiagnosticBuilder<'tcx, ErrorReported>, generate_err: impl Fn(&str) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>,
) { ) {
for br in referenced_regions.difference(&constrained_regions) { for br in referenced_regions.difference(&constrained_regions) {
let br_name = match *br { let br_name = match *br {

View file

@ -32,7 +32,7 @@ use super::FnCtxt;
use crate::hir::def_id::DefId; use crate::hir::def_id::DefId;
use crate::type_error_struct; use crate::type_error_struct;
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorReported}; use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::lang_items::LangItem; use rustc_hir::lang_items::LangItem;
use rustc_middle::mir::Mutability; use rustc_middle::mir::Mutability;
@ -86,13 +86,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self, &self,
t: Ty<'tcx>, t: Ty<'tcx>,
span: Span, span: Span,
) -> Result<Option<PointerKind<'tcx>>, ErrorReported> { ) -> Result<Option<PointerKind<'tcx>>, ErrorGuaranteed> {
debug!("pointer_kind({:?}, {:?})", t, span); debug!("pointer_kind({:?}, {:?})", t, span);
let t = self.resolve_vars_if_possible(t); let t = self.resolve_vars_if_possible(t);
if t.references_error() { if t.references_error() {
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
if self.type_is_known_to_be_sized_modulo_regions(t, span) { if self.type_is_known_to_be_sized_modulo_regions(t, span) {
@ -142,7 +142,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.tcx self.tcx
.sess .sess
.delay_span_bug(span, &format!("`{:?}` should be sized but is not?", t)); .delay_span_bug(span, &format!("`{:?}` should be sized but is not?", t));
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
}) })
} }
@ -150,7 +150,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub enum CastError { pub enum CastError {
ErrorReported, ErrorGuaranteed,
CastToBool, CastToBool,
CastToChar, CastToChar,
@ -167,9 +167,9 @@ pub enum CastError {
UnknownCastPtrKind, UnknownCastPtrKind,
} }
impl From<ErrorReported> for CastError { impl From<ErrorGuaranteed> for CastError {
fn from(ErrorReported: ErrorReported) -> Self { fn from(ErrorGuaranteed: ErrorGuaranteed) -> Self {
CastError::ErrorReported CastError::ErrorGuaranteed
} }
} }
@ -179,7 +179,7 @@ fn make_invalid_casting_error<'a, 'tcx>(
expr_ty: Ty<'tcx>, expr_ty: Ty<'tcx>,
cast_ty: Ty<'tcx>, cast_ty: Ty<'tcx>,
fcx: &FnCtxt<'a, 'tcx>, fcx: &FnCtxt<'a, 'tcx>,
) -> DiagnosticBuilder<'a, ErrorReported> { ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
type_error_struct!( type_error_struct!(
sess, sess,
span, span,
@ -199,7 +199,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
cast_ty: Ty<'tcx>, cast_ty: Ty<'tcx>,
cast_span: Span, cast_span: Span,
span: Span, span: Span,
) -> Result<CastCheck<'tcx>, ErrorReported> { ) -> Result<CastCheck<'tcx>, ErrorGuaranteed> {
let check = CastCheck { expr, expr_ty, cast_ty, cast_span, span }; let check = CastCheck { expr, expr_ty, cast_ty, cast_span, span };
// For better error messages, check for some obviously unsized // For better error messages, check for some obviously unsized
@ -208,7 +208,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
match cast_ty.kind() { match cast_ty.kind() {
ty::Dynamic(..) | ty::Slice(..) => { ty::Dynamic(..) | ty::Slice(..) => {
check.report_cast_to_unsized_type(fcx); check.report_cast_to_unsized_type(fcx);
Err(ErrorReported) Err(ErrorGuaranteed)
} }
_ => Ok(check), _ => Ok(check),
} }
@ -216,7 +216,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
fn report_cast_error(&self, fcx: &FnCtxt<'a, 'tcx>, e: CastError) { fn report_cast_error(&self, fcx: &FnCtxt<'a, 'tcx>, e: CastError) {
match e { match e {
CastError::ErrorReported => { CastError::ErrorGuaranteed => {
// an error has already been reported // an error has already been reported
} }
CastError::NeedDeref => { CastError::NeedDeref => {

View file

@ -4,7 +4,7 @@ use super::compare_method::{compare_const_impl, compare_impl_method, compare_ty_
use super::*; use super::*;
use rustc_attr as attr; use rustc_attr as attr;
use rustc_errors::{Applicability, ErrorReported}; use rustc_errors::{Applicability, ErrorGuaranteed};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::intravisit::Visitor; use rustc_hir::intravisit::Visitor;
@ -623,13 +623,13 @@ pub(super) fn check_opaque_for_cycles<'tcx>(
substs: SubstsRef<'tcx>, substs: SubstsRef<'tcx>,
span: Span, span: Span,
origin: &hir::OpaqueTyOrigin, origin: &hir::OpaqueTyOrigin,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
if tcx.try_expand_impl_trait_type(def_id.to_def_id(), substs).is_err() { if tcx.try_expand_impl_trait_type(def_id.to_def_id(), substs).is_err() {
match origin { match origin {
hir::OpaqueTyOrigin::AsyncFn(..) => async_opaque_type_cycle_error(tcx, span), hir::OpaqueTyOrigin::AsyncFn(..) => async_opaque_type_cycle_error(tcx, span),
_ => opaque_type_cycle_error(tcx, def_id, span), _ => opaque_type_cycle_error(tcx, def_id, span),
} }
Err(ErrorReported) Err(ErrorGuaranteed)
} else { } else {
Ok(()) Ok(())
} }
@ -760,7 +760,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) {
let assoc_item = tcx.associated_item(item.def_id); let assoc_item = tcx.associated_item(item.def_id);
let trait_substs = let trait_substs =
InternalSubsts::identity_for_item(tcx, it.def_id.to_def_id()); InternalSubsts::identity_for_item(tcx, it.def_id.to_def_id());
let _: Result<_, rustc_errors::ErrorReported> = check_type_bounds( let _: Result<_, rustc_errors::ErrorGuaranteed> = check_type_bounds(
tcx, tcx,
assoc_item, assoc_item,
assoc_item, assoc_item,

View file

@ -37,7 +37,9 @@
use crate::astconv::AstConv; use crate::astconv::AstConv;
use crate::check::FnCtxt; use crate::check::FnCtxt;
use rustc_errors::{struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorReported}; use rustc_errors::{
struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
@ -1520,7 +1522,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
fcx: &FnCtxt<'a, 'tcx>, fcx: &FnCtxt<'a, 'tcx>,
id: hir::HirId, id: hir::HirId,
expression: Option<(&'tcx hir::Expr<'tcx>, hir::HirId)>, expression: Option<(&'tcx hir::Expr<'tcx>, hir::HirId)>,
) -> DiagnosticBuilder<'a, ErrorReported> { ) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
let mut err = fcx.report_mismatched_types(cause, expected, found, ty_err); let mut err = fcx.report_mismatched_types(cause, expected, found, ty_err);
let mut pointing_at_return_type = false; let mut pointing_at_return_type = false;

View file

@ -1,6 +1,6 @@
use crate::errors::LifetimesOrBoundsMismatchOnTrait; use crate::errors::LifetimesOrBoundsMismatchOnTrait;
use rustc_data_structures::stable_set::FxHashSet; use rustc_data_structures::stable_set::FxHashSet;
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticId, ErrorReported}; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticId, ErrorGuaranteed};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res}; use rustc_hir::def::{DefKind, Res};
use rustc_hir::intravisit; use rustc_hir::intravisit;
@ -41,34 +41,35 @@ crate fn compare_impl_method<'tcx>(
let impl_m_span = tcx.sess.source_map().guess_head_span(impl_m_span); let impl_m_span = tcx.sess.source_map().guess_head_span(impl_m_span);
if let Err(ErrorReported) = compare_self_type(tcx, impl_m, impl_m_span, trait_m, impl_trait_ref) if let Err(ErrorGuaranteed) =
compare_self_type(tcx, impl_m, impl_m_span, trait_m, impl_trait_ref)
{ {
return; return;
} }
if let Err(ErrorReported) = if let Err(ErrorGuaranteed) =
compare_number_of_generics(tcx, impl_m, impl_m_span, trait_m, trait_item_span) compare_number_of_generics(tcx, impl_m, impl_m_span, trait_m, trait_item_span)
{ {
return; return;
} }
if let Err(ErrorReported) = if let Err(ErrorGuaranteed) =
compare_number_of_method_arguments(tcx, impl_m, impl_m_span, trait_m, trait_item_span) compare_number_of_method_arguments(tcx, impl_m, impl_m_span, trait_m, trait_item_span)
{ {
return; return;
} }
if let Err(ErrorReported) = compare_synthetic_generics(tcx, impl_m, trait_m) { if let Err(ErrorGuaranteed) = compare_synthetic_generics(tcx, impl_m, trait_m) {
return; return;
} }
if let Err(ErrorReported) = if let Err(ErrorGuaranteed) =
compare_predicate_entailment(tcx, impl_m, impl_m_span, trait_m, impl_trait_ref) compare_predicate_entailment(tcx, impl_m, impl_m_span, trait_m, impl_trait_ref)
{ {
return; return;
} }
if let Err(ErrorReported) = compare_const_param_types(tcx, impl_m, trait_m, trait_item_span) { if let Err(ErrorGuaranteed) = compare_const_param_types(tcx, impl_m, trait_m, trait_item_span) {
return; return;
} }
} }
@ -79,7 +80,7 @@ fn compare_predicate_entailment<'tcx>(
impl_m_span: Span, impl_m_span: Span,
trait_m: &ty::AssocItem, trait_m: &ty::AssocItem,
impl_trait_ref: ty::TraitRef<'tcx>, impl_trait_ref: ty::TraitRef<'tcx>,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
let trait_to_impl_substs = impl_trait_ref.substs; let trait_to_impl_substs = impl_trait_ref.substs;
// This node-id should be used for the `body_id` field on each // This node-id should be used for the `body_id` field on each
@ -385,7 +386,7 @@ fn compare_predicate_entailment<'tcx>(
false, false,
); );
diag.emit(); diag.emit();
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
// Check that all obligations are satisfied by the implementation's // Check that all obligations are satisfied by the implementation's
@ -393,7 +394,7 @@ fn compare_predicate_entailment<'tcx>(
let errors = inh.fulfillment_cx.borrow_mut().select_all_or_error(&infcx); let errors = inh.fulfillment_cx.borrow_mut().select_all_or_error(&infcx);
if !errors.is_empty() { if !errors.is_empty() {
infcx.report_fulfillment_errors(&errors, None, false); infcx.report_fulfillment_errors(&errors, None, false);
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
// Finally, resolve all regions. This catches wily misuses of // Finally, resolve all regions. This catches wily misuses of
@ -412,7 +413,7 @@ fn check_region_bounds_on_impl_item<'tcx>(
trait_m: &ty::AssocItem, trait_m: &ty::AssocItem,
trait_generics: &ty::Generics, trait_generics: &ty::Generics,
impl_generics: &ty::Generics, impl_generics: &ty::Generics,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
let trait_params = trait_generics.own_counts().lifetimes; let trait_params = trait_generics.own_counts().lifetimes;
let impl_params = impl_generics.own_counts().lifetimes; let impl_params = impl_generics.own_counts().lifetimes;
@ -455,7 +456,7 @@ fn check_region_bounds_on_impl_item<'tcx>(
ident: impl_m.ident(tcx), ident: impl_m.ident(tcx),
generics_span, generics_span,
}); });
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
Ok(()) Ok(())
@ -501,7 +502,7 @@ fn compare_self_type<'tcx>(
impl_m_span: Span, impl_m_span: Span,
trait_m: &ty::AssocItem, trait_m: &ty::AssocItem,
impl_trait_ref: ty::TraitRef<'tcx>, impl_trait_ref: ty::TraitRef<'tcx>,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
// Try to give more informative error messages about self typing // Try to give more informative error messages about self typing
// mismatches. Note that any mismatch will also be detected // mismatches. Note that any mismatch will also be detected
// below, where we construct a canonical function type that // below, where we construct a canonical function type that
@ -550,7 +551,7 @@ fn compare_self_type<'tcx>(
err.note_trait_signature(trait_m.name.to_string(), trait_m.signature(tcx)); err.note_trait_signature(trait_m.name.to_string(), trait_m.signature(tcx));
} }
err.emit(); err.emit();
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
(true, false) => { (true, false) => {
@ -570,7 +571,7 @@ fn compare_self_type<'tcx>(
err.note_trait_signature(trait_m.name.to_string(), trait_m.signature(tcx)); err.note_trait_signature(trait_m.name.to_string(), trait_m.signature(tcx));
} }
err.emit(); err.emit();
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
} }
@ -583,7 +584,7 @@ fn compare_number_of_generics<'tcx>(
_impl_span: Span, _impl_span: Span,
trait_: &ty::AssocItem, trait_: &ty::AssocItem,
trait_span: Option<Span>, trait_span: Option<Span>,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
let trait_own_counts = tcx.generics_of(trait_.def_id).own_counts(); let trait_own_counts = tcx.generics_of(trait_.def_id).own_counts();
let impl_own_counts = tcx.generics_of(impl_.def_id).own_counts(); let impl_own_counts = tcx.generics_of(impl_.def_id).own_counts();
@ -693,7 +694,7 @@ fn compare_number_of_generics<'tcx>(
} }
} }
if err_occurred { Err(ErrorReported) } else { Ok(()) } if err_occurred { Err(ErrorGuaranteed) } else { Ok(()) }
} }
fn compare_number_of_method_arguments<'tcx>( fn compare_number_of_method_arguments<'tcx>(
@ -702,7 +703,7 @@ fn compare_number_of_method_arguments<'tcx>(
impl_m_span: Span, impl_m_span: Span,
trait_m: &ty::AssocItem, trait_m: &ty::AssocItem,
trait_item_span: Option<Span>, trait_item_span: Option<Span>,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
let impl_m_fty = tcx.fn_sig(impl_m.def_id); let impl_m_fty = tcx.fn_sig(impl_m.def_id);
let trait_m_fty = tcx.fn_sig(trait_m.def_id); let trait_m_fty = tcx.fn_sig(trait_m.def_id);
let trait_number_args = trait_m_fty.inputs().skip_binder().len(); let trait_number_args = trait_m_fty.inputs().skip_binder().len();
@ -772,7 +773,7 @@ fn compare_number_of_method_arguments<'tcx>(
), ),
); );
err.emit(); err.emit();
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
Ok(()) Ok(())
@ -782,7 +783,7 @@ fn compare_synthetic_generics<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
impl_m: &ty::AssocItem, impl_m: &ty::AssocItem,
trait_m: &ty::AssocItem, trait_m: &ty::AssocItem,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
// FIXME(chrisvittal) Clean up this function, list of FIXME items: // FIXME(chrisvittal) Clean up this function, list of FIXME items:
// 1. Better messages for the span labels // 1. Better messages for the span labels
// 2. Explanation as to what is going on // 2. Explanation as to what is going on
@ -921,7 +922,7 @@ fn compare_synthetic_generics<'tcx>(
error_found = true; error_found = true;
} }
} }
if error_found { Err(ErrorReported) } else { Ok(()) } if error_found { Err(ErrorGuaranteed) } else { Ok(()) }
} }
fn compare_const_param_types<'tcx>( fn compare_const_param_types<'tcx>(
@ -929,7 +930,7 @@ fn compare_const_param_types<'tcx>(
impl_m: &ty::AssocItem, impl_m: &ty::AssocItem,
trait_m: &ty::AssocItem, trait_m: &ty::AssocItem,
trait_item_span: Option<Span>, trait_item_span: Option<Span>,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
let const_params_of = |def_id| { let const_params_of = |def_id| {
tcx.generics_of(def_id).params.iter().filter_map(|param| match param.kind { tcx.generics_of(def_id).params.iter().filter_map(|param| match param.kind {
GenericParamDefKind::Const { .. } => Some(param.def_id), GenericParamDefKind::Const { .. } => Some(param.def_id),
@ -979,7 +980,7 @@ fn compare_const_param_types<'tcx>(
), ),
); );
err.emit(); err.emit();
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
} }
@ -1101,7 +1102,7 @@ crate fn compare_ty_impl<'tcx>(
) { ) {
debug!("compare_impl_type(impl_trait_ref={:?})", impl_trait_ref); debug!("compare_impl_type(impl_trait_ref={:?})", impl_trait_ref);
let _: Result<(), ErrorReported> = (|| { let _: Result<(), ErrorGuaranteed> = (|| {
compare_number_of_generics(tcx, impl_ty, impl_ty_span, trait_ty, trait_item_span)?; compare_number_of_generics(tcx, impl_ty, impl_ty_span, trait_ty, trait_item_span)?;
let sp = tcx.def_span(impl_ty.def_id); let sp = tcx.def_span(impl_ty.def_id);
@ -1119,7 +1120,7 @@ fn compare_type_predicate_entailment<'tcx>(
impl_ty_span: Span, impl_ty_span: Span,
trait_ty: &ty::AssocItem, trait_ty: &ty::AssocItem,
impl_trait_ref: ty::TraitRef<'tcx>, impl_trait_ref: ty::TraitRef<'tcx>,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
let impl_substs = InternalSubsts::identity_for_item(tcx, impl_ty.def_id); let impl_substs = InternalSubsts::identity_for_item(tcx, impl_ty.def_id);
let trait_to_impl_substs = let trait_to_impl_substs =
impl_substs.rebase_onto(tcx, impl_ty.container.id(), impl_trait_ref.substs); impl_substs.rebase_onto(tcx, impl_ty.container.id(), impl_trait_ref.substs);
@ -1203,7 +1204,7 @@ fn compare_type_predicate_entailment<'tcx>(
let errors = inh.fulfillment_cx.borrow_mut().select_all_or_error(&infcx); let errors = inh.fulfillment_cx.borrow_mut().select_all_or_error(&infcx);
if !errors.is_empty() { if !errors.is_empty() {
infcx.report_fulfillment_errors(&errors, None, false); infcx.report_fulfillment_errors(&errors, None, false);
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
// Finally, resolve all regions. This catches wily misuses of // Finally, resolve all regions. This catches wily misuses of
@ -1235,7 +1236,7 @@ pub fn check_type_bounds<'tcx>(
impl_ty: &ty::AssocItem, impl_ty: &ty::AssocItem,
impl_ty_span: Span, impl_ty_span: Span,
impl_trait_ref: ty::TraitRef<'tcx>, impl_trait_ref: ty::TraitRef<'tcx>,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
// Given // Given
// //
// impl<A, B> Foo<u32> for (A, B) { // impl<A, B> Foo<u32> for (A, B) {
@ -1427,7 +1428,7 @@ pub fn check_type_bounds<'tcx>(
let errors = inh.fulfillment_cx.borrow_mut().select_all_or_error(&infcx); let errors = inh.fulfillment_cx.borrow_mut().select_all_or_error(&infcx);
if !errors.is_empty() { if !errors.is_empty() {
infcx.report_fulfillment_errors(&errors, None, false); infcx.report_fulfillment_errors(&errors, None, false);
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
// Finally, resolve all regions. This catches wily misuses of // Finally, resolve all regions. This catches wily misuses of

View file

@ -4,7 +4,7 @@ use rustc_trait_selection::infer::InferCtxtExt as _;
use rustc_trait_selection::traits::ObligationCause; use rustc_trait_selection::traits::ObligationCause;
use rustc_ast::util::parser::PREC_POSTFIX; use rustc_ast::util::parser::PREC_POSTFIX;
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorReported}; use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::lang_items::LangItem; use rustc_hir::lang_items::LangItem;
use rustc_hir::{is_range_literal, Node}; use rustc_hir::{is_range_literal, Node};
@ -57,7 +57,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
sp: Span, sp: Span,
expected: Ty<'tcx>, expected: Ty<'tcx>,
actual: Ty<'tcx>, actual: Ty<'tcx>,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> { ) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
self.demand_suptype_with_origin(&self.misc(sp), expected, actual) self.demand_suptype_with_origin(&self.misc(sp), expected, actual)
} }
@ -67,7 +67,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
cause: &ObligationCause<'tcx>, cause: &ObligationCause<'tcx>,
expected: Ty<'tcx>, expected: Ty<'tcx>,
actual: Ty<'tcx>, actual: Ty<'tcx>,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> { ) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
match self.at(cause, self.param_env).sup(expected, actual) { match self.at(cause, self.param_env).sup(expected, actual) {
Ok(InferOk { obligations, value: () }) => { Ok(InferOk { obligations, value: () }) => {
self.register_predicates(obligations); self.register_predicates(obligations);
@ -88,7 +88,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
sp: Span, sp: Span,
expected: Ty<'tcx>, expected: Ty<'tcx>,
actual: Ty<'tcx>, actual: Ty<'tcx>,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> { ) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
self.demand_eqtype_with_origin(&self.misc(sp), expected, actual) self.demand_eqtype_with_origin(&self.misc(sp), expected, actual)
} }
@ -97,7 +97,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
cause: &ObligationCause<'tcx>, cause: &ObligationCause<'tcx>,
expected: Ty<'tcx>, expected: Ty<'tcx>,
actual: Ty<'tcx>, actual: Ty<'tcx>,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> { ) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
match self.at(cause, self.param_env).eq(expected, actual) { match self.at(cause, self.param_env).eq(expected, actual) {
Ok(InferOk { obligations, value: () }) => { Ok(InferOk { obligations, value: () }) => {
self.register_predicates(obligations); self.register_predicates(obligations);
@ -134,7 +134,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
expected: Ty<'tcx>, expected: Ty<'tcx>,
expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>, expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>,
allow_two_phase: AllowTwoPhase, allow_two_phase: AllowTwoPhase,
) -> (Ty<'tcx>, Option<DiagnosticBuilder<'tcx, ErrorReported>>) { ) -> (Ty<'tcx>, Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>>) {
let expected = self.resolve_vars_with_obligations(expected); let expected = self.resolve_vars_with_obligations(expected);
let e = match self.try_coerce(expr, checked_ty, expected, allow_two_phase, None) { let e = match self.try_coerce(expr, checked_ty, expected, allow_two_phase, None) {

View file

@ -1,7 +1,7 @@
use crate::check::regionck::RegionCtxt; use crate::check::regionck::RegionCtxt;
use crate::hir; use crate::hir;
use crate::hir::def_id::{DefId, LocalDefId}; use crate::hir::def_id::{DefId, LocalDefId};
use rustc_errors::{struct_span_err, ErrorReported}; use rustc_errors::{struct_span_err, ErrorGuaranteed};
use rustc_infer::infer::outlives::env::OutlivesEnvironment; use rustc_infer::infer::outlives::env::OutlivesEnvironment;
use rustc_infer::infer::{InferOk, RegionckMode, TyCtxtInferExt}; use rustc_infer::infer::{InferOk, RegionckMode, TyCtxtInferExt};
use rustc_infer::traits::TraitEngineExt as _; use rustc_infer::traits::TraitEngineExt as _;
@ -31,7 +31,7 @@ use rustc_trait_selection::traits::{ObligationCause, TraitEngine, TraitEngineExt
/// struct/enum definition for the nominal type itself (i.e. /// struct/enum definition for the nominal type itself (i.e.
/// cannot do `struct S<T>; impl<T:Clone> Drop for S<T> { ... }`). /// cannot do `struct S<T>; impl<T:Clone> Drop for S<T> { ... }`).
/// ///
pub fn check_drop_impl(tcx: TyCtxt<'_>, drop_impl_did: DefId) -> Result<(), ErrorReported> { pub fn check_drop_impl(tcx: TyCtxt<'_>, drop_impl_did: DefId) -> Result<(), ErrorGuaranteed> {
let dtor_self_type = tcx.type_of(drop_impl_did); let dtor_self_type = tcx.type_of(drop_impl_did);
let dtor_predicates = tcx.predicates_of(drop_impl_did); let dtor_predicates = tcx.predicates_of(drop_impl_did);
match dtor_self_type.kind() { match dtor_self_type.kind() {
@ -59,7 +59,7 @@ pub fn check_drop_impl(tcx: TyCtxt<'_>, drop_impl_did: DefId) -> Result<(), Erro
span, span,
&format!("should have been rejected by coherence check: {}", dtor_self_type), &format!("should have been rejected by coherence check: {}", dtor_self_type),
); );
Err(ErrorReported) Err(ErrorGuaranteed)
} }
} }
} }
@ -69,7 +69,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
drop_impl_did: LocalDefId, drop_impl_did: LocalDefId,
drop_impl_ty: Ty<'tcx>, drop_impl_ty: Ty<'tcx>,
self_type_did: DefId, self_type_did: DefId,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
let drop_impl_hir_id = tcx.hir().local_def_id_to_hir_id(drop_impl_did); let drop_impl_hir_id = tcx.hir().local_def_id_to_hir_id(drop_impl_did);
// check that the impl type can be made to match the trait type. // check that the impl type can be made to match the trait type.
@ -109,7 +109,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
), ),
) )
.emit(); .emit();
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
} }
@ -117,7 +117,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
if !errors.is_empty() { if !errors.is_empty() {
// this could be reached when we get lazy normalization // this could be reached when we get lazy normalization
infcx.report_fulfillment_errors(&errors, None, false); infcx.report_fulfillment_errors(&errors, None, false);
return Err(ErrorReported); return Err(ErrorGuaranteed);
} }
// NB. It seems a bit... suspicious to use an empty param-env // NB. It seems a bit... suspicious to use an empty param-env
@ -146,7 +146,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
dtor_predicates: ty::GenericPredicates<'tcx>, dtor_predicates: ty::GenericPredicates<'tcx>,
self_type_did: LocalDefId, self_type_did: LocalDefId,
self_to_impl_substs: SubstsRef<'tcx>, self_to_impl_substs: SubstsRef<'tcx>,
) -> Result<(), ErrorReported> { ) -> Result<(), ErrorGuaranteed> {
let mut result = Ok(()); let mut result = Ok(());
// Here is an example, analogous to that from // Here is an example, analogous to that from
@ -268,7 +268,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
) )
.span_note(item_span, "the implementor must specify the same requirement") .span_note(item_span, "the implementor must specify the same requirement")
.emit(); .emit();
result = Err(ErrorReported); result = Err(ErrorGuaranteed);
} }
} }

View file

@ -26,7 +26,7 @@ use rustc_ast as ast;
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::Diagnostic; use rustc_errors::Diagnostic;
use rustc_errors::ErrorReported; use rustc_errors::ErrorGuaranteed;
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, DiagnosticId}; use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, DiagnosticId};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{CtorKind, DefKind, Res}; use rustc_hir::def::{CtorKind, DefKind, Res};
@ -1188,7 +1188,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
deferred_cast_checks.push(cast_check); deferred_cast_checks.push(cast_check);
t_cast t_cast
} }
Err(ErrorReported) => self.tcx.ty_error(), Err(ErrorGuaranteed) => self.tcx.ty_error(),
} }
} }
} }
@ -2225,7 +2225,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
field: Ident, field: Ident,
expr_t: Ty<'tcx>, expr_t: Ty<'tcx>,
id: HirId, id: HirId,
) -> DiagnosticBuilder<'_, ErrorReported> { ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
let span = field.span; let span = field.span;
debug!("no_such_field_err(span: {:?}, field: {:?}, expr_t: {:?})", span, field, expr_t); debug!("no_such_field_err(span: {:?}, field: {:?}, expr_t: {:?})", span, field, expr_t);

View file

@ -8,7 +8,7 @@ use crate::check::{BreakableCtxt, Diverges, Expectation, FnCtxt, LocalTy};
use rustc_data_structures::captures::Captures; use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{Applicability, Diagnostic, ErrorReported}; use rustc_errors::{Applicability, Diagnostic, ErrorGuaranteed};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def::{CtorOf, DefKind, Res};
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
@ -158,7 +158,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub(in super::super) fn write_resolution( pub(in super::super) fn write_resolution(
&self, &self,
hir_id: hir::HirId, hir_id: hir::HirId,
r: Result<(DefKind, DefId), ErrorReported>, r: Result<(DefKind, DefId), ErrorGuaranteed>,
) { ) {
self.typeck_results.borrow_mut().type_dependent_defs_mut().insert(hir_id, r); self.typeck_results.borrow_mut().type_dependent_defs_mut().insert(hir_id, r);
} }
@ -900,7 +900,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.or_else(|error| { .or_else(|error| {
let result = match error { let result = match error {
method::MethodError::PrivateMatch(kind, def_id, _) => Ok((kind, def_id)), method::MethodError::PrivateMatch(kind, def_id, _) => Ok((kind, def_id)),
_ => Err(ErrorReported), _ => Err(ErrorGuaranteed),
}; };
// If we have a path like `MyTrait::missing_method`, then don't register // If we have a path like `MyTrait::missing_method`, then don't register

View file

@ -4,7 +4,7 @@
use crate::check::FnCtxt; use crate::check::FnCtxt;
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::{ use rustc_errors::{
pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorReported, pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
}; };
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
@ -93,7 +93,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
source: SelfSource<'tcx>, source: SelfSource<'tcx>,
error: MethodError<'tcx>, error: MethodError<'tcx>,
args: Option<&'tcx [hir::Expr<'tcx>]>, args: Option<&'tcx [hir::Expr<'tcx>]>,
) -> Option<DiagnosticBuilder<'_, ErrorReported>> { ) -> Option<DiagnosticBuilder<'_, ErrorGuaranteed>> {
// Avoid suggestions when we don't know what's going on. // Avoid suggestions when we don't know what's going on.
if rcvr_ty.references_error() { if rcvr_ty.references_error() {
return None; return None;

View file

@ -3,7 +3,7 @@ use rustc_ast as ast;
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{ use rustc_errors::{
pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorReported, pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed,
}; };
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{CtorKind, DefKind, Res}; use rustc_hir::def::{CtorKind, DefKind, Res};
@ -100,7 +100,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
expected: Ty<'tcx>, expected: Ty<'tcx>,
actual: Ty<'tcx>, actual: Ty<'tcx>,
ti: TopInfo<'tcx>, ti: TopInfo<'tcx>,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> { ) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
self.demand_eqtype_with_origin(&self.pattern_cause(ti, cause_span), expected, actual) self.demand_eqtype_with_origin(&self.pattern_cause(ti, cause_span), expected, actual)
} }
@ -818,7 +818,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn emit_bad_pat_path<'b>( fn emit_bad_pat_path<'b>(
&self, &self,
mut e: DiagnosticBuilder<'_, ErrorReported>, mut e: DiagnosticBuilder<'_, ErrorGuaranteed>,
pat_span: Span, pat_span: Span,
res: Res, res: Res,
pat_res: Res, pat_res: Res,
@ -1369,7 +1369,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
variant: &VariantDef, variant: &VariantDef,
pat: &'_ Pat<'_>, pat: &'_ Pat<'_>,
fields: &[hir::PatField<'_>], fields: &[hir::PatField<'_>],
) -> Option<DiagnosticBuilder<'_, ErrorReported>> { ) -> Option<DiagnosticBuilder<'_, ErrorGuaranteed>> {
// if this is a tuple struct, then all field names will be numbers // if this is a tuple struct, then all field names will be numbers
// so if any fields in a struct pattern use shorthand syntax, they will // so if any fields in a struct pattern use shorthand syntax, they will
// be invalid identifiers (for example, Foo { 0, 1 }). // be invalid identifiers (for example, Foo { 0, 1 }).
@ -1442,7 +1442,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
inexistent_fields: &[Ident], inexistent_fields: &[Ident],
unmentioned_fields: &mut Vec<(&ty::FieldDef, Ident)>, unmentioned_fields: &mut Vec<(&ty::FieldDef, Ident)>,
variant: &ty::VariantDef, variant: &ty::VariantDef,
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let tcx = self.tcx; let tcx = self.tcx;
let (field_names, t, plural) = if inexistent_fields.len() == 1 { let (field_names, t, plural) = if inexistent_fields.len() == 1 {
(format!("a field named `{}`", inexistent_fields[0]), "this", "") (format!("a field named `{}`", inexistent_fields[0]), "this", "")
@ -1538,7 +1538,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pat: &Pat<'_>, pat: &Pat<'_>,
fields: &'tcx [hir::PatField<'tcx>], fields: &'tcx [hir::PatField<'tcx>],
variant: &ty::VariantDef, variant: &ty::VariantDef,
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> { ) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
if let (CtorKind::Fn, PatKind::Struct(qpath, ..)) = (variant.ctor_kind, &pat.kind) { if let (CtorKind::Fn, PatKind::Struct(qpath, ..)) = (variant.ctor_kind, &pat.kind) {
let path = rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| { let path = rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| {
s.print_qpath(qpath, false) s.print_qpath(qpath, false)
@ -1620,7 +1620,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self, &self,
pat: &Pat<'_>, pat: &Pat<'_>,
fields: &'tcx [hir::PatField<'tcx>], fields: &'tcx [hir::PatField<'tcx>],
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let mut err = self let mut err = self
.tcx .tcx
.sess .sess
@ -1712,7 +1712,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
unmentioned_fields: &[(&ty::FieldDef, Ident)], unmentioned_fields: &[(&ty::FieldDef, Ident)],
have_inaccessible_fields: bool, have_inaccessible_fields: bool,
fields: &'tcx [hir::PatField<'tcx>], fields: &'tcx [hir::PatField<'tcx>],
) -> DiagnosticBuilder<'tcx, ErrorReported> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let inaccessible = if have_inaccessible_fields { " and inaccessible fields" } else { "" }; let inaccessible = if have_inaccessible_fields { " and inaccessible fields" } else { "" };
let field_names = if unmentioned_fields.len() == 1 { let field_names = if unmentioned_fields.len() == 1 {
format!("field `{}`{}", unmentioned_fields[0].1, inaccessible) format!("field `{}`{}", unmentioned_fields[0].1, inaccessible)

View file

@ -4,7 +4,7 @@ use crate::constrained_generic_params::{identify_constrained_generic_params, Par
use rustc_ast as ast; use rustc_ast as ast;
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorReported}; use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::intravisit as hir_visit; use rustc_hir::intravisit as hir_visit;
@ -1764,7 +1764,7 @@ fn report_bivariance(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
param: &rustc_hir::GenericParam<'_>, param: &rustc_hir::GenericParam<'_>,
has_explicit_bounds: bool, has_explicit_bounds: bool,
) -> ErrorReported { ) -> ErrorGuaranteed {
let span = param.span; let span = param.span;
let param_name = param.name.ident().name; let param_name = param.name.ident().name;
let mut err = error_392(tcx, span, param_name); let mut err = error_392(tcx, span, param_name);
@ -1977,7 +1977,7 @@ fn error_392(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
span: Span, span: Span,
param_name: Symbol, param_name: Symbol,
) -> DiagnosticBuilder<'_, ErrorReported> { ) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut err = let mut err =
struct_span_err!(tcx.sess, span, E0392, "parameter `{}` is never used", param_name); struct_span_err!(tcx.sess, span, E0392, "parameter `{}` is never used", param_name);
err.span_label(span, "unused parameter"); err.span_label(span, "unused parameter");

Some files were not shown because too many files have changed in this diff Show more