mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
rename ErrorReported -> ErrorGuaranteed
This commit is contained in:
parent
c42d846add
commit
e489a94dee
@ -1,4 +1,4 @@
|
||||
use rustc_errors::{struct_span_err, DiagnosticBuilder, DiagnosticId, ErrorReported};
|
||||
use rustc_errors::{struct_span_err, DiagnosticBuilder, DiagnosticId, ErrorGuaranteed};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_span::{MultiSpan, Span};
|
||||
|
||||
@ -7,7 +7,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&self,
|
||||
span: Span,
|
||||
desc: &str,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
struct_span_err!(self, span, E0505, "cannot move out of {} because it is borrowed", desc,)
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
desc: &str,
|
||||
borrow_span: Span,
|
||||
borrow_desc: &str,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
span,
|
||||
@ -36,7 +36,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
span: Span,
|
||||
verb: &str,
|
||||
desc: &str,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
struct_span_err!(
|
||||
self,
|
||||
span,
|
||||
@ -55,7 +55,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
old_loan_span: Span,
|
||||
old_opt_via: &str,
|
||||
old_load_end_span: Option<Span>,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let via =
|
||||
|msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {})", msg) };
|
||||
let mut err = struct_span_err!(
|
||||
@ -103,7 +103,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
desc: &str,
|
||||
old_loan_span: Span,
|
||||
old_load_end_span: Option<Span>,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
new_loan_span,
|
||||
@ -136,7 +136,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
noun_old: &str,
|
||||
old_opt_via: &str,
|
||||
previous_end_span: Option<Span>,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
new_loan_span,
|
||||
@ -168,7 +168,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
old_opt_via: &str,
|
||||
previous_end_span: Option<Span>,
|
||||
second_borrow_desc: &str,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
new_loan_span,
|
||||
@ -204,7 +204,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
kind_old: &str,
|
||||
msg_old: &str,
|
||||
old_load_end_span: Option<Span>,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let via =
|
||||
|msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {})", msg) };
|
||||
let mut err = struct_span_err!(
|
||||
@ -247,7 +247,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
span: Span,
|
||||
borrow_span: Span,
|
||||
desc: &str,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
span,
|
||||
@ -266,12 +266,16 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
span: Span,
|
||||
desc: &str,
|
||||
is_arg: bool,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let msg = if is_arg { "to immutable argument" } else { "twice to immutable variable" };
|
||||
struct_span_err!(self, span, E0384, "cannot assign {} {}", msg, desc)
|
||||
}
|
||||
|
||||
crate fn cannot_assign(&self, span: Span, desc: &str) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
crate fn cannot_assign(
|
||||
&self,
|
||||
span: Span,
|
||||
desc: &str,
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
struct_span_err!(self, span, E0594, "cannot assign to {}", desc)
|
||||
}
|
||||
|
||||
@ -279,7 +283,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&self,
|
||||
move_from_span: Span,
|
||||
move_from_desc: &str,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
struct_span_err!(self, move_from_span, E0507, "cannot move out of {}", move_from_desc,)
|
||||
}
|
||||
|
||||
@ -291,7 +295,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
move_from_span: Span,
|
||||
ty: Ty<'_>,
|
||||
is_index: Option<bool>,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let type_name = match (&ty.kind(), is_index) {
|
||||
(&ty::Array(_, _), Some(true)) | (&ty::Array(_, _), None) => "array",
|
||||
(&ty::Slice(_), _) => "slice",
|
||||
@ -313,7 +317,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&self,
|
||||
move_from_span: Span,
|
||||
container_ty: Ty<'_>,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
move_from_span,
|
||||
@ -331,7 +335,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
verb: &str,
|
||||
optional_adverb_for_moved: &str,
|
||||
moved_path: Option<String>,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let moved_path = moved_path.map(|mp| format!(": `{}`", mp)).unwrap_or_default();
|
||||
|
||||
struct_span_err!(
|
||||
@ -350,7 +354,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
span: Span,
|
||||
path: &str,
|
||||
reason: &str,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
struct_span_err!(self, span, E0596, "cannot borrow {} as mutable{}", path, reason,)
|
||||
}
|
||||
|
||||
@ -361,7 +365,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
immutable_place: &str,
|
||||
immutable_section: &str,
|
||||
action: &str,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
mutate_span,
|
||||
@ -380,7 +384,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&self,
|
||||
span: Span,
|
||||
yield_span: Span,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
span,
|
||||
@ -394,7 +398,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
crate fn cannot_borrow_across_destructor(
|
||||
&self,
|
||||
borrow_span: Span,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
struct_span_err!(
|
||||
self,
|
||||
borrow_span,
|
||||
@ -407,7 +411,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&self,
|
||||
span: Span,
|
||||
path: &str,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
struct_span_err!(self, span, E0597, "{} does not live long enough", path,)
|
||||
}
|
||||
|
||||
@ -417,7 +421,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
return_kind: &str,
|
||||
reference_desc: &str,
|
||||
path_desc: &str,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
span,
|
||||
@ -442,7 +446,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
closure_kind: &str,
|
||||
borrowed_path: &str,
|
||||
capture_span: Span,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let mut err = struct_span_err!(
|
||||
self,
|
||||
closure_span,
|
||||
@ -461,14 +465,14 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
crate fn thread_local_value_does_not_live_long_enough(
|
||||
&self,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
struct_span_err!(self, span, E0712, "thread-local variable borrowed past end of function",)
|
||||
}
|
||||
|
||||
crate fn temporary_value_borrowed_for_too_long(
|
||||
&self,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
struct_span_err!(self, span, E0716, "temporary value dropped while borrowed",)
|
||||
}
|
||||
|
||||
@ -477,7 +481,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
sp: S,
|
||||
msg: &str,
|
||||
code: DiagnosticId,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
self.infcx.tcx.sess.struct_span_err_with_code(sp, msg, code)
|
||||
}
|
||||
}
|
||||
@ -486,7 +490,7 @@ crate fn borrowed_data_escapes_closure<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
escape_span: Span,
|
||||
escapes_from: &str,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
struct_span_err!(
|
||||
tcx.sess,
|
||||
escape_span,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use rustc_errors::{DiagnosticBuilder, ErrorReported};
|
||||
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
|
||||
use rustc_infer::infer::canonical::Canonical;
|
||||
use rustc_infer::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||
use rustc_infer::infer::region_constraints::Constraint;
|
||||
@ -124,7 +124,7 @@ trait TypeOpInfo<'tcx> {
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported>;
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>;
|
||||
|
||||
fn base_universe(&self) -> ty::UniverseIndex;
|
||||
|
||||
@ -134,7 +134,7 @@ trait TypeOpInfo<'tcx> {
|
||||
cause: ObligationCause<'tcx>,
|
||||
placeholder_region: ty::Region<'tcx>,
|
||||
error_region: Option<ty::Region<'tcx>>,
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>>;
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>>;
|
||||
|
||||
fn report_error(
|
||||
&self,
|
||||
@ -196,7 +196,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let mut err = tcx.sess.struct_span_err(span, "higher-ranked lifetime error");
|
||||
err.note(&format!("could not prove {}", self.canonical_query.value.value.predicate));
|
||||
err
|
||||
@ -212,7 +212,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
|
||||
cause: ObligationCause<'tcx>,
|
||||
placeholder_region: ty::Region<'tcx>,
|
||||
error_region: Option<ty::Region<'tcx>>,
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
|
||||
tcx.infer_ctxt().enter_with_canonical(
|
||||
cause.span,
|
||||
&self.canonical_query,
|
||||
@ -243,7 +243,7 @@ where
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let mut err = tcx.sess.struct_span_err(span, "higher-ranked lifetime error");
|
||||
err.note(&format!("could not normalize `{}`", self.canonical_query.value.value.value));
|
||||
err
|
||||
@ -259,7 +259,7 @@ where
|
||||
cause: ObligationCause<'tcx>,
|
||||
placeholder_region: ty::Region<'tcx>,
|
||||
error_region: Option<ty::Region<'tcx>>,
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
|
||||
tcx.infer_ctxt().enter_with_canonical(
|
||||
cause.span,
|
||||
&self.canonical_query,
|
||||
@ -304,7 +304,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
// FIXME: This error message isn't great, but it doesn't show up in the existing UI tests,
|
||||
// and is only the fallback when the nice error fails. Consider improving this some more.
|
||||
tcx.sess.struct_span_err(span, "higher-ranked lifetime error")
|
||||
@ -320,7 +320,7 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
|
||||
cause: ObligationCause<'tcx>,
|
||||
placeholder_region: ty::Region<'tcx>,
|
||||
error_region: Option<ty::Region<'tcx>>,
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
|
||||
tcx.infer_ctxt().enter_with_canonical(
|
||||
cause.span,
|
||||
&self.canonical_query,
|
||||
@ -345,7 +345,7 @@ fn try_extract_error_from_fulfill_cx<'tcx>(
|
||||
infcx: &InferCtxt<'_, 'tcx>,
|
||||
placeholder_region: ty::Region<'tcx>,
|
||||
error_region: Option<ty::Region<'tcx>>,
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
|
||||
let tcx = infcx.tcx;
|
||||
|
||||
// We generally shouldn't have errors here because the query was
|
||||
|
@ -1,7 +1,7 @@
|
||||
use either::Either;
|
||||
use rustc_const_eval::util::{CallDesugaringKind, CallKind};
|
||||
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::def_id::DefId;
|
||||
use rustc_hir::{AsyncGeneratorKind, GeneratorKind};
|
||||
@ -507,7 +507,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
location: Location,
|
||||
(place, _span): (Place<'tcx>, Span),
|
||||
borrow: &BorrowData<'tcx>,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let borrow_spans = self.retrieve_borrow_spans(borrow);
|
||||
let borrow_span = borrow_spans.args_or_use();
|
||||
|
||||
@ -554,7 +554,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
(place, span): (Place<'tcx>, Span),
|
||||
gen_borrow_kind: BorrowKind,
|
||||
issued_borrow: &BorrowData<'tcx>,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let issued_spans = self.retrieve_borrow_spans(issued_borrow);
|
||||
let issued_span = issued_spans.args_or_use();
|
||||
|
||||
@ -1120,7 +1120,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
drop_span: Span,
|
||||
borrow_spans: UseSpans<'tcx>,
|
||||
explanation: BorrowExplanation,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
debug!(
|
||||
"report_local_value_does_not_live_long_enough(\
|
||||
{:?}, {:?}, {:?}, {:?}, {:?}\
|
||||
@ -1298,7 +1298,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
&mut self,
|
||||
drop_span: Span,
|
||||
borrow_span: Span,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
debug!(
|
||||
"report_thread_local_value_does_not_live_long_enough(\
|
||||
{:?}, {:?}\
|
||||
@ -1325,7 +1325,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
borrow_spans: UseSpans<'tcx>,
|
||||
proper_span: Span,
|
||||
explanation: BorrowExplanation,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
debug!(
|
||||
"report_temporary_value_does_not_live_long_enough(\
|
||||
{:?}, {:?}, {:?}, {:?}\
|
||||
@ -1384,7 +1384,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
return_span: Span,
|
||||
category: ConstraintCategory,
|
||||
opt_place_desc: Option<&String>,
|
||||
) -> Option<DiagnosticBuilder<'cx, ErrorReported>> {
|
||||
) -> Option<DiagnosticBuilder<'cx, ErrorGuaranteed>> {
|
||||
let return_kind = match category {
|
||||
ConstraintCategory::Return(_) => "return",
|
||||
ConstraintCategory::Yield => "yield",
|
||||
@ -1483,7 +1483,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
category: ConstraintCategory,
|
||||
constraint_span: Span,
|
||||
captured_var: &str,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let tcx = self.infcx.tcx;
|
||||
let args_span = use_span.args_or_use();
|
||||
|
||||
@ -1560,7 +1560,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
upvar_span: Span,
|
||||
upvar_name: &str,
|
||||
escape_span: Span,
|
||||
) -> DiagnosticBuilder<'cx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
|
||||
let tcx = self.infcx.tcx;
|
||||
|
||||
let (_, escapes_from) = tcx.article_and_description(self.mir_def_id().to_def_id());
|
||||
|
@ -1,5 +1,5 @@
|
||||
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_middle::mir::*;
|
||||
use rustc_middle::ty;
|
||||
@ -271,7 +271,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
&mut self,
|
||||
place: Place<'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'a, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
let description = if place.projection.len() == 1 {
|
||||
format!("static item {}", self.describe_any_place(place.as_ref()))
|
||||
} else {
|
||||
@ -293,7 +293,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
deref_target_place: Place<'tcx>,
|
||||
span: Span,
|
||||
use_spans: Option<UseSpans<'tcx>>,
|
||||
) -> DiagnosticBuilder<'a, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
// Inspect the type of the content behind the
|
||||
// borrow to provide feedback about why this
|
||||
// was a move rather than a copy.
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Error reporting machinery for lifetime errors.
|
||||
|
||||
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorReported};
|
||||
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
|
||||
use rustc_infer::infer::{
|
||||
error_reporting::nice_region_error::NiceRegionError,
|
||||
error_reporting::unexpected_hidden_region_diagnostic, NllRegionVariableOrigin,
|
||||
@ -389,7 +389,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
&self,
|
||||
errci: &ErrorConstraintInfo,
|
||||
kind: ReturnConstraint,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let ErrorConstraintInfo { outlived_fr, span, .. } = errci;
|
||||
|
||||
let mut diag = self
|
||||
@ -469,7 +469,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
fn report_escaping_data_error(
|
||||
&self,
|
||||
errci: &ErrorConstraintInfo,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let ErrorConstraintInfo { span, category, .. } = errci;
|
||||
|
||||
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(
|
||||
&self,
|
||||
errci: &ErrorConstraintInfo,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let ErrorConstraintInfo {
|
||||
fr,
|
||||
fr_is_local,
|
||||
|
@ -19,7 +19,7 @@ extern crate tracing;
|
||||
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
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::def_id::LocalDefId;
|
||||
use rustc_hir::Node;
|
||||
@ -178,7 +178,7 @@ fn do_mir_borrowck<'a, 'tcx>(
|
||||
|
||||
// Gather the upvars of a closure, if any.
|
||||
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();
|
||||
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
|
||||
/// same primary span come out in a consistent order.
|
||||
buffered_move_errors:
|
||||
BTreeMap<Vec<MoveOutIndex>, (PlaceRef<'tcx>, DiagnosticBuilder<'tcx, ErrorReported>)>,
|
||||
BTreeMap<Vec<MoveOutIndex>, (PlaceRef<'tcx>, DiagnosticBuilder<'tcx, ErrorGuaranteed>)>,
|
||||
/// Diagnostics to be reported buffer.
|
||||
buffered: Vec<Diagnostic>,
|
||||
/// Set to Some if we emit an error during borrowck
|
||||
tainted_by_errors: Option<ErrorReported>,
|
||||
tainted_by_errors: Option<ErrorGuaranteed>,
|
||||
}
|
||||
|
||||
impl BorrowckErrors<'_> {
|
||||
@ -2310,8 +2310,8 @@ mod error {
|
||||
|
||||
// FIXME(eddyb) this is a suboptimal API because `tainted_by_errors` is
|
||||
// set before any emission actually happens (weakening the guarantee).
|
||||
pub fn buffer_error(&mut self, t: DiagnosticBuilder<'_, ErrorReported>) {
|
||||
self.tainted_by_errors = Some(ErrorReported {});
|
||||
pub fn buffer_error(&mut self, t: DiagnosticBuilder<'_, ErrorGuaranteed>) {
|
||||
self.tainted_by_errors = Some(ErrorGuaranteed {});
|
||||
t.buffer(&mut self.buffered);
|
||||
}
|
||||
|
||||
@ -2320,12 +2320,12 @@ mod error {
|
||||
}
|
||||
|
||||
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> {
|
||||
pub fn buffer_error(&mut self, t: DiagnosticBuilder<'_, ErrorReported>) {
|
||||
pub fn buffer_error(&mut self, t: DiagnosticBuilder<'_, ErrorGuaranteed>) {
|
||||
self.errors.buffer_error(t);
|
||||
}
|
||||
|
||||
@ -2336,7 +2336,7 @@ mod error {
|
||||
pub fn buffer_move_error(
|
||||
&mut self,
|
||||
move_out_indices: Vec<MoveOutIndex>,
|
||||
place_and_err: (PlaceRef<'tcx>, DiagnosticBuilder<'tcx, ErrorReported>),
|
||||
place_and_err: (PlaceRef<'tcx>, DiagnosticBuilder<'tcx, ErrorGuaranteed>),
|
||||
) -> bool {
|
||||
if let Some((_, diag)) =
|
||||
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.
|
||||
for (_, (_, diag)) in std::mem::take(&mut self.errors.buffered_move_errors) {
|
||||
// We have already set tainted for this error, so just buffer it.
|
||||
@ -2374,7 +2374,7 @@ mod error {
|
||||
pub fn has_move_error(
|
||||
&self,
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! Handling of `static`s, `const`s and promoted allocations
|
||||
|
||||
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::mir::interpret::{
|
||||
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;
|
||||
match err {
|
||||
ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => {
|
||||
ErrorHandled::Reported(ErrorGuaranteed) | ErrorHandled::Linted => {
|
||||
fx.tcx.sess.span_err(constant.span, "erroneous constant encountered");
|
||||
}
|
||||
ErrorHandled::TooGeneric => {
|
||||
|
@ -29,7 +29,7 @@ use std::cell::Cell;
|
||||
|
||||
use rustc_codegen_ssa::traits::CodegenBackend;
|
||||
use rustc_codegen_ssa::CodegenResults;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_metadata::EncodedMetadata;
|
||||
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
||||
use rustc_session::config::OutputFilenames;
|
||||
@ -209,7 +209,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
||||
ongoing_codegen: Box<dyn Any>,
|
||||
_sess: &Session,
|
||||
_outputs: &OutputFilenames,
|
||||
) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorReported> {
|
||||
) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorGuaranteed> {
|
||||
Ok(*ongoing_codegen
|
||||
.downcast::<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>)>()
|
||||
.unwrap())
|
||||
@ -220,7 +220,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
|
||||
sess: &Session,
|
||||
codegen_results: CodegenResults,
|
||||
outputs: &OutputFilenames,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
use rustc_codegen_ssa::back::link::link_binary;
|
||||
|
||||
link_binary::<crate::archive::ArArchiveBuilder<'_>>(sess, &codegen_results, outputs)
|
||||
|
@ -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::traits::{CodegenBackend, ExtraBackendMethods, ModuleBufferMethods, ThinBufferMethods, WriteBackendMethods};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{ErrorReported, Handler};
|
||||
use rustc_errors::{ErrorGuaranteed, Handler};
|
||||
use rustc_metadata::EncodedMetadata;
|
||||
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
@ -93,7 +93,7 @@ impl CodegenBackend for GccCodegenBackend {
|
||||
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
|
||||
.downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<GccCodegenBackend>>()
|
||||
.expect("Expected GccCodegenBackend's OngoingCodegen, found Box<Any>")
|
||||
@ -102,7 +102,7 @@ impl CodegenBackend for GccCodegenBackend {
|
||||
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;
|
||||
|
||||
link_binary::<crate::archive::ArArchiveBuilder<'_>>(
|
||||
|
@ -30,7 +30,7 @@ use rustc_codegen_ssa::traits::*;
|
||||
use rustc_codegen_ssa::ModuleCodegen;
|
||||
use rustc_codegen_ssa::{CodegenResults, CompiledModule};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{ErrorReported, FatalError, Handler};
|
||||
use rustc_errors::{ErrorGuaranteed, FatalError, Handler};
|
||||
use rustc_metadata::EncodedMetadata;
|
||||
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
||||
use rustc_middle::ty::query::Providers;
|
||||
@ -352,7 +352,7 @@ impl CodegenBackend for LlvmCodegenBackend {
|
||||
ongoing_codegen: Box<dyn Any>,
|
||||
sess: &Session,
|
||||
outputs: &OutputFilenames,
|
||||
) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorReported> {
|
||||
) -> Result<(CodegenResults, FxHashMap<WorkProductId, WorkProduct>), ErrorGuaranteed> {
|
||||
let (codegen_results, work_products) = ongoing_codegen
|
||||
.downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<LlvmCodegenBackend>>()
|
||||
.expect("Expected LlvmCodegenBackend's OngoingCodegen, found Box<Any>")
|
||||
@ -373,7 +373,7 @@ impl CodegenBackend for LlvmCodegenBackend {
|
||||
sess: &Session,
|
||||
codegen_results: CodegenResults,
|
||||
outputs: &OutputFilenames,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
use crate::back::archive::LlvmArchiveBuilder;
|
||||
use rustc_codegen_ssa::back::link::link_binary;
|
||||
|
||||
|
@ -2,7 +2,7 @@ use rustc_arena::TypedArena;
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
|
||||
use rustc_data_structures::memmap::Mmap;
|
||||
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_hir::def_id::CrateNum;
|
||||
use rustc_middle::middle::dependency_format::Linkage;
|
||||
@ -57,7 +57,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
|
||||
sess: &'a Session,
|
||||
codegen_results: &CodegenResults,
|
||||
outputs: &OutputFilenames,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let _timer = sess.timer("link_binary");
|
||||
let output_metadata = sess.opts.output_types.contains_key(&OutputType::Metadata);
|
||||
for &crate_type in sess.crate_types().iter() {
|
||||
@ -260,7 +260,7 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
|
||||
flavor: RlibFlavor,
|
||||
out_filename: &Path,
|
||||
tmpdir: &MaybeTempDir,
|
||||
) -> Result<B, ErrorReported> {
|
||||
) -> Result<B, ErrorGuaranteed> {
|
||||
info!("preparing rlib to {:?}", out_filename);
|
||||
|
||||
let lib_search_paths = archive_search_paths(sess);
|
||||
@ -407,7 +407,7 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
|
||||
fn collate_raw_dylibs(
|
||||
sess: &Session,
|
||||
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.
|
||||
let mut dylib_table = FxIndexMap::<String, FxIndexMap<Symbol, &DllImport>>::default();
|
||||
|
||||
@ -459,7 +459,7 @@ fn link_staticlib<'a, B: ArchiveBuilder<'a>>(
|
||||
codegen_results: &CodegenResults,
|
||||
out_filename: &Path,
|
||||
tempdir: &MaybeTempDir,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let mut ab =
|
||||
link_rlib::<B>(sess, codegen_results, RlibFlavor::StaticlibBase, out_filename, tempdir)?;
|
||||
let mut all_native_libs = vec![];
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::traits::*;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::ErrorHandled;
|
||||
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;
|
||||
match err {
|
||||
// errored or at least linted
|
||||
ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => {}
|
||||
ErrorHandled::Reported(ErrorGuaranteed) | ErrorHandled::Linted => {}
|
||||
ErrorHandled::TooGeneric => {
|
||||
span_bug!(const_.span, "codgen encountered polymorphic constant: {:?}", err)
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use crate::{CodegenResults, ModuleCodegen};
|
||||
|
||||
use rustc_ast::expand::allocator::AllocatorKind;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_metadata::EncodedMetadata;
|
||||
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
||||
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf, TyAndLayout};
|
||||
@ -98,7 +98,7 @@ pub trait CodegenBackend {
|
||||
ongoing_codegen: Box<dyn Any>,
|
||||
sess: &Session,
|
||||
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`
|
||||
///
|
||||
@ -110,7 +110,7 @@ pub trait CodegenBackend {
|
||||
sess: &Session,
|
||||
codegen_results: CodegenResults,
|
||||
outputs: &OutputFilenames,
|
||||
) -> Result<(), ErrorReported>;
|
||||
) -> Result<(), ErrorGuaranteed>;
|
||||
}
|
||||
|
||||
pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Send + Sync {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
@ -251,7 +251,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
||||
rustc_span::DUMMY_SP,
|
||||
"This is likely a const item that is missing from its impl",
|
||||
);
|
||||
throw_inval!(AlreadyReported(ErrorReported {}));
|
||||
throw_inval!(AlreadyReported(ErrorGuaranteed {}));
|
||||
} else {
|
||||
let path = ecx.tcx.def_path_str(def.did);
|
||||
Err(ConstEvalErrKind::NeedsRfc(format!("calling extern function `{}`", path))
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
use super::validity::RefTracking;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir as hir;
|
||||
use rustc_middle::mir::interpret::InterpResult;
|
||||
use rustc_middle::ty::{self, layout::TyAndLayout, Ty};
|
||||
@ -297,7 +297,7 @@ pub fn intern_const_alloc_recursive<
|
||||
ecx: &mut InterpCx<'mir, 'tcx, M>,
|
||||
intern_kind: InternKind,
|
||||
ret: &MPlaceTy<'tcx>,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let tcx = ecx.tcx;
|
||||
let base_intern_mode = match intern_kind {
|
||||
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
|
||||
// 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");
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
} 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
|
||||
// marked as dangling by local memory. That should be impossible.
|
||||
|
@ -4,7 +4,7 @@
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt::Write;
|
||||
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir::def::Namespace;
|
||||
use rustc_macros::HashStable;
|
||||
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>> {
|
||||
match val.val() {
|
||||
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) => {
|
||||
let instance = self.resolve(uv.def, uv.substs)?;
|
||||
Ok(self.eval_to_allocation(GlobalId { instance, promoted: uv.promoted })?.into())
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! 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::def_id::DefId;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
@ -121,7 +121,7 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
|
||||
fn in_return_place(
|
||||
&mut self,
|
||||
ccx: &'mir ConstCx<'mir, 'tcx>,
|
||||
tainted_by_errors: Option<ErrorReported>,
|
||||
tainted_by_errors: Option<ErrorGuaranteed>,
|
||||
) -> ConstQualifs {
|
||||
// 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.
|
||||
local_has_storage_dead: Option<BitSet<Local>>,
|
||||
|
||||
error_emitted: Option<ErrorReported>,
|
||||
error_emitted: Option<ErrorGuaranteed>,
|
||||
secondary_errors: Vec<Diagnostic>,
|
||||
}
|
||||
|
||||
@ -329,7 +329,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
|
||||
|
||||
match op.importance() {
|
||||
ops::DiagnosticImportance::Primary => {
|
||||
self.error_emitted = Some(ErrorReported);
|
||||
self.error_emitted = Some(ErrorGuaranteed);
|
||||
err.emit();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! 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::def_id::DefId;
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
@ -51,7 +51,7 @@ pub trait NonConstOp<'tcx>: std::fmt::Debug {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported>;
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>;
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -69,7 +69,7 @@ impl<'tcx> NonConstOp<'tcx> for FloatingPointOp {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
feature_err(
|
||||
&ccx.tcx.sess.parse_sess,
|
||||
sym::const_fn_floating_point_arithmetic,
|
||||
@ -87,7 +87,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallIndirect {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
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,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
_: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let FnCallNonConst { caller, callee, substs, span, from_hir_call } = *self;
|
||||
let ConstCx { tcx, param_env, .. } = *ccx;
|
||||
|
||||
@ -332,7 +332,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallUnstable {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let FnCallUnstable(def_id, feature) = *self;
|
||||
|
||||
let mut err = ccx.tcx.sess.struct_span_err(
|
||||
@ -370,7 +370,7 @@ impl<'tcx> NonConstOp<'tcx> for FnPtrCast {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
feature_err(
|
||||
&ccx.tcx.sess.parse_sess,
|
||||
sym::const_fn_fn_ptr_basics,
|
||||
@ -395,7 +395,7 @@ impl<'tcx> NonConstOp<'tcx> for Generator {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let msg = format!("{}s are not allowed in {}s", self.0, ccx.const_kind());
|
||||
if let hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) = self.0 {
|
||||
feature_err(&ccx.tcx.sess.parse_sess, sym::const_async_blocks, span, &msg)
|
||||
@ -412,7 +412,7 @@ impl<'tcx> NonConstOp<'tcx> for HeapAllocation {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let mut err = struct_span_err!(
|
||||
ccx.tcx.sess,
|
||||
span,
|
||||
@ -440,7 +440,7 @@ impl<'tcx> NonConstOp<'tcx> for InlineAsm {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
struct_span_err!(
|
||||
ccx.tcx.sess,
|
||||
span,
|
||||
@ -460,7 +460,7 @@ impl<'tcx> NonConstOp<'tcx> for LiveDrop {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let mut err = struct_span_err!(
|
||||
ccx.tcx.sess,
|
||||
span,
|
||||
@ -492,7 +492,7 @@ impl<'tcx> NonConstOp<'tcx> for TransientCellBorrow {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
feature_err(
|
||||
&ccx.tcx.sess.parse_sess,
|
||||
sym::const_refs_to_cell,
|
||||
@ -512,7 +512,7 @@ impl<'tcx> NonConstOp<'tcx> for CellBorrow {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let mut err = struct_span_err!(
|
||||
ccx.tcx.sess,
|
||||
span,
|
||||
@ -563,7 +563,7 @@ impl<'tcx> NonConstOp<'tcx> for MutBorrow {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let raw = match self.0 {
|
||||
hir::BorrowKind::Raw => "raw ",
|
||||
hir::BorrowKind::Ref => "",
|
||||
@ -606,7 +606,7 @@ impl<'tcx> NonConstOp<'tcx> for TransientMutBorrow {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let raw = match self.0 {
|
||||
hir::BorrowKind::Raw => "raw ",
|
||||
hir::BorrowKind::Ref => "",
|
||||
@ -637,7 +637,7 @@ impl<'tcx> NonConstOp<'tcx> for MutDeref {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
feature_err(
|
||||
&ccx.tcx.sess.parse_sess,
|
||||
sym::const_mut_refs,
|
||||
@ -655,7 +655,7 @@ impl<'tcx> NonConstOp<'tcx> for PanicNonStr {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
ccx.tcx.sess.struct_span_err(
|
||||
span,
|
||||
"argument to `panic!()` in a const context must have type `&str`",
|
||||
@ -673,7 +673,7 @@ impl<'tcx> NonConstOp<'tcx> for RawPtrComparison {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let mut err = ccx
|
||||
.tcx
|
||||
.sess
|
||||
@ -697,7 +697,7 @@ impl<'tcx> NonConstOp<'tcx> for RawMutPtrDeref {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
feature_err(
|
||||
&ccx.tcx.sess.parse_sess,
|
||||
sym::const_mut_refs,
|
||||
@ -717,7 +717,7 @@ impl<'tcx> NonConstOp<'tcx> for RawPtrToIntCast {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let mut err = ccx
|
||||
.tcx
|
||||
.sess
|
||||
@ -746,7 +746,7 @@ impl<'tcx> NonConstOp<'tcx> for StaticAccess {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let mut err = struct_span_err!(
|
||||
ccx.tcx.sess,
|
||||
span,
|
||||
@ -776,7 +776,7 @@ impl<'tcx> NonConstOp<'tcx> for ThreadLocalAccess {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
struct_span_err!(
|
||||
ccx.tcx.sess,
|
||||
span,
|
||||
@ -811,7 +811,7 @@ pub mod ty {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
feature_err(
|
||||
&ccx.tcx.sess.parse_sess,
|
||||
sym::const_mut_refs,
|
||||
@ -845,7 +845,7 @@ pub mod ty {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
feature_err(
|
||||
&ccx.tcx.sess.parse_sess,
|
||||
sym::const_fn_fn_ptr_basics,
|
||||
@ -866,7 +866,7 @@ pub mod ty {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
feature_err(
|
||||
&ccx.tcx.sess.parse_sess,
|
||||
sym::const_impl_trait,
|
||||
@ -900,7 +900,7 @@ pub mod ty {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let mut err = feature_err(
|
||||
&ccx.tcx.sess.parse_sess,
|
||||
sym::const_fn_trait_bound,
|
||||
@ -943,7 +943,7 @@ pub mod ty {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let mut err = feature_err(
|
||||
&ccx.tcx.sess.parse_sess,
|
||||
sym::const_fn_trait_bound,
|
||||
@ -974,7 +974,7 @@ pub mod ty {
|
||||
&self,
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
feature_err(
|
||||
&ccx.tcx.sess.parse_sess,
|
||||
sym::const_trait_bound_opt_out,
|
||||
|
@ -2,7 +2,7 @@
|
||||
//!
|
||||
//! See the `Qualif` trait for more info.
|
||||
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_infer::traits::TraitEngine;
|
||||
use rustc_middle::mir::*;
|
||||
@ -17,7 +17,7 @@ use super::ConstCx;
|
||||
pub fn in_any_value_of_ty<'tcx>(
|
||||
cx: &ConstCx<'_, 'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
tainted_by_errors: Option<ErrorReported>,
|
||||
tainted_by_errors: Option<ErrorGuaranteed>,
|
||||
) -> ConstQualifs {
|
||||
ConstQualifs {
|
||||
has_mut_interior: HasMutInterior::in_any_value_of_ty(cx, ty),
|
||||
|
@ -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::sync::SeqCst;
|
||||
use rustc_errors::registry::{InvalidErrorCode, Registry};
|
||||
use rustc_errors::{ErrorReported, PResult};
|
||||
use rustc_errors::{ErrorGuaranteed, PResult};
|
||||
use rustc_feature::find_gated_cfg;
|
||||
use rustc_interface::util::{self, collect_crate_types, get_codegen_backend};
|
||||
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"];
|
||||
|
||||
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 {
|
||||
Err(..) => {
|
||||
sess.abort_if_errors();
|
||||
@ -235,7 +235,7 @@ fn run_compiler(
|
||||
};
|
||||
|
||||
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))) => {
|
||||
config.input = input;
|
||||
config.input_path = input_file_path;
|
||||
@ -457,7 +457,7 @@ fn make_output(matches: &getopts::Matches) -> (Option<PathBuf>, Option<PathBuf>)
|
||||
fn make_input(
|
||||
error_format: ErrorOutputType,
|
||||
free_matches: &[String],
|
||||
) -> Result<Option<(Input, Option<PathBuf>)>, ErrorReported> {
|
||||
) -> Result<Option<(Input, Option<PathBuf>)>, ErrorGuaranteed> {
|
||||
if free_matches.len() == 1 {
|
||||
let ifile = &free_matches[0];
|
||||
if ifile == "-" {
|
||||
@ -469,7 +469,7 @@ fn make_input(
|
||||
error_format,
|
||||
"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") {
|
||||
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
|
||||
/// compilation on fatal errors. This function catches that sentinel and turns
|
||||
/// 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| {
|
||||
if value.is::<rustc_errors::FatalErrorMarker>() {
|
||||
ErrorReported
|
||||
ErrorGuaranteed
|
||||
} else {
|
||||
panic::resume_unwind(value);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use rustc_ast as ast;
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir_pretty as pprust_hir;
|
||||
use rustc_middle::hir::map as hir_map;
|
||||
@ -479,7 +479,7 @@ fn print_with_analysis(
|
||||
tcx: TyCtxt<'_>,
|
||||
ppm: PpMode,
|
||||
ofile: Option<&Path>,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
tcx.analysis(())?;
|
||||
let out = match ppm {
|
||||
Mir => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::{Diagnostic, DiagnosticId, DiagnosticStyledString, ErrorReported};
|
||||
use crate::{Diagnostic, DiagnosticId, DiagnosticStyledString, ErrorGuaranteed};
|
||||
use crate::{Handler, Level, StashKey};
|
||||
use rustc_lint_defs::Applicability;
|
||||
|
||||
@ -96,7 +96,7 @@ mod sealed_level_is_error {
|
||||
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
|
||||
/// `struct_*` methods on [`Handler`].
|
||||
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()`.
|
||||
impl EmissionGuarantee for ErrorReported {
|
||||
// FIXME(eddyb) make `ErrorGuaranteed` impossible to create outside `.emit()`.
|
||||
impl EmissionGuarantee for ErrorGuaranteed {
|
||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
||||
match db.inner.state {
|
||||
// First `.emit()` call, the `&Handler` is still available.
|
||||
@ -136,10 +136,10 @@ impl EmissionGuarantee for ErrorReported {
|
||||
assert!(
|
||||
db.inner.diagnostic.is_error(),
|
||||
"emitted non-error ({:?}) diagnostic \
|
||||
from `DiagnosticBuilder<ErrorReported>`",
|
||||
from `DiagnosticBuilder<ErrorGuaranteed>`",
|
||||
db.inner.diagnostic.level,
|
||||
);
|
||||
ErrorReported
|
||||
ErrorGuaranteed
|
||||
}
|
||||
// `.emit()` was previously called, disallowed from repeating it,
|
||||
// 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`.
|
||||
assert!(
|
||||
db.inner.diagnostic.is_error(),
|
||||
"`DiagnosticBuilder<ErrorReported>`'s diagnostic \
|
||||
"`DiagnosticBuilder<ErrorGuaranteed>`'s diagnostic \
|
||||
became non-error ({:?}), after original `.emit()`",
|
||||
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 () {
|
||||
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
|
||||
match db.inner.state {
|
||||
|
@ -54,7 +54,7 @@ mod snippet;
|
||||
mod styled_buffer;
|
||||
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.
|
||||
// (See also the comment on `DiagnosticBuilder`'s `diagnostic` field.)
|
||||
@ -682,7 +682,7 @@ impl Handler {
|
||||
&self,
|
||||
span: impl Into<MultiSpan>,
|
||||
msg: &str,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
let mut result = self.struct_err(msg);
|
||||
result.set_span(span);
|
||||
result
|
||||
@ -694,7 +694,7 @@ impl Handler {
|
||||
span: impl Into<MultiSpan>,
|
||||
msg: &str,
|
||||
code: DiagnosticId,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
let mut result = self.struct_span_err(span, msg);
|
||||
result.code(code);
|
||||
result
|
||||
@ -702,7 +702,7 @@ impl Handler {
|
||||
|
||||
/// Construct a builder at the `Error` level with the `msg`.
|
||||
// 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)
|
||||
}
|
||||
|
||||
@ -717,7 +717,7 @@ impl Handler {
|
||||
&self,
|
||||
msg: &str,
|
||||
code: DiagnosticId,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
let mut result = self.struct_err(msg);
|
||||
result.code(code);
|
||||
result
|
||||
@ -728,7 +728,7 @@ impl Handler {
|
||||
&self,
|
||||
span: impl Into<MultiSpan>,
|
||||
msg: &str,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
let mut result = self.struct_fatal(msg);
|
||||
result.set_span(span);
|
||||
result
|
||||
@ -740,14 +740,14 @@ impl Handler {
|
||||
span: impl Into<MultiSpan>,
|
||||
msg: &str,
|
||||
code: DiagnosticId,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
let mut result = self.struct_span_fatal(span, msg);
|
||||
result.code(code);
|
||||
result
|
||||
}
|
||||
|
||||
/// 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)
|
||||
}
|
||||
|
||||
@ -1343,6 +1343,6 @@ pub fn add_elided_lifetime_in_path_suggestion(
|
||||
// Useful type to use with `Result<>` indicate that an error has already
|
||||
// been reported to the user, so no need to continue checking.
|
||||
#[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);
|
||||
|
@ -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_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
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::BuiltinLintDiagnostics;
|
||||
use rustc_parse::{self, nt_to_tokenstream, parser, MACRO_ARGUMENTS};
|
||||
@ -275,7 +275,7 @@ pub trait ProcMacro {
|
||||
ecx: &'cx mut ExtCtxt<'_>,
|
||||
span: Span,
|
||||
ts: TokenStream,
|
||||
) -> Result<TokenStream, ErrorReported>;
|
||||
) -> Result<TokenStream, ErrorGuaranteed>;
|
||||
}
|
||||
|
||||
impl<F> ProcMacro for F
|
||||
@ -287,7 +287,7 @@ where
|
||||
_ecx: &'cx mut ExtCtxt<'_>,
|
||||
_span: Span,
|
||||
ts: TokenStream,
|
||||
) -> Result<TokenStream, ErrorReported> {
|
||||
) -> Result<TokenStream, ErrorGuaranteed> {
|
||||
// FIXME setup implicit context in TLS before calling self.
|
||||
Ok(self(ts))
|
||||
}
|
||||
@ -300,7 +300,7 @@ pub trait AttrProcMacro {
|
||||
span: Span,
|
||||
annotation: TokenStream,
|
||||
annotated: TokenStream,
|
||||
) -> Result<TokenStream, ErrorReported>;
|
||||
) -> Result<TokenStream, ErrorGuaranteed>;
|
||||
}
|
||||
|
||||
impl<F> AttrProcMacro for F
|
||||
@ -313,7 +313,7 @@ where
|
||||
_span: Span,
|
||||
annotation: TokenStream,
|
||||
annotated: TokenStream,
|
||||
) -> Result<TokenStream, ErrorReported> {
|
||||
) -> Result<TokenStream, ErrorGuaranteed> {
|
||||
// FIXME setup implicit context in TLS before calling self.
|
||||
Ok(self(annotation, annotated))
|
||||
}
|
||||
@ -1076,7 +1076,7 @@ impl<'a> ExtCtxt<'a> {
|
||||
&self,
|
||||
sp: S,
|
||||
msg: &str,
|
||||
) -> DiagnosticBuilder<'a, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
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<'_>,
|
||||
expr: P<ast::Expr>,
|
||||
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.
|
||||
// We want to be able to handle e.g., `concat!("foo", "bar")`.
|
||||
let expr = cx.expander().fully_expand_fragment(AstFragment::Expr(expr)).make_expr();
|
||||
|
@ -62,7 +62,7 @@ crate fn annotate_err_with_kind(err: &mut Diagnostic, kind: AstFragmentKind, spa
|
||||
}
|
||||
|
||||
fn emit_frag_parse_err(
|
||||
mut e: DiagnosticBuilder<'_, rustc_errors::ErrorReported>,
|
||||
mut e: DiagnosticBuilder<'_, rustc_errors::ErrorGuaranteed>,
|
||||
parser: &Parser<'_>,
|
||||
orig_parser: &mut Parser<'_>,
|
||||
site_span: Span,
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::base::ModuleData;
|
||||
use rustc_ast::ptr::P;
|
||||
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::validate_attr;
|
||||
use rustc_session::parse::ParseSess;
|
||||
@ -39,7 +39,7 @@ pub enum ModError<'a> {
|
||||
ModInBlock(Option<Ident>),
|
||||
FileNotFound(Ident, PathBuf, PathBuf),
|
||||
MultipleCandidates(Ident, PathBuf, PathBuf),
|
||||
ParserError(DiagnosticBuilder<'a, ErrorReported>),
|
||||
ParserError(DiagnosticBuilder<'a, ErrorGuaranteed>),
|
||||
}
|
||||
|
||||
crate fn parse_external_mod(
|
||||
@ -242,7 +242,7 @@ pub fn default_submod_path<'a>(
|
||||
}
|
||||
|
||||
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;
|
||||
match self {
|
||||
ModError::CircularInclusion(file_paths) => {
|
||||
|
@ -6,7 +6,7 @@ use rustc_ast::ptr::P;
|
||||
use rustc_ast::token;
|
||||
use rustc_ast::tokenstream::{CanSynthesizeMissingTokens, TokenStream, TokenTree};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_parse::nt_to_tokenstream;
|
||||
use rustc_parse::parser::ForceCollect;
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
@ -23,7 +23,7 @@ impl base::ProcMacro for BangProcMacro {
|
||||
ecx: &'cx mut ExtCtxt<'_>,
|
||||
span: Span,
|
||||
input: TokenStream,
|
||||
) -> Result<TokenStream, ErrorReported> {
|
||||
) -> Result<TokenStream, ErrorGuaranteed> {
|
||||
let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace;
|
||||
let server = proc_macro_server::Rustc::new(ecx);
|
||||
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.emit();
|
||||
ErrorReported
|
||||
ErrorGuaranteed
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ impl base::AttrProcMacro for AttrProcMacro {
|
||||
span: Span,
|
||||
annotation: TokenStream,
|
||||
annotated: TokenStream,
|
||||
) -> Result<TokenStream, ErrorReported> {
|
||||
) -> Result<TokenStream, ErrorGuaranteed> {
|
||||
let proc_macro_backtrace = ecx.ecfg.proc_macro_backtrace;
|
||||
let server = proc_macro_server::Rustc::new(ecx);
|
||||
self.client
|
||||
@ -59,7 +59,7 @@ impl base::AttrProcMacro for AttrProcMacro {
|
||||
err.help(&format!("message: {}", s));
|
||||
}
|
||||
err.emit();
|
||||
ErrorReported
|
||||
ErrorGuaranteed
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::svh::Svh;
|
||||
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_session::{Session, StableCrateId};
|
||||
|
||||
@ -204,7 +204,7 @@ pub fn prepare_session_directory(
|
||||
sess: &Session,
|
||||
crate_name: &str,
|
||||
stable_crate_id: StableCrateId,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
if sess.opts.incremental.is_none() {
|
||||
return Ok(());
|
||||
}
|
||||
@ -230,7 +230,7 @@ pub fn prepare_session_directory(
|
||||
crate_dir.display(),
|
||||
err
|
||||
));
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
};
|
||||
|
||||
@ -482,7 +482,7 @@ fn generate_session_dir_path(crate_dir: &Path) -> PathBuf {
|
||||
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) {
|
||||
Ok(()) => {
|
||||
debug!("{} directory created successfully", dir_tag);
|
||||
@ -496,7 +496,7 @@ fn create_dir(sess: &Session, path: &Path, dir_tag: &str) -> Result<(), ErrorRep
|
||||
path.display(),
|
||||
err
|
||||
));
|
||||
Err(ErrorReported)
|
||||
Err(ErrorGuaranteed)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -505,7 +505,7 @@ fn create_dir(sess: &Session, path: &Path, dir_tag: &str) -> Result<(), ErrorRep
|
||||
fn lock_directory(
|
||||
sess: &Session,
|
||||
session_dir: &Path,
|
||||
) -> Result<(flock::Lock, PathBuf), ErrorReported> {
|
||||
) -> Result<(flock::Lock, PathBuf), ErrorGuaranteed> {
|
||||
let lock_file_path = lock_file_path(session_dir);
|
||||
debug!("lock_directory() - lock_file: {}", lock_file_path.display());
|
||||
|
||||
@ -546,7 +546,7 @@ fn lock_directory(
|
||||
}
|
||||
}
|
||||
err.emit();
|
||||
Err(ErrorReported)
|
||||
Err(ErrorGuaranteed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ use crate::traits::{
|
||||
};
|
||||
|
||||
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_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
@ -230,7 +230,7 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>(
|
||||
span: Span,
|
||||
hidden_ty: Ty<'tcx>,
|
||||
hidden_region: ty::Region<'tcx>,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let mut err = struct_span_err!(
|
||||
tcx.sess,
|
||||
span,
|
||||
@ -258,7 +258,7 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>(
|
||||
// explanation.
|
||||
//
|
||||
// (*) 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(
|
||||
tcx,
|
||||
&mut err,
|
||||
@ -2013,7 +2013,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
&self,
|
||||
trace: TypeTrace<'tcx>,
|
||||
terr: &TypeError<'tcx>,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
use crate::traits::ObligationCauseCode::MatchExpressionArm;
|
||||
|
||||
debug!("report_and_explain_type_error(trace={:?}, terr={:?})", trace, terr);
|
||||
@ -2221,7 +2221,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
origin: Option<SubregionOrigin<'tcx>>,
|
||||
bound_kind: GenericKind<'tcx>,
|
||||
sub: Region<'tcx>,
|
||||
) -> DiagnosticBuilder<'a, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
let hir = self.tcx.hir();
|
||||
// Attempt to obtain the span of the parameter so we can
|
||||
// suggest adding an explicit lifetime bound to it.
|
||||
@ -2647,7 +2647,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
fn report_inference_failure(
|
||||
&self,
|
||||
var_origin: RegionVariableOrigin,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let br_string = |br: ty::BoundRegionKind| {
|
||||
let mut s = match br {
|
||||
ty::BrNamed(_, name) => name.to_string(),
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::infer::type_variable::TypeVariableOriginKind;
|
||||
use crate::infer::{InferCtxt, Symbol};
|
||||
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::def::{DefKind, Namespace};
|
||||
@ -490,7 +490,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
arg: GenericArg<'tcx>,
|
||||
impl_candidates: Vec<ty::TraitRef<'tcx>>,
|
||||
error_code: TypeAnnotationNeeded,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let arg = self.resolve_vars_if_possible(arg);
|
||||
let arg_data = self.extract_inference_diagnostics_data(arg, None);
|
||||
|
||||
@ -915,7 +915,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
kind: hir::GeneratorKind,
|
||||
span: Span,
|
||||
ty: Ty<'tcx>,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let ty = self.resolve_vars_if_possible(ty);
|
||||
let data = self.extract_inference_diagnostics_data(ty.into(), None);
|
||||
|
||||
|
@ -7,7 +7,7 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||
use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
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::{GenericParamKind, Ty};
|
||||
use rustc_middle::ty::Region;
|
||||
@ -49,7 +49,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
/// ```
|
||||
///
|
||||
/// 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()?;
|
||||
|
||||
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);
|
||||
|
||||
err.emit();
|
||||
Some(ErrorReported)
|
||||
Some(ErrorGuaranteed)
|
||||
}
|
||||
|
||||
fn suggest_adding_lifetime_params(
|
||||
|
@ -7,14 +7,14 @@ use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
use crate::infer::{SubregionOrigin, TypeTrace};
|
||||
use crate::traits::ObligationCauseCode;
|
||||
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::intravisit::Visitor;
|
||||
use rustc_middle::ty::TypeVisitor;
|
||||
use rustc_span::MultiSpan;
|
||||
|
||||
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()?;
|
||||
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.emit();
|
||||
Some(ErrorReported)
|
||||
Some(ErrorGuaranteed)
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
use crate::infer::lexical_region_resolve::RegionResolutionError::*;
|
||||
use crate::infer::InferCtxt;
|
||||
use rustc_errors::{DiagnosticBuilder, ErrorReported};
|
||||
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_span::source_map::Span;
|
||||
|
||||
@ -46,17 +46,17 @@ impl<'cx, 'tcx> NiceRegionError<'cx, '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
|
||||
// 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())
|
||||
}
|
||||
|
||||
pub fn try_report(&self) -> Option<ErrorReported> {
|
||||
pub fn try_report(&self) -> Option<ErrorGuaranteed> {
|
||||
self.try_report_from_nll()
|
||||
.map(|mut diag| {
|
||||
diag.emit();
|
||||
ErrorReported
|
||||
ErrorGuaranteed
|
||||
})
|
||||
.or_else(|| self.try_report_impl_not_conforming_to_trait())
|
||||
.or_else(|| self.try_report_anon_anon_conflict())
|
||||
|
@ -2,7 +2,7 @@
|
||||
//! 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::NiceRegionError;
|
||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorReported};
|
||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed};
|
||||
use rustc_middle::ty;
|
||||
|
||||
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
@ -10,7 +10,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
/// an anonymous region, emit an descriptive diagnostic error.
|
||||
pub(super) fn try_report_named_anon_conflict(
|
||||
&self,
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
|
||||
let (span, sub, sup) = self.regions()?;
|
||||
|
||||
debug!(
|
||||
|
@ -4,7 +4,7 @@ use crate::infer::ValuePairs;
|
||||
use crate::infer::{SubregionOrigin, TypeTrace};
|
||||
use crate::traits::{ObligationCause, ObligationCauseCode};
|
||||
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_id::DefId;
|
||||
use rustc_middle::ty::error::ExpectedFound;
|
||||
@ -19,7 +19,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
|
||||
/// an anonymous region, emit a descriptive diagnostic error.
|
||||
pub(super) fn try_report_placeholder_conflict(
|
||||
&self,
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
|
||||
match &self.error {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// NB. The ordering of cases in this match is very
|
||||
@ -155,7 +155,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
|
||||
sub_placeholder: Option<Region<'tcx>>,
|
||||
sup_placeholder: Option<Region<'tcx>>,
|
||||
value_pairs: &ValuePairs<'tcx>,
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
|
||||
let (expected_substs, found_substs, trait_def_id) = match value_pairs {
|
||||
ValuePairs::TraitRefs(ExpectedFound { expected, found })
|
||||
if expected.def_id == found.def_id =>
|
||||
@ -203,7 +203,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
|
||||
trait_def_id: DefId,
|
||||
expected_substs: SubstsRef<'tcx>,
|
||||
actual_substs: SubstsRef<'tcx>,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let span = cause.span(self.tcx());
|
||||
let msg = format!(
|
||||
"implementation of `{}` is not general enough",
|
||||
|
@ -5,7 +5,7 @@ use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
use crate::infer::{SubregionOrigin, TypeTrace};
|
||||
use crate::traits::{ObligationCauseCode, UnifyReceiverContext};
|
||||
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::intravisit::{walk_ty, Visitor};
|
||||
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> {
|
||||
/// 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.
|
||||
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);
|
||||
let tcx = self.tcx();
|
||||
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) {
|
||||
err.emit();
|
||||
return Some(ErrorReported);
|
||||
return Some(ErrorGuaranteed);
|
||||
} else {
|
||||
err.cancel();
|
||||
}
|
||||
@ -280,7 +280,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
);
|
||||
|
||||
err.emit();
|
||||
Some(ErrorReported)
|
||||
Some(ErrorGuaranteed)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError;
|
||||
use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||
use crate::infer::{SubregionOrigin, Subtype};
|
||||
use crate::traits::ObligationCauseCode::CompareImplMethodObligation;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::def_id::DefId;
|
||||
@ -19,7 +19,7 @@ use std::ops::ControlFlow;
|
||||
|
||||
impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
/// 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()?;
|
||||
debug!("try_report_impl_not_conforming_to_trait {:?}", error);
|
||||
if let RegionResolutionError::SubSupConflict(
|
||||
@ -46,7 +46,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
*sub_found,
|
||||
*trait_item_def_id,
|
||||
);
|
||||
return Some(ErrorReported);
|
||||
return Some(ErrorGuaranteed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -66,7 +66,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
impl_item_def_id,
|
||||
trait_item_def_id,
|
||||
);
|
||||
return Some(ErrorReported);
|
||||
return Some(ErrorGuaranteed);
|
||||
}
|
||||
}
|
||||
None
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::infer::error_reporting::{note_and_explain_region, ObligationCauseExt};
|
||||
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::ty::error::TypeError;
|
||||
use rustc_middle::ty::{self, Region};
|
||||
@ -109,7 +109,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
origin: SubregionOrigin<'tcx>,
|
||||
sub: Region<'tcx>,
|
||||
sup: Region<'tcx>,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
match origin {
|
||||
infer::Subtype(box trace) => {
|
||||
let terr = TypeError::RegionsDoesNotOutlive(sup, sub);
|
||||
@ -401,7 +401,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
placeholder_origin: SubregionOrigin<'tcx>,
|
||||
sub: Region<'tcx>,
|
||||
sup: Region<'tcx>,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
// I can't think how to do better than this right now. -nikomatsakis
|
||||
debug!(?placeholder_origin, ?sub, ?sup, "report_placeholder_failure");
|
||||
match placeholder_origin {
|
||||
|
@ -14,7 +14,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_data_structures::undo_log::Rollback;
|
||||
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::def_id::{DefId, LocalDefId};
|
||||
use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
|
||||
@ -1475,9 +1475,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
sp: Span,
|
||||
mk_diag: M,
|
||||
actual_ty: Ty<'tcx>,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported>
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>
|
||||
where
|
||||
M: FnOnce(String) -> DiagnosticBuilder<'tcx, ErrorReported>,
|
||||
M: FnOnce(String) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>,
|
||||
{
|
||||
let actual_ty = self.resolve_vars_if_possible(actual_ty);
|
||||
debug!("type_error_struct_with_diag({:?}, {:?})", sp, actual_ty);
|
||||
@ -1498,7 +1498,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
expected: Ty<'tcx>,
|
||||
actual: Ty<'tcx>,
|
||||
err: TypeError<'tcx>,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let trace = TypeTrace::types(cause, true, expected, actual);
|
||||
self.report_and_explain_type_error(trace, &err)
|
||||
}
|
||||
@ -1509,7 +1509,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
expected: ty::Const<'tcx>,
|
||||
actual: ty::Const<'tcx>,
|
||||
err: TypeError<'tcx>,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let trace = TypeTrace::consts(cause, true, expected, actual);
|
||||
self.report_and_explain_type_error(trace, &err)
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use super::ObjectSafetyViolation;
|
||||
|
||||
use crate::infer::InferCtxt;
|
||||
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::def_id::DefId;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
@ -17,7 +17,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
impl_item_def_id: DefId,
|
||||
trait_item_def_id: DefId,
|
||||
requirement: &dyn fmt::Display,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let msg = "impl has stricter requirements than trait";
|
||||
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,
|
||||
trait_def_id: DefId,
|
||||
violations: &[ObjectSafetyViolation],
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
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 {
|
||||
hir::Node::Item(item) => Some(item.ident.span),
|
||||
|
@ -8,7 +8,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_data_structures::OnDrop;
|
||||
use rustc_errors::registry::Registry;
|
||||
use rustc_errors::{ErrorReported, Handler};
|
||||
use rustc_errors::{ErrorGuaranteed, Handler};
|
||||
use rustc_lint::LintStore;
|
||||
use rustc_middle::ty;
|
||||
use rustc_parse::maybe_new_parser_from_source_str;
|
||||
@ -23,7 +23,7 @@ use rustc_span::symbol::sym;
|
||||
use std::path::PathBuf;
|
||||
use std::result;
|
||||
|
||||
pub type Result<T> = result::Result<T, ErrorReported>;
|
||||
pub type Result<T> = result::Result<T, ErrorGuaranteed>;
|
||||
|
||||
/// Represents a compiler session.
|
||||
///
|
||||
|
@ -10,7 +10,7 @@ use rustc_codegen_ssa::traits::CodegenBackend;
|
||||
use rustc_data_structures::parallel;
|
||||
use rustc_data_structures::sync::{Lrc, OnceCell, WorkerLocal};
|
||||
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_hir::def_id::{StableCrateId, LOCAL_CRATE};
|
||||
use rustc_hir::Crate;
|
||||
@ -373,7 +373,7 @@ pub fn configure_and_expand(
|
||||
if recursion_limit_hit {
|
||||
// If we hit a recursion limit, exit early to avoid later passes getting overwhelmed
|
||||
// with a large AST
|
||||
Err(ErrorReported)
|
||||
Err(ErrorGuaranteed)
|
||||
} else {
|
||||
Ok(krate)
|
||||
}
|
||||
@ -758,7 +758,7 @@ pub fn prepare_outputs(
|
||||
executable",
|
||||
input_path.display()
|
||||
));
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
if let Some(dir_path) = output_conflicts_with_dir(&output_paths) {
|
||||
sess.err(&format!(
|
||||
@ -767,7 +767,7 @@ pub fn prepare_outputs(
|
||||
input_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 fs::create_dir_all(dir).is_err() {
|
||||
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 fs::create_dir_all(dir).is_err() {
|
||||
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
|
||||
// kindck is gone now). -nmatsakis
|
||||
if sess.has_errors() {
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
|
||||
sess.time("misc_checking_3", || {
|
||||
|
@ -5,7 +5,7 @@ use rustc_ast as ast;
|
||||
use rustc_codegen_ssa::traits::CodegenBackend;
|
||||
use rustc_data_structures::svh::Svh;
|
||||
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_incremental::DepGraphFuture;
|
||||
use rustc_lint::LintStore;
|
||||
@ -123,7 +123,7 @@ impl<'tcx> Queries<'tcx> {
|
||||
self.parse.compute(|| {
|
||||
passes::parse(self.session(), &self.compiler.input).map_err(|mut parse_error| {
|
||||
parse_error.emit();
|
||||
ErrorReported
|
||||
ErrorGuaranteed
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ impl<'a> SessionDiagnosticDerive<'a> {
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
#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
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use crate::mir::interpret::ConstValue;
|
||||
use crate::ty::{layout, query::TyCtxtAt, tls, FnSig, Ty};
|
||||
|
||||
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_session::CtfeBacktrace;
|
||||
use rustc_span::def_id::DefId;
|
||||
@ -15,7 +15,7 @@ use std::{any::Any, backtrace::Backtrace, fmt};
|
||||
pub enum ErrorHandled {
|
||||
/// Already reported an error for this evaluation, and the compilation is
|
||||
/// *guaranteed* to fail. Warnings/lints *must not* produce `Reported`.
|
||||
Reported(ErrorReported),
|
||||
Reported(ErrorGuaranteed),
|
||||
/// Already emitted a lint for this evaluation.
|
||||
Linted,
|
||||
/// Don't emit an error, the evaluation failed because the MIR was generic
|
||||
@ -23,8 +23,8 @@ pub enum ErrorHandled {
|
||||
TooGeneric,
|
||||
}
|
||||
|
||||
impl From<ErrorReported> for ErrorHandled {
|
||||
fn from(err: ErrorReported) -> ErrorHandled {
|
||||
impl From<ErrorGuaranteed> for ErrorHandled {
|
||||
fn from(err: ErrorGuaranteed) -> ErrorHandled {
|
||||
ErrorHandled::Reported(err)
|
||||
}
|
||||
}
|
||||
@ -39,7 +39,7 @@ pub type EvalToConstValueResult<'tcx> = Result<ConstValue<'tcx>, ErrorHandled>;
|
||||
pub fn struct_error<'tcx>(
|
||||
tcx: TyCtxtAt<'tcx>,
|
||||
msg: &str,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
struct_span_err!(tcx.sess, tcx.span, E0080, "{}", msg)
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ fn print_backtrace(backtrace: &Backtrace) {
|
||||
impl From<ErrorHandled> for InterpErrorInfo<'_> {
|
||||
fn from(err: ErrorHandled) -> Self {
|
||||
match err {
|
||||
ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => {
|
||||
ErrorHandled::Reported(ErrorGuaranteed) | ErrorHandled::Linted => {
|
||||
err_inval!(ReferencedConstant)
|
||||
}
|
||||
ErrorHandled::TooGeneric => err_inval!(TooGeneric),
|
||||
@ -100,8 +100,8 @@ impl From<ErrorHandled> for InterpErrorInfo<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ErrorReported> for InterpErrorInfo<'_> {
|
||||
fn from(err: ErrorReported) -> Self {
|
||||
impl From<ErrorGuaranteed> for InterpErrorInfo<'_> {
|
||||
fn from(err: ErrorGuaranteed) -> Self {
|
||||
InterpError::InvalidProgram(InvalidProgramInfo::AlreadyReported(err)).into()
|
||||
}
|
||||
}
|
||||
@ -141,7 +141,7 @@ pub enum InvalidProgramInfo<'tcx> {
|
||||
/// which already produced an error.
|
||||
ReferencedConstant,
|
||||
/// Abort in case errors are already reported.
|
||||
AlreadyReported(ErrorReported),
|
||||
AlreadyReported(ErrorGuaranteed),
|
||||
/// An error occurred during layout computation.
|
||||
Layout(layout::LayoutError<'tcx>),
|
||||
/// An error occurred during FnAbi computation: the passed --target lacks FFI support
|
||||
@ -160,7 +160,7 @@ impl fmt::Display for InvalidProgramInfo<'_> {
|
||||
match self {
|
||||
TooGeneric => write!(f, "encountered overly generic constant"),
|
||||
ReferencedConstant => write!(f, "referenced constant has errors"),
|
||||
AlreadyReported(ErrorReported) => {
|
||||
AlreadyReported(ErrorGuaranteed) => {
|
||||
write!(f, "encountered constants with type errors, stopping evaluation")
|
||||
}
|
||||
Layout(ref err) => write!(f, "{}", err),
|
||||
|
@ -13,7 +13,7 @@ use crate::ty::subst::{Subst, SubstsRef};
|
||||
use crate::ty::{self, List, Ty, TyCtxt};
|
||||
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_id::{DefId, CRATE_DEF_INDEX};
|
||||
use rustc_hir::{self, GeneratorKind};
|
||||
@ -286,7 +286,7 @@ pub struct Body<'tcx> {
|
||||
predecessor_cache: PredecessorCache,
|
||||
is_cyclic: GraphIsCyclicCache,
|
||||
|
||||
pub tainted_by_errors: Option<ErrorReported>,
|
||||
pub tainted_by_errors: Option<ErrorGuaranteed>,
|
||||
}
|
||||
|
||||
impl<'tcx> Body<'tcx> {
|
||||
@ -300,7 +300,7 @@ impl<'tcx> Body<'tcx> {
|
||||
var_debug_info: Vec<VarDebugInfo<'tcx>>,
|
||||
span: Span,
|
||||
generator_kind: Option<GeneratorKind>,
|
||||
tainted_by_errors: Option<ErrorReported>,
|
||||
tainted_by_errors: Option<ErrorGuaranteed>,
|
||||
) -> Self {
|
||||
// We need `arg_count` locals, and one for the return place.
|
||||
assert!(
|
||||
|
@ -4,7 +4,7 @@ use crate::mir::{Body, Promoted};
|
||||
use crate::ty::{self, Ty, TyCtxt};
|
||||
use rustc_data_structures::stable_map::FxHashMap;
|
||||
use rustc_data_structures::vec_map::VecMap;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_index::bit_set::BitMatrix;
|
||||
@ -245,7 +245,7 @@ pub struct BorrowCheckResult<'tcx> {
|
||||
pub concrete_opaque_types: VecMap<OpaqueTypeKey<'tcx>, Ty<'tcx>>,
|
||||
pub closure_requirements: Option<ClosureRegionRequirements<'tcx>>,
|
||||
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.
|
||||
@ -259,7 +259,7 @@ pub struct ConstQualifs {
|
||||
pub needs_drop: bool,
|
||||
pub needs_non_const_drop: 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
|
||||
|
@ -142,7 +142,7 @@ rustc_queries! {
|
||||
separate_provide_extern
|
||||
}
|
||||
|
||||
query analysis(key: ()) -> Result<(), ErrorReported> {
|
||||
query analysis(key: ()) -> Result<(), ErrorGuaranteed> {
|
||||
eval_always
|
||||
desc { "running analysis passes on this crate" }
|
||||
}
|
||||
@ -312,7 +312,7 @@ rustc_queries! {
|
||||
/// Try to build an abstract representation of the given constant.
|
||||
query thir_abstract_const(
|
||||
key: DefId
|
||||
) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorReported> {
|
||||
) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorGuaranteed> {
|
||||
desc {
|
||||
|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.
|
||||
query thir_abstract_const_of_const_arg(
|
||||
key: (LocalDefId, DefId)
|
||||
) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorReported> {
|
||||
) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorGuaranteed> {
|
||||
desc {
|
||||
|tcx|
|
||||
"building an abstract representation for the const argument {}",
|
||||
@ -1107,7 +1107,7 @@ rustc_queries! {
|
||||
|
||||
query codegen_fulfill_obligation(
|
||||
key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
|
||||
) -> Result<&'tcx ImplSource<'tcx, ()>, ErrorReported> {
|
||||
) -> Result<&'tcx ImplSource<'tcx, ()>, ErrorGuaranteed> {
|
||||
cache_on_disk_if { true }
|
||||
desc { |tcx|
|
||||
"checking if `{}` fulfills its obligations",
|
||||
@ -1890,20 +1890,20 @@ rustc_queries! {
|
||||
/// * `Ok(Some(instance))` on success
|
||||
/// * `Ok(None)` when the `SubstsRef` are still too generic,
|
||||
/// 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
|
||||
/// from `Ok(None)` to avoid misleading diagnostics when an error
|
||||
/// has already been/will be emitted, for the original cause
|
||||
query resolve_instance(
|
||||
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) }
|
||||
remap_env_constness
|
||||
}
|
||||
|
||||
query resolve_instance_of_const_arg(
|
||||
key: ty::ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)>
|
||||
) -> Result<Option<ty::Instance<'tcx>>, ErrorReported> {
|
||||
) -> Result<Option<ty::Instance<'tcx>>, ErrorGuaranteed> {
|
||||
desc {
|
||||
"resolving instance of the const argument `{}`",
|
||||
ty::Instance::new(key.value.0.to_def_id(), key.value.2),
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! A subset of a mir body used for const evaluatability checking.
|
||||
use crate::mir;
|
||||
use crate::ty::{self, Ty, TyCtxt};
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
|
||||
rustc_index::newtype_index! {
|
||||
/// An index into an `AbstractConst`.
|
||||
@ -31,13 +31,13 @@ pub enum Node<'tcx> {
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
|
||||
pub enum NotConstEvaluatable {
|
||||
Error(ErrorReported),
|
||||
Error(ErrorGuaranteed),
|
||||
MentionsInfer,
|
||||
MentionsParam,
|
||||
}
|
||||
|
||||
impl From<ErrorReported> for NotConstEvaluatable {
|
||||
fn from(e: ErrorReported) -> NotConstEvaluatable {
|
||||
impl From<ErrorGuaranteed> for NotConstEvaluatable {
|
||||
fn from(e: ErrorGuaranteed) -> NotConstEvaluatable {
|
||||
NotConstEvaluatable::Error(e)
|
||||
}
|
||||
}
|
||||
@ -51,7 +51,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
pub fn thir_abstract_const_opt_const_arg(
|
||||
self,
|
||||
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() {
|
||||
self.thir_abstract_const_of_const_arg((did, param_did))
|
||||
} else {
|
||||
|
@ -2,7 +2,7 @@ use crate::ty::fast_reject::SimplifiedType;
|
||||
use crate::ty::fold::TypeFoldable;
|
||||
use crate::ty::{self, TyCtxt};
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir::def_id::{DefId, DefIdMap};
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
@ -243,11 +243,11 @@ pub fn ancestors<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
trait_def_id: DefId,
|
||||
start_from_impl: DefId,
|
||||
) -> Result<Ancestors<'tcx>, ErrorReported> {
|
||||
) -> Result<Ancestors<'tcx>, ErrorGuaranteed> {
|
||||
let specialization_graph = tcx.specialization_graph_of(trait_def_id);
|
||||
|
||||
if specialization_graph.has_errored || tcx.type_of(start_from_impl).references_error() {
|
||||
Err(ErrorReported)
|
||||
Err(ErrorGuaranteed)
|
||||
} else {
|
||||
Ok(Ancestors {
|
||||
trait_def_id,
|
||||
|
@ -6,7 +6,7 @@ use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::stable_hasher::HashingControls;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorKind, DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
@ -424,7 +424,7 @@ impl<'tcx> AdtDef {
|
||||
}
|
||||
Err(err) => {
|
||||
let msg = match err {
|
||||
ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => {
|
||||
ErrorHandled::Reported(ErrorGuaranteed) | ErrorHandled::Linted => {
|
||||
"enum discriminant evaluation failed"
|
||||
}
|
||||
ErrorHandled::TooGeneric => "enum discriminant depends on generics",
|
||||
|
@ -5,7 +5,7 @@ use crate::ty::{
|
||||
TyCtxt, TypeFoldable,
|
||||
};
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_macros::HashStable;
|
||||
@ -264,7 +264,7 @@ impl<'tcx> Const<'tcx> {
|
||||
if let Some(val) = self.val().try_eval(tcx, param_env) {
|
||||
match val {
|
||||
Ok(val) => Const::from_value(tcx, val, self.ty()),
|
||||
Err(ErrorReported) => tcx.const_error(self.ty()),
|
||||
Err(ErrorGuaranteed) => tcx.const_error(self.ty()),
|
||||
}
|
||||
} else {
|
||||
self
|
||||
|
@ -5,7 +5,7 @@ use crate::mir::Promoted;
|
||||
use crate::ty::subst::{InternalSubsts, SubstsRef};
|
||||
use crate::ty::ParamEnv;
|
||||
use crate::ty::{self, TyCtxt, TypeFoldable};
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_macros::HashStable;
|
||||
use rustc_target::abi::Size;
|
||||
@ -130,7 +130,7 @@ impl<'tcx> ConstKind<'tcx> {
|
||||
self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ParamEnv<'tcx>,
|
||||
) -> Option<Result<ConstValue<'tcx>, ErrorReported>> {
|
||||
) -> Option<Result<ConstValue<'tcx>, ErrorGuaranteed>> {
|
||||
if let ConstKind::Unevaluated(unevaluated) = self {
|
||||
use crate::mir::interpret::ErrorHandled;
|
||||
|
||||
|
@ -33,7 +33,7 @@ use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap};
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_data_structures::steal::Steal;
|
||||
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::def::{DefKind, Res};
|
||||
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
|
||||
/// 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`)
|
||||
/// 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>>,
|
||||
|
||||
/// If any errors occurred while type-checking this body,
|
||||
/// this field will be set to `Some(ErrorReported)`.
|
||||
pub tainted_by_errors: Option<ErrorReported>,
|
||||
/// this field will be set to `Some(ErrorGuaranteed)`.
|
||||
pub tainted_by_errors: Option<ErrorGuaranteed>,
|
||||
|
||||
/// All the opaque types that are restricted to concrete types
|
||||
/// by this function.
|
||||
@ -569,7 +569,7 @@ impl<'tcx> TypeckResults<'tcx> {
|
||||
|
||||
pub fn type_dependent_defs(
|
||||
&self,
|
||||
) -> LocalTableInContext<'_, Result<(DefKind, DefId), ErrorReported>> {
|
||||
) -> LocalTableInContext<'_, Result<(DefKind, DefId), ErrorGuaranteed>> {
|
||||
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(
|
||||
&mut self,
|
||||
) -> LocalTableInContextMut<'_, Result<(DefKind, DefId), ErrorReported>> {
|
||||
) -> LocalTableInContextMut<'_, Result<(DefKind, DefId), ErrorGuaranteed>> {
|
||||
LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.type_dependent_defs }
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use crate::ty::print::{FmtPrinter, Printer};
|
||||
use crate::ty::subst::{InternalSubsts, Subst};
|
||||
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_id::{CrateNum, DefId};
|
||||
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
|
||||
/// `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
|
||||
/// from `Ok(None)` to avoid misleading diagnostics when an error
|
||||
/// has already been/will be emitted, for the original cause
|
||||
@ -358,7 +358,7 @@ impl<'tcx> Instance<'tcx> {
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
def_id: DefId,
|
||||
substs: SubstsRef<'tcx>,
|
||||
) -> Result<Option<Instance<'tcx>>, ErrorReported> {
|
||||
) -> Result<Option<Instance<'tcx>>, ErrorGuaranteed> {
|
||||
Instance::resolve_opt_const_arg(
|
||||
tcx,
|
||||
param_env,
|
||||
@ -374,7 +374,7 @@ impl<'tcx> Instance<'tcx> {
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
def: ty::WithOptConstParam<DefId>,
|
||||
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
|
||||
// fine to erase all of the input regions.
|
||||
|
||||
|
@ -37,7 +37,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||
use rustc_data_structures::steal::Steal;
|
||||
use rustc_data_structures::svh::Svh;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId};
|
||||
|
@ -260,7 +260,7 @@ TrivialTypeFoldableAndLiftImpls! {
|
||||
crate::ty::UniverseIndex,
|
||||
crate::ty::Variance,
|
||||
::rustc_span::Span,
|
||||
::rustc_errors::ErrorReported,
|
||||
::rustc_errors::ErrorGuaranteed,
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -7,7 +7,7 @@ use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::definitions::DefPathHash;
|
||||
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_macros::HashStable;
|
||||
|
||||
/// A trait's definition with type information.
|
||||
@ -110,7 +110,7 @@ impl<'tcx> TraitDef {
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
of_impl: DefId,
|
||||
) -> Result<specialization_graph::Ancestors<'tcx>, ErrorReported> {
|
||||
) -> Result<specialization_graph::Ancestors<'tcx>, ErrorGuaranteed> {
|
||||
specialization_graph::ancestors(tcx, self.def_id, of_impl)
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ use rustc_attr::{self as attr, SignedInt, UnsignedInt};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorOf, DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
@ -352,7 +352,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
pub fn calculate_dtor(
|
||||
self,
|
||||
adt_did: DefId,
|
||||
validate: impl Fn(Self, DefId) -> Result<(), ErrorReported>,
|
||||
validate: impl Fn(Self, DefId) -> Result<(), ErrorGuaranteed>,
|
||||
) -> Option<ty::Destructor> {
|
||||
let drop_trait = self.lang_items().drop_trait()?;
|
||||
self.ensure().coherent_trait(drop_trait);
|
||||
|
@ -2,7 +2,7 @@ use crate::build;
|
||||
use crate::build::expr::as_place::PlaceBuilder;
|
||||
use crate::build::scope::DropKind;
|
||||
use crate::thir::pattern::pat_from_hir;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
@ -714,7 +714,7 @@ fn construct_error<'a, 'tcx>(
|
||||
hir_id: hir::HirId,
|
||||
body_id: hir::BodyId,
|
||||
body_owner_kind: hir::BodyOwnerKind,
|
||||
err: ErrorReported,
|
||||
err: ErrorGuaranteed,
|
||||
) -> Body<'tcx> {
|
||||
let tcx = infcx.tcx;
|
||||
let span = tcx.hir().span(hir_id);
|
||||
|
@ -7,7 +7,7 @@ use super::{PatCtxt, PatternError};
|
||||
use rustc_arena::TypedArena;
|
||||
use rustc_ast::Mutability;
|
||||
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::def::*;
|
||||
@ -42,7 +42,7 @@ fn create_e0004(
|
||||
sess: &Session,
|
||||
sp: Span,
|
||||
error_message: String,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
struct_span_err!(sess, sp, E0004, "{}", &error_message)
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@
|
||||
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
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::def_id::{DefId, DefIdMap, LocalDefId, LOCAL_CRATE};
|
||||
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) {
|
||||
// The `monomorphize` call should have evaluated that constant already.
|
||||
Ok(val) => val,
|
||||
Err(ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted) => return,
|
||||
Err(ErrorHandled::Reported(ErrorGuaranteed) | ErrorHandled::Linted) => {
|
||||
return;
|
||||
}
|
||||
Err(ErrorHandled::TooGeneric) => span_bug!(
|
||||
self.body.source_info(location).span,
|
||||
"collection encountered polymorphic constant: {:?}",
|
||||
@ -748,7 +750,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
|
||||
substituted_constant,
|
||||
val
|
||||
),
|
||||
Err(ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted) => {}
|
||||
Err(ErrorHandled::Reported(ErrorGuaranteed) | ErrorHandled::Linted) => {}
|
||||
Err(ErrorHandled::TooGeneric) => span_bug!(
|
||||
self.body.source_info(location).span,
|
||||
"collection encountered polymorphic constant: {}",
|
||||
|
@ -4,7 +4,7 @@ use rustc_ast::token::{self, CommentKind, Token, TokenKind};
|
||||
use rustc_ast::tokenstream::{Spacing, TokenStream};
|
||||
use rustc_ast::util::unicode::contains_text_flow_control_chars;
|
||||
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::{Base, DocStyle, RawStrError};
|
||||
@ -129,7 +129,7 @@ impl<'a> StringReader<'a> {
|
||||
to_pos: BytePos,
|
||||
m: &str,
|
||||
c: char,
|
||||
) -> DiagnosticBuilder<'a, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
self.sess
|
||||
.span_diagnostic
|
||||
.struct_span_fatal(self.mk_sp(from_pos, to_pos), &format!("{}: {}", m, escaped_char(c)))
|
||||
|
@ -16,7 +16,7 @@ use rustc_ast::{
|
||||
};
|
||||
use rustc_ast_pretty::pprust;
|
||||
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_span::source_map::Spanned;
|
||||
use rustc_span::symbol::{kw, Ident};
|
||||
@ -57,7 +57,7 @@ impl Error {
|
||||
self,
|
||||
sp: impl Into<MultiSpan>,
|
||||
handler: &Handler,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
match self {
|
||||
Error::UselessDocComment => {
|
||||
let mut err = struct_span_err!(
|
||||
@ -159,7 +159,7 @@ impl<'a> Parser<'a> {
|
||||
&self,
|
||||
sp: S,
|
||||
err: Error,
|
||||
) -> DiagnosticBuilder<'a, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
err.span_err(sp, self.diagnostic())
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ impl<'a> Parser<'a> {
|
||||
&self,
|
||||
sp: S,
|
||||
m: &str,
|
||||
) -> DiagnosticBuilder<'a, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
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)
|
||||
}
|
||||
|
||||
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(
|
||||
self.token.span,
|
||||
&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 `,`.
|
||||
pub(super) fn check_mistyped_turbofish_with_multiple_type_params(
|
||||
&mut self,
|
||||
mut e: DiagnosticBuilder<'a, ErrorReported>,
|
||||
mut e: DiagnosticBuilder<'a, ErrorGuaranteed>,
|
||||
expr: &mut P<Expr>,
|
||||
) -> PResult<'a, ()> {
|
||||
if let ExprKind::Binary(binop, _, _) = &expr.kind
|
||||
@ -1451,7 +1451,7 @@ impl<'a> Parser<'a> {
|
||||
pub(super) fn recover_closing_delimiter(
|
||||
&mut self,
|
||||
tokens: &[TokenKind],
|
||||
mut err: DiagnosticBuilder<'a, ErrorReported>,
|
||||
mut err: DiagnosticBuilder<'a, ErrorGuaranteed>,
|
||||
) -> PResult<'a, bool> {
|
||||
let mut pos = None;
|
||||
// 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) {
|
||||
(&token::Eof, Some(origin)) => {
|
||||
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(
|
||||
&mut self,
|
||||
start: Span,
|
||||
mut err: DiagnosticBuilder<'a, ErrorReported>,
|
||||
mut err: DiagnosticBuilder<'a, ErrorGuaranteed>,
|
||||
) -> PResult<'a, GenericArg> {
|
||||
let is_op_or_dot = AssocOp::from_token(&self.token)
|
||||
.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
|
||||
pub fn dummy_const_arg_needs_braces(
|
||||
&self,
|
||||
mut err: DiagnosticBuilder<'a, ErrorReported>,
|
||||
mut err: DiagnosticBuilder<'a, ErrorGuaranteed>,
|
||||
span: Span,
|
||||
) -> GenericArg {
|
||||
err.multipart_suggestion(
|
||||
@ -2115,7 +2115,7 @@ impl<'a> Parser<'a> {
|
||||
pub(super) fn incorrect_move_async_order_found(
|
||||
&self,
|
||||
move_async_span: Span,
|
||||
) -> DiagnosticBuilder<'a, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
let mut err =
|
||||
self.struct_span_err(move_async_span, "the order of `move` and `async` is incorrect");
|
||||
err.span_suggestion_verbose(
|
||||
|
@ -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::{Arm, Async, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLimits};
|
||||
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::BuiltinLintDiagnostics;
|
||||
use rustc_span::edition::LATEST_STABLE_EDITION;
|
||||
@ -2126,9 +2126,9 @@ impl<'a> Parser<'a> {
|
||||
fn error_missing_if_then_block(
|
||||
&self,
|
||||
if_span: Span,
|
||||
err: Option<DiagnosticBuilder<'a, ErrorReported>>,
|
||||
err: Option<DiagnosticBuilder<'a, ErrorGuaranteed>>,
|
||||
binop_span: Option<Span>,
|
||||
) -> DiagnosticBuilder<'a, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
let msg = "this `if` expression has a condition, but no block";
|
||||
|
||||
let mut err = if let Some(mut err) = err {
|
||||
|
@ -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::{MacArgs, MacCall, MacDelimiter};
|
||||
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::lev_distance::lev_distance;
|
||||
use rustc_span::source_map::{self, Span};
|
||||
@ -799,7 +799,7 @@ impl<'a> Parser<'a> {
|
||||
before_where_clause_span: Span,
|
||||
after_predicates: &[WherePredicate],
|
||||
after_where_clause_span: Span,
|
||||
) -> ErrorReported {
|
||||
) -> ErrorGuaranteed {
|
||||
let mut err =
|
||||
self.struct_span_err(after_where_clause_span, "where clause not allowed here");
|
||||
if !after_predicates.is_empty() {
|
||||
|
@ -32,7 +32,9 @@ use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
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_span::source_map::{MultiSpan, Span, DUMMY_SP};
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
@ -877,7 +879,7 @@ impl<'a> Parser<'a> {
|
||||
fn recover_missing_braces_around_closure_body(
|
||||
&mut self,
|
||||
closure_spans: ClosureSpans,
|
||||
mut expect_err: DiagnosticBuilder<'_, ErrorReported>,
|
||||
mut expect_err: DiagnosticBuilder<'_, ErrorGuaranteed>,
|
||||
) -> PResult<'a, ()> {
|
||||
let initial_semicolon = self.token.span;
|
||||
|
||||
@ -1429,7 +1431,7 @@ impl<'a> Parser<'a> {
|
||||
crate fn make_unclosed_delims_error(
|
||||
unmatched: UnmatchedBrace,
|
||||
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
|
||||
// `unmatched_braces` only for error recovery in the `Parser`.
|
||||
let found_delim = unmatched.found_delim?;
|
||||
|
@ -8,7 +8,7 @@ use rustc_ast::{
|
||||
PatField, PatKind, Path, QSelf, RangeEnd, RangeSyntax,
|
||||
};
|
||||
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::symbol::{kw, sym, Ident};
|
||||
|
||||
@ -678,7 +678,7 @@ impl<'a> Parser<'a> {
|
||||
|
||||
fn fatal_unexpected_non_pat(
|
||||
&mut self,
|
||||
err: DiagnosticBuilder<'a, ErrorReported>,
|
||||
err: DiagnosticBuilder<'a, ErrorGuaranteed>,
|
||||
expected: Expected,
|
||||
) -> PResult<'a, P<Pat>> {
|
||||
err.cancel();
|
||||
@ -914,7 +914,7 @@ impl<'a> Parser<'a> {
|
||||
let mut fields = Vec::new();
|
||||
let mut etc = false;
|
||||
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;
|
||||
|
||||
while self.token != token::CloseDelim(token::Brace) {
|
||||
|
@ -18,7 +18,7 @@ use rustc_ast::{
|
||||
};
|
||||
use rustc_ast::{Block, BlockCheckMode, Expr, ExprKind, Local, Stmt};
|
||||
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::symbol::{kw, sym};
|
||||
|
||||
@ -415,7 +415,7 @@ impl<'a> Parser<'a> {
|
||||
fn error_block_no_opening_brace_msg(
|
||||
&mut self,
|
||||
msg: &str,
|
||||
) -> DiagnosticBuilder<'a, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
let sp = self.token.span;
|
||||
let mut e = self.struct_span_err(sp, msg);
|
||||
let do_not_suggest_help = self.token.is_keyword(kw::In) || self.token == token::Colon;
|
||||
|
@ -7,7 +7,7 @@ use crate::query::caches::QueryCache;
|
||||
use crate::query::{QueryContext, QueryState};
|
||||
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_errors::{DiagnosticBuilder, ErrorReported};
|
||||
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
|
||||
use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
|
||||
@ -27,7 +27,7 @@ pub struct QueryVtable<CTX: QueryContext, K, V> {
|
||||
|
||||
pub compute: fn(CTX::DepContext, K) -> V,
|
||||
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>>,
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,9 @@ use crate::query::{QueryContext, QueryStackFrame};
|
||||
use rustc_hir::def::DefKind;
|
||||
|
||||
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_span::Span;
|
||||
|
||||
@ -530,7 +532,7 @@ pub fn deadlock<CTX: QueryContext>(tcx: CTX, registry: &rayon_core::Registry) {
|
||||
pub(crate) fn report_cycle<'a>(
|
||||
sess: &'a Session,
|
||||
CycleError { usage, cycle: stack }: CycleError,
|
||||
) -> DiagnosticBuilder<'a, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
assert!(!stack.is_empty());
|
||||
|
||||
let fix_span = |span: Span, query: &QueryStackFrame| {
|
||||
|
@ -15,7 +15,7 @@ use rustc_data_structures::profiling::TimingGuard;
|
||||
use rustc_data_structures::sharded::Sharded;
|
||||
use rustc_data_structures::sync::Lock;
|
||||
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_span::{Span, DUMMY_SP};
|
||||
use std::cell::Cell;
|
||||
@ -118,7 +118,7 @@ where
|
||||
fn mk_cycle<CTX, V, R>(
|
||||
tcx: CTX,
|
||||
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>,
|
||||
) -> R
|
||||
where
|
||||
|
@ -3,7 +3,9 @@ use std::ptr;
|
||||
use rustc_ast::{self as ast, Path};
|
||||
use rustc_ast_pretty::pprust;
|
||||
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_hir::def::Namespace::{self, *};
|
||||
use rustc_hir::def::{self, CtorKind, CtorOf, DefKind, NonMacroAttrKind};
|
||||
@ -110,7 +112,7 @@ impl<'a> Resolver<'a> {
|
||||
&self,
|
||||
span: Span,
|
||||
resolution_error: ResolutionError<'_>,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
match resolution_error {
|
||||
ResolutionError::GenericParamsFromOuterFunction(outer_res, has_generic_params) => {
|
||||
let mut err = struct_span_err!(
|
||||
@ -627,7 +629,7 @@ impl<'a> Resolver<'a> {
|
||||
crate fn report_vis_error(
|
||||
&self,
|
||||
vis_resolution_error: VisResolutionError<'_>,
|
||||
) -> ErrorReported {
|
||||
) -> ErrorGuaranteed {
|
||||
match vis_resolution_error {
|
||||
VisResolutionError::Relative2018(span, path) => {
|
||||
let mut err = self.session.struct_span_err(
|
||||
|
@ -13,7 +13,7 @@ use rustc_ast::{
|
||||
use rustc_ast_pretty::pprust::path_segment_to_string;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
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::def::Namespace::{self, *};
|
||||
@ -135,7 +135,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
||||
span: Span,
|
||||
source: PathSource<'_>,
|
||||
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 ns = source.namespace();
|
||||
let is_expected = &|res| source.is_expected(res);
|
||||
@ -1819,7 +1819,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
||||
&self,
|
||||
spans: Vec<Span>,
|
||||
count: usize,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
struct_span_err!(
|
||||
self.tcx.sess,
|
||||
spans,
|
||||
|
@ -40,7 +40,9 @@ use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||
use rustc_data_structures::intern::Interned;
|
||||
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_hir::def::Namespace::*;
|
||||
use rustc_hir::def::{self, CtorOf, DefKind, NonMacroAttrKind, PartialRes};
|
||||
@ -713,7 +715,7 @@ struct PrivacyError<'a> {
|
||||
}
|
||||
|
||||
struct UseError<'a> {
|
||||
err: DiagnosticBuilder<'a, ErrorReported>,
|
||||
err: DiagnosticBuilder<'a, ErrorGuaranteed>,
|
||||
/// Candidates which user could `use` to access the missing type.
|
||||
candidates: Vec<ImportSuggestion>,
|
||||
/// The `DefId` of the module to place the use-statements in.
|
||||
|
@ -7,7 +7,7 @@ use rustc_ast::node_id::NodeId;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::sync::{Lock, Lrc};
|
||||
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_span::edition::Edition;
|
||||
use rustc_span::hygiene::ExpnId;
|
||||
@ -82,7 +82,7 @@ pub fn feature_err<'a>(
|
||||
feature: Symbol,
|
||||
span: impl Into<MultiSpan>,
|
||||
explain: &str,
|
||||
) -> DiagnosticBuilder<'a, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
feature_err_issue(sess, feature, span, GateIssue::Language, explain)
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ pub fn feature_err_issue<'a>(
|
||||
span: impl Into<MultiSpan>,
|
||||
issue: GateIssue,
|
||||
explain: &str,
|
||||
) -> DiagnosticBuilder<'a, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
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) {
|
||||
|
@ -19,7 +19,7 @@ use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitterWriter;
|
||||
use rustc_errors::emitter::{Emitter, EmitterWriter, HumanReadableErrorType};
|
||||
use rustc_errors::json::JsonEmitter;
|
||||
use rustc_errors::registry::Registry;
|
||||
use rustc_errors::{Diagnostic, DiagnosticBuilder, DiagnosticId, ErrorReported};
|
||||
use rustc_errors::{Diagnostic, DiagnosticBuilder, DiagnosticId, ErrorGuaranteed};
|
||||
use rustc_macros::HashStable_Generic;
|
||||
pub use rustc_span::def_id::StableCrateId;
|
||||
use rustc_span::edition::Edition;
|
||||
@ -221,7 +221,7 @@ enum DiagnosticBuilderMethod {
|
||||
pub trait SessionDiagnostic<'a> {
|
||||
/// Write out as a diagnostic out of `sess`.
|
||||
#[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
|
||||
@ -335,7 +335,7 @@ impl Session {
|
||||
&self,
|
||||
sp: S,
|
||||
msg: &str,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
self.diagnostic().struct_span_err(sp, msg)
|
||||
}
|
||||
pub fn struct_span_err_with_code<S: Into<MultiSpan>>(
|
||||
@ -343,25 +343,25 @@ impl Session {
|
||||
sp: S,
|
||||
msg: &str,
|
||||
code: DiagnosticId,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
self.diagnostic().struct_span_err_with_code(sp, msg, 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)
|
||||
}
|
||||
pub fn struct_err_with_code(
|
||||
&self,
|
||||
msg: &str,
|
||||
code: DiagnosticId,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
self.diagnostic().struct_err_with_code(msg, code)
|
||||
}
|
||||
pub fn struct_span_fatal<S: Into<MultiSpan>>(
|
||||
&self,
|
||||
sp: S,
|
||||
msg: &str,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
self.diagnostic().struct_span_fatal(sp, msg)
|
||||
}
|
||||
pub fn struct_span_fatal_with_code<S: Into<MultiSpan>>(
|
||||
@ -369,10 +369,10 @@ impl Session {
|
||||
sp: S,
|
||||
msg: &str,
|
||||
code: DiagnosticId,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
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)
|
||||
}
|
||||
|
||||
@ -406,7 +406,7 @@ impl Session {
|
||||
pub fn err(&self, msg: &str) {
|
||||
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()
|
||||
}
|
||||
#[inline]
|
||||
@ -422,22 +422,22 @@ impl Session {
|
||||
pub fn abort_if_errors(&self) {
|
||||
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() {
|
||||
self.diagnostic().emit_stashed_diagnostics();
|
||||
Err(ErrorReported)
|
||||
Err(ErrorGuaranteed)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
// 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
|
||||
F: FnOnce() -> T,
|
||||
{
|
||||
let old_count = self.err_count();
|
||||
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) {
|
||||
self.diagnostic().span_warn(sp, msg)
|
||||
|
@ -8,7 +8,7 @@ use crate::traits::{
|
||||
FulfillmentContext, ImplSource, Obligation, ObligationCause, SelectionContext, TraitEngine,
|
||||
Unimplemented,
|
||||
};
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_middle::ty::fold::TypeFoldable;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
|
||||
@ -22,7 +22,7 @@ use rustc_middle::ty::{self, TyCtxt};
|
||||
pub fn codegen_fulfill_obligation<'tcx>(
|
||||
tcx: TyCtxt<'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.
|
||||
let trait_ref = tcx.erase_regions(trait_ref);
|
||||
// We expect the input to be fully normalized.
|
||||
@ -59,7 +59,7 @@ pub fn codegen_fulfill_obligation<'tcx>(
|
||||
trait_ref
|
||||
),
|
||||
);
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
Err(Unimplemented) => {
|
||||
// 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
|
||||
),
|
||||
);
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
Err(e) => {
|
||||
bug!("Encountered error `{:?}` selecting `{:?}` during codegen", e, trait_ref)
|
||||
|
@ -9,7 +9,7 @@
|
||||
//! `thir_abstract_const` which can then be checked for structural equality with other
|
||||
//! generic constants mentioned in the `caller_bounds` of the current environment.
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_infer::infer::InferCtxt;
|
||||
@ -171,7 +171,7 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
|
||||
}),
|
||||
Err(ErrorHandled::Linted) => {
|
||||
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)),
|
||||
Ok(_) => Ok(()),
|
||||
@ -194,7 +194,7 @@ impl<'tcx> AbstractConst<'tcx> {
|
||||
pub fn new(
|
||||
tcx: TyCtxt<'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)?;
|
||||
debug!("AbstractConst::new({:?}) = {:?}", uv, inner);
|
||||
Ok(inner.map(|inner| AbstractConst { inner, substs: uv.substs }))
|
||||
@ -203,10 +203,10 @@ impl<'tcx> AbstractConst<'tcx> {
|
||||
pub fn from_const(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
ct: ty::Const<'tcx>,
|
||||
) -> Result<Option<AbstractConst<'tcx>>, ErrorReported> {
|
||||
) -> Result<Option<AbstractConst<'tcx>>, ErrorGuaranteed> {
|
||||
match ct.val() {
|
||||
ty::ConstKind::Unevaluated(uv) => AbstractConst::new(tcx, uv.shrink()),
|
||||
ty::ConstKind::Error(_) => Err(ErrorReported),
|
||||
ty::ConstKind::Error(_) => Err(ErrorGuaranteed),
|
||||
_ => Ok(None),
|
||||
}
|
||||
}
|
||||
@ -241,7 +241,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
|
||||
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
|
||||
.sess
|
||||
.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")
|
||||
.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
|
||||
.sess
|
||||
.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")
|
||||
.emit();
|
||||
|
||||
Err(ErrorReported)
|
||||
Err(ErrorGuaranteed)
|
||||
}
|
||||
|
||||
fn new(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
(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() };
|
||||
|
||||
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
|
||||
/// 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);
|
||||
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()))
|
||||
}
|
||||
|
||||
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;
|
||||
let node = &self.body.exprs[node];
|
||||
debug!("recurse_build: node={:?}", node);
|
||||
@ -503,7 +503,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
|
||||
pub(super) fn thir_abstract_const<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
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 {
|
||||
match tcx.def_kind(def.did) {
|
||||
// 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);
|
||||
if body.0.borrow().exprs.is_empty() {
|
||||
// type error in constant, there is no thir
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
|
||||
AbstractConstBuilder::new(tcx, (&*body.0.borrow(), body.1))?
|
||||
@ -542,10 +542,10 @@ pub(super) fn try_unify_abstract_consts<'tcx>(
|
||||
|
||||
Ok(false)
|
||||
})()
|
||||
.unwrap_or_else(|ErrorReported| true)
|
||||
.unwrap_or_else(|ErrorGuaranteed| true)
|
||||
// FIXME(generic_const_exprs): We should instead have this
|
||||
// method return the resulting `ty::Const` and return `ConstKind::Error`
|
||||
// on `ErrorReported`.
|
||||
// on `ErrorGuaranteed`.
|
||||
}
|
||||
|
||||
pub fn walk_abstract_const<'tcx, R, F>(
|
||||
|
@ -13,7 +13,7 @@ use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||
use crate::infer::{self, InferCtxt, TyCtxtInferExt};
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
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::def_id::DefId;
|
||||
@ -102,7 +102,7 @@ pub trait InferCtxtExt<'tcx> {
|
||||
expected_args: Vec<ArgKind>,
|
||||
found_args: Vec<ArgKind>,
|
||||
is_closure: bool,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported>;
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>;
|
||||
}
|
||||
|
||||
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.
|
||||
SelectionError::NotConstEvaluatable(NotConstEvaluatable::Error(ErrorReported)) => {
|
||||
// FIXME(eddyb) remove this once `ErrorReported` becomes a proof token.
|
||||
self.tcx.sess.delay_span_bug(span, "`ErrorReported` without an error");
|
||||
SelectionError::NotConstEvaluatable(NotConstEvaluatable::Error(ErrorGuaranteed)) => {
|
||||
// FIXME(eddyb) remove this once `ErrorGuaranteed` becomes a proof token.
|
||||
self.tcx.sess.delay_span_bug(span, "`ErrorGuaranteed` without an error");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1019,7 +1019,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
expected_args: Vec<ArgKind>,
|
||||
found_args: Vec<ArgKind>,
|
||||
is_closure: bool,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let kind = if is_closure { "closure" } else { "function" };
|
||||
|
||||
let args_str = |arguments: &[ArgKind], other: &[ArgKind]| {
|
||||
|
@ -11,7 +11,7 @@ use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_errors::{
|
||||
error_code, pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder,
|
||||
ErrorReported, Style,
|
||||
ErrorGuaranteed, Style,
|
||||
};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::DefKind;
|
||||
@ -123,7 +123,7 @@ pub trait InferCtxtExt<'tcx> {
|
||||
found_span: Option<Span>,
|
||||
expected_ref: ty::PolyTraitRef<'tcx>,
|
||||
found: ty::PolyTraitRef<'tcx>,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported>;
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>;
|
||||
|
||||
fn suggest_fully_qualified_path(
|
||||
&self,
|
||||
@ -1260,7 +1260,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
found_span: Option<Span>,
|
||||
expected_ref: ty::PolyTraitRef<'tcx>,
|
||||
found: ty::PolyTraitRef<'tcx>,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
crate fn build_fn_sig_string<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
|
@ -3,7 +3,7 @@ use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::obligation_forest::ProcessResult;
|
||||
use rustc_data_structures::obligation_forest::{Error, ForestObligation, Outcome};
|
||||
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::{SelectionError, TraitEngine, TraitEngineExt as _, TraitObligation};
|
||||
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(ErrorReported))) => ProcessResult::Error(
|
||||
CodeSelectionError(SelectionError::NotConstEvaluatable(
|
||||
NotConstEvaluatable::Error(ErrorReported),
|
||||
(Err(ErrorHandled::Reported(ErrorGuaranteed)), _)
|
||||
| (_, Err(ErrorHandled::Reported(ErrorGuaranteed))) => {
|
||||
ProcessResult::Error(CodeSelectionError(
|
||||
SelectionError::NotConstEvaluatable(NotConstEvaluatable::Error(
|
||||
ErrorGuaranteed,
|
||||
)),
|
||||
),
|
||||
))
|
||||
}
|
||||
(Err(ErrorHandled::Linted), _) | (_, Err(ErrorHandled::Linted)) => {
|
||||
span_bug!(
|
||||
obligation.cause.span(self.selcx.tcx()),
|
||||
|
@ -26,7 +26,7 @@ use crate::infer::outlives::env::OutlivesEnvironment;
|
||||
use crate::infer::{InferCtxt, RegionckMode, TyCtxtInferExt};
|
||||
use crate::traits::error_reporting::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::def_id::DefId;
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
@ -206,7 +206,7 @@ fn do_normalize_predicates<'tcx>(
|
||||
cause: ObligationCause<'tcx>,
|
||||
elaborated_env: ty::ParamEnv<'tcx>,
|
||||
predicates: Vec<ty::Predicate<'tcx>>,
|
||||
) -> Result<Vec<ty::Predicate<'tcx>>, ErrorReported> {
|
||||
) -> Result<Vec<ty::Predicate<'tcx>>, ErrorGuaranteed> {
|
||||
debug!(
|
||||
"do_normalize_predicates(predicates={:?}, region_context={:?}, cause={:?})",
|
||||
predicates, region_context, cause,
|
||||
@ -232,7 +232,7 @@ fn do_normalize_predicates<'tcx>(
|
||||
Ok(predicates) => predicates,
|
||||
Err(errors) => {
|
||||
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,
|
||||
// all things considered.
|
||||
tcx.sess.span_err(span, &fixup_err.to_string());
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
};
|
||||
if predicates.needs_infer() {
|
||||
tcx.sess.delay_span_bug(span, "encountered inference variables after `fully_resolve`");
|
||||
Err(ErrorReported)
|
||||
Err(ErrorGuaranteed)
|
||||
} else {
|
||||
Ok(predicates)
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use rustc_ast::{MetaItem, NestedMetaItem};
|
||||
use rustc_attr as attr;
|
||||
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_middle::ty::{self, GenericParamDefKind, TyCtxt};
|
||||
use rustc_parse_format::{ParseMode, Parser, Piece, Position};
|
||||
@ -41,14 +41,14 @@ fn parse_error(
|
||||
message: &str,
|
||||
label: &str,
|
||||
note: Option<&str>,
|
||||
) -> ErrorReported {
|
||||
) -> ErrorGuaranteed {
|
||||
let mut diag = struct_span_err!(tcx.sess, span, E0232, "{}", message);
|
||||
diag.span_label(span, label);
|
||||
if let Some(note) = note {
|
||||
diag.note(note);
|
||||
}
|
||||
diag.emit();
|
||||
ErrorReported
|
||||
ErrorGuaranteed
|
||||
}
|
||||
|
||||
impl<'tcx> OnUnimplementedDirective {
|
||||
@ -58,7 +58,7 @@ impl<'tcx> OnUnimplementedDirective {
|
||||
items: &[NestedMetaItem],
|
||||
span: Span,
|
||||
is_root: bool,
|
||||
) -> Result<Self, ErrorReported> {
|
||||
) -> Result<Self, ErrorGuaranteed> {
|
||||
let mut errored = false;
|
||||
let mut item_iter = items.iter();
|
||||
|
||||
@ -164,7 +164,7 @@ impl<'tcx> OnUnimplementedDirective {
|
||||
}
|
||||
|
||||
if errored {
|
||||
Err(ErrorReported)
|
||||
Err(ErrorGuaranteed)
|
||||
} else {
|
||||
Ok(OnUnimplementedDirective {
|
||||
condition,
|
||||
@ -182,7 +182,7 @@ impl<'tcx> OnUnimplementedDirective {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
trait_def_id: DefId,
|
||||
impl_def_id: DefId,
|
||||
) -> Result<Option<Self>, ErrorReported> {
|
||||
) -> Result<Option<Self>, ErrorGuaranteed> {
|
||||
let attrs = tcx.get_attrs(impl_def_id);
|
||||
|
||||
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,
|
||||
}))
|
||||
} else {
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
};
|
||||
debug!("of_item({:?}/{:?}) = {:?}", trait_def_id, impl_def_id, result);
|
||||
result
|
||||
@ -283,7 +283,7 @@ impl<'tcx> OnUnimplementedFormatString {
|
||||
trait_def_id: DefId,
|
||||
from: Symbol,
|
||||
err_sp: Span,
|
||||
) -> Result<Self, ErrorReported> {
|
||||
) -> Result<Self, ErrorGuaranteed> {
|
||||
let result = OnUnimplementedFormatString(from);
|
||||
result.verify(tcx, trait_def_id, err_sp)?;
|
||||
Ok(result)
|
||||
@ -294,7 +294,7 @@ impl<'tcx> OnUnimplementedFormatString {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
trait_def_id: DefId,
|
||||
span: Span,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let name = tcx.item_name(trait_def_id);
|
||||
let generics = tcx.generics_of(trait_def_id);
|
||||
let s = self.0.as_str();
|
||||
@ -334,7 +334,7 @@ impl<'tcx> OnUnimplementedFormatString {
|
||||
name
|
||||
)
|
||||
.emit();
|
||||
result = Err(ErrorReported);
|
||||
result = Err(ErrorGuaranteed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -347,7 +347,7 @@ impl<'tcx> OnUnimplementedFormatString {
|
||||
"only named substitution parameters are allowed"
|
||||
)
|
||||
.emit();
|
||||
result = Err(ErrorReported);
|
||||
result = Err(ErrorGuaranteed);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ use crate::traits::error_reporting::InferCtxtExt as _;
|
||||
use crate::traits::select::ProjectionMatchesProjection;
|
||||
use rustc_data_structures::sso::SsoHashSet;
|
||||
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_id::DefId;
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
@ -1326,7 +1326,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
|
||||
// `rustc_ty_utils::instance::resolve_associated_item()`.
|
||||
let node_item =
|
||||
assoc_def(selcx, impl_data.impl_def_id, obligation.predicate.item_def_id)
|
||||
.map_err(|ErrorReported| ())?;
|
||||
.map_err(|ErrorGuaranteed| ())?;
|
||||
|
||||
if node_item.is_final() {
|
||||
// Non-specializable items are always projectable.
|
||||
@ -1918,7 +1918,7 @@ fn assoc_def(
|
||||
selcx: &SelectionContext<'_, '_>,
|
||||
impl_def_id: DefId,
|
||||
assoc_def_id: DefId,
|
||||
) -> Result<specialization_graph::LeafDef, ErrorReported> {
|
||||
) -> Result<specialization_graph::LeafDef, ErrorGuaranteed> {
|
||||
let tcx = selcx.tcx();
|
||||
let trait_def_id = tcx.impl_trait_ref(impl_def_id).unwrap().def_id;
|
||||
let trait_def = tcx.trait_def(trait_def_id);
|
||||
|
@ -29,7 +29,7 @@ use crate::traits::project::ProjectionCacheKeyExt;
|
||||
use crate::traits::ProjectionCacheKey;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
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::def_id::DefId;
|
||||
use rustc_infer::infer::LateBoundRegionConversionTime;
|
||||
@ -674,8 +674,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
Err(_) => Ok(EvaluatedToErr),
|
||||
}
|
||||
}
|
||||
(Err(ErrorHandled::Reported(ErrorReported)), _)
|
||||
| (_, Err(ErrorHandled::Reported(ErrorReported))) => Ok(EvaluatedToErr),
|
||||
(Err(ErrorHandled::Reported(ErrorGuaranteed)), _)
|
||||
| (_, Err(ErrorHandled::Reported(ErrorGuaranteed))) => Ok(EvaluatedToErr),
|
||||
(Err(ErrorHandled::Linted), _) | (_, Err(ErrorHandled::Linted)) => {
|
||||
span_bug!(
|
||||
obligation.cause.span(self.tcx()),
|
||||
|
@ -1,4 +1,4 @@
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
||||
@ -114,7 +114,7 @@ impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> {
|
||||
fn resolve_instance<'tcx>(
|
||||
tcx: TyCtxt<'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();
|
||||
if let Some(did) = did.as_local() {
|
||||
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>(
|
||||
tcx: TyCtxt<'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();
|
||||
inner_resolve_instance(
|
||||
tcx,
|
||||
@ -143,7 +143,7 @@ fn resolve_instance_of_const_arg<'tcx>(
|
||||
fn inner_resolve_instance<'tcx>(
|
||||
tcx: TyCtxt<'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 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>,
|
||||
trait_id: DefId,
|
||||
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");
|
||||
|
||||
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).
|
||||
//
|
||||
// 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
|
||||
// the declaration in the `trait`), so that we can cheaply check
|
||||
// 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);
|
||||
tcx.sess.delay_span_bug(span, &msg);
|
||||
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ use crate::astconv::{
|
||||
use crate::errors::AssocTypeBindingNotAllowed;
|
||||
use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs};
|
||||
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::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
@ -602,7 +602,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
correct: if lifetimes_correct && args_correct {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(GenericArgCountMismatch { reported: Some(ErrorReported), invalid_args })
|
||||
Err(GenericArgCountMismatch { reported: Some(ErrorGuaranteed), invalid_args })
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,9 @@ use crate::middle::resolve_lifetime as rl;
|
||||
use crate::require_c_abi_if_c_variadic;
|
||||
use rustc_ast::TraitObjectSyntax;
|
||||
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::def::{CtorOf, DefKind, Namespace, Res};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
@ -162,7 +164,7 @@ pub(crate) enum GenericArgPosition {
|
||||
#[derive(Clone, Default)]
|
||||
pub struct GenericArgCountMismatch {
|
||||
/// 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.
|
||||
pub invalid_args: Vec<Span>,
|
||||
}
|
||||
@ -733,7 +735,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
let mut dup_bindings = FxHashMap::default();
|
||||
for binding in &assoc_bindings {
|
||||
// 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,
|
||||
poly_trait_ref,
|
||||
binding,
|
||||
@ -742,7 +744,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
&mut dup_bindings,
|
||||
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
|
||||
@ -1096,7 +1098,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
speculative: bool,
|
||||
dup_bindings: &mut FxHashMap<DefId, Span>,
|
||||
path_span: Span,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
// Given something like `U: SomeTrait<T = X>`, we want to produce a
|
||||
// predicate like `<U as SomeTrait>::T = X`. This is somewhat
|
||||
// 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,
|
||||
assoc_name: Ident,
|
||||
span: Span,
|
||||
) -> Result<ty::PolyTraitRef<'tcx>, ErrorReported> {
|
||||
) -> Result<ty::PolyTraitRef<'tcx>, ErrorGuaranteed> {
|
||||
let tcx = self.tcx();
|
||||
|
||||
debug!(
|
||||
@ -1646,7 +1648,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
assoc_name: Ident,
|
||||
span: Span,
|
||||
is_equality: impl Fn() -> Option<String>,
|
||||
) -> Result<ty::PolyTraitRef<'tcx>, ErrorReported>
|
||||
) -> Result<ty::PolyTraitRef<'tcx>, ErrorGuaranteed>
|
||||
where
|
||||
I: Iterator<Item = ty::PolyTraitRef<'tcx>>,
|
||||
{
|
||||
@ -1665,7 +1667,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
assoc_name,
|
||||
span,
|
||||
);
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
};
|
||||
debug!("one_bound_for_assoc_type: bound = {:?}", bound);
|
||||
@ -1752,7 +1754,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
}
|
||||
err.emit();
|
||||
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,
|
||||
assoc_segment: &hir::PathSegment<'_>,
|
||||
permit_variants: bool,
|
||||
) -> Result<(Ty<'tcx>, DefKind, DefId), ErrorReported> {
|
||||
) -> Result<(Ty<'tcx>, DefKind, DefId), ErrorGuaranteed> {
|
||||
let tcx = self.tcx();
|
||||
let assoc_ident = assoc_segment.ident;
|
||||
|
||||
@ -1809,7 +1811,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
// trait reference.
|
||||
let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) else {
|
||||
// A cycle error occurred, most likely.
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
};
|
||||
|
||||
self.one_bound_for_assoc_type(
|
||||
@ -1878,7 +1880,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
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 msg = format!("found associated const `{assoc_ident}` when type was expected");
|
||||
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);
|
||||
@ -2617,7 +2619,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
&self,
|
||||
constrained_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) {
|
||||
let br_name = match *br {
|
||||
|
@ -32,7 +32,7 @@ use super::FnCtxt;
|
||||
|
||||
use crate::hir::def_id::DefId;
|
||||
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::lang_items::LangItem;
|
||||
use rustc_middle::mir::Mutability;
|
||||
@ -86,13 +86,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
&self,
|
||||
t: Ty<'tcx>,
|
||||
span: Span,
|
||||
) -> Result<Option<PointerKind<'tcx>>, ErrorReported> {
|
||||
) -> Result<Option<PointerKind<'tcx>>, ErrorGuaranteed> {
|
||||
debug!("pointer_kind({:?}, {:?})", t, span);
|
||||
|
||||
let t = self.resolve_vars_if_possible(t);
|
||||
|
||||
if t.references_error() {
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
|
||||
if self.type_is_known_to_be_sized_modulo_regions(t, span) {
|
||||
@ -142,7 +142,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
self.tcx
|
||||
.sess
|
||||
.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)]
|
||||
pub enum CastError {
|
||||
ErrorReported,
|
||||
ErrorGuaranteed,
|
||||
|
||||
CastToBool,
|
||||
CastToChar,
|
||||
@ -167,9 +167,9 @@ pub enum CastError {
|
||||
UnknownCastPtrKind,
|
||||
}
|
||||
|
||||
impl From<ErrorReported> for CastError {
|
||||
fn from(ErrorReported: ErrorReported) -> Self {
|
||||
CastError::ErrorReported
|
||||
impl From<ErrorGuaranteed> for CastError {
|
||||
fn from(ErrorGuaranteed: ErrorGuaranteed) -> Self {
|
||||
CastError::ErrorGuaranteed
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ fn make_invalid_casting_error<'a, 'tcx>(
|
||||
expr_ty: Ty<'tcx>,
|
||||
cast_ty: Ty<'tcx>,
|
||||
fcx: &FnCtxt<'a, 'tcx>,
|
||||
) -> DiagnosticBuilder<'a, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
type_error_struct!(
|
||||
sess,
|
||||
span,
|
||||
@ -199,7 +199,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||
cast_ty: Ty<'tcx>,
|
||||
cast_span: Span,
|
||||
span: Span,
|
||||
) -> Result<CastCheck<'tcx>, ErrorReported> {
|
||||
) -> Result<CastCheck<'tcx>, ErrorGuaranteed> {
|
||||
let check = CastCheck { expr, expr_ty, cast_ty, cast_span, span };
|
||||
|
||||
// For better error messages, check for some obviously unsized
|
||||
@ -208,7 +208,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||
match cast_ty.kind() {
|
||||
ty::Dynamic(..) | ty::Slice(..) => {
|
||||
check.report_cast_to_unsized_type(fcx);
|
||||
Err(ErrorReported)
|
||||
Err(ErrorGuaranteed)
|
||||
}
|
||||
_ => Ok(check),
|
||||
}
|
||||
@ -216,7 +216,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||
|
||||
fn report_cast_error(&self, fcx: &FnCtxt<'a, 'tcx>, e: CastError) {
|
||||
match e {
|
||||
CastError::ErrorReported => {
|
||||
CastError::ErrorGuaranteed => {
|
||||
// an error has already been reported
|
||||
}
|
||||
CastError::NeedDeref => {
|
||||
|
@ -4,7 +4,7 @@ use super::compare_method::{compare_const_impl, compare_impl_method, compare_ty_
|
||||
use super::*;
|
||||
|
||||
use rustc_attr as attr;
|
||||
use rustc_errors::{Applicability, ErrorReported};
|
||||
use rustc_errors::{Applicability, ErrorGuaranteed};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::intravisit::Visitor;
|
||||
@ -623,13 +623,13 @@ pub(super) fn check_opaque_for_cycles<'tcx>(
|
||||
substs: SubstsRef<'tcx>,
|
||||
span: Span,
|
||||
origin: &hir::OpaqueTyOrigin,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
if tcx.try_expand_impl_trait_type(def_id.to_def_id(), substs).is_err() {
|
||||
match origin {
|
||||
hir::OpaqueTyOrigin::AsyncFn(..) => async_opaque_type_cycle_error(tcx, span),
|
||||
_ => opaque_type_cycle_error(tcx, def_id, span),
|
||||
}
|
||||
Err(ErrorReported)
|
||||
Err(ErrorGuaranteed)
|
||||
} else {
|
||||
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 trait_substs =
|
||||
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,
|
||||
assoc_item,
|
||||
assoc_item,
|
||||
|
@ -37,7 +37,9 @@
|
||||
|
||||
use crate::astconv::AstConv;
|
||||
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::def_id::DefId;
|
||||
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>,
|
||||
id: 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 pointing_at_return_type = false;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::errors::LifetimesOrBoundsMismatchOnTrait;
|
||||
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::def::{DefKind, Res};
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if let Err(ErrorReported) =
|
||||
if let Err(ErrorGuaranteed) =
|
||||
compare_number_of_generics(tcx, impl_m, impl_m_span, trait_m, trait_item_span)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
if let Err(ErrorReported) =
|
||||
if let Err(ErrorGuaranteed) =
|
||||
compare_predicate_entailment(tcx, impl_m, impl_m_span, trait_m, impl_trait_ref)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -79,7 +80,7 @@ fn compare_predicate_entailment<'tcx>(
|
||||
impl_m_span: Span,
|
||||
trait_m: &ty::AssocItem,
|
||||
impl_trait_ref: ty::TraitRef<'tcx>,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let trait_to_impl_substs = impl_trait_ref.substs;
|
||||
|
||||
// This node-id should be used for the `body_id` field on each
|
||||
@ -385,7 +386,7 @@ fn compare_predicate_entailment<'tcx>(
|
||||
false,
|
||||
);
|
||||
diag.emit();
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
|
||||
// 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);
|
||||
if !errors.is_empty() {
|
||||
infcx.report_fulfillment_errors(&errors, None, false);
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
|
||||
// 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_generics: &ty::Generics,
|
||||
impl_generics: &ty::Generics,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let trait_params = trait_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),
|
||||
generics_span,
|
||||
});
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -501,7 +502,7 @@ fn compare_self_type<'tcx>(
|
||||
impl_m_span: Span,
|
||||
trait_m: &ty::AssocItem,
|
||||
impl_trait_ref: ty::TraitRef<'tcx>,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
// Try to give more informative error messages about self typing
|
||||
// mismatches. Note that any mismatch will also be detected
|
||||
// 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.emit();
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
|
||||
(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.emit();
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
}
|
||||
|
||||
@ -583,7 +584,7 @@ fn compare_number_of_generics<'tcx>(
|
||||
_impl_span: Span,
|
||||
trait_: &ty::AssocItem,
|
||||
trait_span: Option<Span>,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let trait_own_counts = tcx.generics_of(trait_.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>(
|
||||
@ -702,7 +703,7 @@ fn compare_number_of_method_arguments<'tcx>(
|
||||
impl_m_span: Span,
|
||||
trait_m: &ty::AssocItem,
|
||||
trait_item_span: Option<Span>,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let impl_m_fty = tcx.fn_sig(impl_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();
|
||||
@ -772,7 +773,7 @@ fn compare_number_of_method_arguments<'tcx>(
|
||||
),
|
||||
);
|
||||
err.emit();
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -782,7 +783,7 @@ fn compare_synthetic_generics<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
impl_m: &ty::AssocItem,
|
||||
trait_m: &ty::AssocItem,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
// FIXME(chrisvittal) Clean up this function, list of FIXME items:
|
||||
// 1. Better messages for the span labels
|
||||
// 2. Explanation as to what is going on
|
||||
@ -921,7 +922,7 @@ fn compare_synthetic_generics<'tcx>(
|
||||
error_found = true;
|
||||
}
|
||||
}
|
||||
if error_found { Err(ErrorReported) } else { Ok(()) }
|
||||
if error_found { Err(ErrorGuaranteed) } else { Ok(()) }
|
||||
}
|
||||
|
||||
fn compare_const_param_types<'tcx>(
|
||||
@ -929,7 +930,7 @@ fn compare_const_param_types<'tcx>(
|
||||
impl_m: &ty::AssocItem,
|
||||
trait_m: &ty::AssocItem,
|
||||
trait_item_span: Option<Span>,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let const_params_of = |def_id| {
|
||||
tcx.generics_of(def_id).params.iter().filter_map(|param| match param.kind {
|
||||
GenericParamDefKind::Const { .. } => Some(param.def_id),
|
||||
@ -979,7 +980,7 @@ fn compare_const_param_types<'tcx>(
|
||||
),
|
||||
);
|
||||
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);
|
||||
|
||||
let _: Result<(), ErrorReported> = (|| {
|
||||
let _: Result<(), ErrorGuaranteed> = (|| {
|
||||
compare_number_of_generics(tcx, impl_ty, impl_ty_span, trait_ty, trait_item_span)?;
|
||||
|
||||
let sp = tcx.def_span(impl_ty.def_id);
|
||||
@ -1119,7 +1120,7 @@ fn compare_type_predicate_entailment<'tcx>(
|
||||
impl_ty_span: Span,
|
||||
trait_ty: &ty::AssocItem,
|
||||
impl_trait_ref: ty::TraitRef<'tcx>,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let impl_substs = InternalSubsts::identity_for_item(tcx, impl_ty.def_id);
|
||||
let trait_to_impl_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);
|
||||
if !errors.is_empty() {
|
||||
infcx.report_fulfillment_errors(&errors, None, false);
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
|
||||
// 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_span: Span,
|
||||
impl_trait_ref: ty::TraitRef<'tcx>,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
// Given
|
||||
//
|
||||
// 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);
|
||||
if !errors.is_empty() {
|
||||
infcx.report_fulfillment_errors(&errors, None, false);
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
|
||||
// Finally, resolve all regions. This catches wily misuses of
|
||||
|
@ -4,7 +4,7 @@ use rustc_trait_selection::infer::InferCtxtExt as _;
|
||||
use rustc_trait_selection::traits::ObligationCause;
|
||||
|
||||
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::lang_items::LangItem;
|
||||
use rustc_hir::{is_range_literal, Node};
|
||||
@ -57,7 +57,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
sp: Span,
|
||||
expected: Ty<'tcx>,
|
||||
actual: Ty<'tcx>,
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
|
||||
self.demand_suptype_with_origin(&self.misc(sp), expected, actual)
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
cause: &ObligationCause<'tcx>,
|
||||
expected: Ty<'tcx>,
|
||||
actual: Ty<'tcx>,
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
|
||||
match self.at(cause, self.param_env).sup(expected, actual) {
|
||||
Ok(InferOk { obligations, value: () }) => {
|
||||
self.register_predicates(obligations);
|
||||
@ -88,7 +88,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
sp: Span,
|
||||
expected: Ty<'tcx>,
|
||||
actual: Ty<'tcx>,
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
|
||||
self.demand_eqtype_with_origin(&self.misc(sp), expected, actual)
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
cause: &ObligationCause<'tcx>,
|
||||
expected: Ty<'tcx>,
|
||||
actual: Ty<'tcx>,
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
|
||||
match self.at(cause, self.param_env).eq(expected, actual) {
|
||||
Ok(InferOk { obligations, value: () }) => {
|
||||
self.register_predicates(obligations);
|
||||
@ -134,7 +134,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
expected: Ty<'tcx>,
|
||||
expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>,
|
||||
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 e = match self.try_coerce(expr, checked_ty, expected, allow_two_phase, None) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::check::regionck::RegionCtxt;
|
||||
use crate::hir;
|
||||
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::{InferOk, RegionckMode, TyCtxtInferExt};
|
||||
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.
|
||||
/// 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_predicates = tcx.predicates_of(drop_impl_did);
|
||||
match dtor_self_type.kind() {
|
||||
@ -59,7 +59,7 @@ pub fn check_drop_impl(tcx: TyCtxt<'_>, drop_impl_did: DefId) -> Result<(), Erro
|
||||
span,
|
||||
&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_ty: Ty<'tcx>,
|
||||
self_type_did: DefId,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
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.
|
||||
@ -109,7 +109,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
|
||||
),
|
||||
)
|
||||
.emit();
|
||||
return Err(ErrorReported);
|
||||
return Err(ErrorGuaranteed);
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
|
||||
if !errors.is_empty() {
|
||||
// this could be reached when we get lazy normalization
|
||||
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
|
||||
@ -146,7 +146,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
|
||||
dtor_predicates: ty::GenericPredicates<'tcx>,
|
||||
self_type_did: LocalDefId,
|
||||
self_to_impl_substs: SubstsRef<'tcx>,
|
||||
) -> Result<(), ErrorReported> {
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let mut result = Ok(());
|
||||
|
||||
// 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")
|
||||
.emit();
|
||||
result = Err(ErrorReported);
|
||||
result = Err(ErrorGuaranteed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ use rustc_ast as ast;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_errors::Diagnostic;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, DiagnosticId};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorKind, DefKind, Res};
|
||||
@ -1188,7 +1188,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
deferred_cast_checks.push(cast_check);
|
||||
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,
|
||||
expr_t: Ty<'tcx>,
|
||||
id: HirId,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
let span = field.span;
|
||||
debug!("no_such_field_err(span: {:?}, field: {:?}, expr_t: {:?})", span, field, expr_t);
|
||||
|
||||
|
@ -8,7 +8,7 @@ use crate::check::{BreakableCtxt, Diverges, Expectation, FnCtxt, LocalTy};
|
||||
|
||||
use rustc_data_structures::captures::Captures;
|
||||
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::def::{CtorOf, DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
@ -158,7 +158,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
pub(in super::super) fn write_resolution(
|
||||
&self,
|
||||
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);
|
||||
}
|
||||
@ -900,7 +900,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
.or_else(|error| {
|
||||
let result = match error {
|
||||
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
|
||||
|
@ -4,7 +4,7 @@
|
||||
use crate::check::FnCtxt;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
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::def_id::{DefId, LocalDefId};
|
||||
@ -93,7 +93,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
source: SelfSource<'tcx>,
|
||||
error: MethodError<'tcx>,
|
||||
args: Option<&'tcx [hir::Expr<'tcx>]>,
|
||||
) -> Option<DiagnosticBuilder<'_, ErrorReported>> {
|
||||
) -> Option<DiagnosticBuilder<'_, ErrorGuaranteed>> {
|
||||
// Avoid suggestions when we don't know what's going on.
|
||||
if rcvr_ty.references_error() {
|
||||
return None;
|
||||
|
@ -3,7 +3,7 @@ use rustc_ast as ast;
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
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::def::{CtorKind, DefKind, Res};
|
||||
@ -100,7 +100,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
|
||||
expected: Ty<'tcx>,
|
||||
actual: Ty<'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)
|
||||
}
|
||||
|
||||
@ -818,7 +818,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
fn emit_bad_pat_path<'b>(
|
||||
&self,
|
||||
mut e: DiagnosticBuilder<'_, ErrorReported>,
|
||||
mut e: DiagnosticBuilder<'_, ErrorGuaranteed>,
|
||||
pat_span: Span,
|
||||
res: Res,
|
||||
pat_res: Res,
|
||||
@ -1369,7 +1369,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
variant: &VariantDef,
|
||||
pat: &'_ Pat<'_>,
|
||||
fields: &[hir::PatField<'_>],
|
||||
) -> Option<DiagnosticBuilder<'_, ErrorReported>> {
|
||||
) -> Option<DiagnosticBuilder<'_, ErrorGuaranteed>> {
|
||||
// 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
|
||||
// be invalid identifiers (for example, Foo { 0, 1 }).
|
||||
@ -1442,7 +1442,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
inexistent_fields: &[Ident],
|
||||
unmentioned_fields: &mut Vec<(&ty::FieldDef, Ident)>,
|
||||
variant: &ty::VariantDef,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let tcx = self.tcx;
|
||||
let (field_names, t, plural) = if inexistent_fields.len() == 1 {
|
||||
(format!("a field named `{}`", inexistent_fields[0]), "this", "")
|
||||
@ -1538,7 +1538,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
pat: &Pat<'_>,
|
||||
fields: &'tcx [hir::PatField<'tcx>],
|
||||
variant: &ty::VariantDef,
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorReported>> {
|
||||
) -> Option<DiagnosticBuilder<'tcx, ErrorGuaranteed>> {
|
||||
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| {
|
||||
s.print_qpath(qpath, false)
|
||||
@ -1620,7 +1620,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
&self,
|
||||
pat: &Pat<'_>,
|
||||
fields: &'tcx [hir::PatField<'tcx>],
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let mut err = self
|
||||
.tcx
|
||||
.sess
|
||||
@ -1712,7 +1712,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
unmentioned_fields: &[(&ty::FieldDef, Ident)],
|
||||
have_inaccessible_fields: bool,
|
||||
fields: &'tcx [hir::PatField<'tcx>],
|
||||
) -> DiagnosticBuilder<'tcx, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let inaccessible = if have_inaccessible_fields { " and inaccessible fields" } else { "" };
|
||||
let field_names = if unmentioned_fields.len() == 1 {
|
||||
format!("field `{}`{}", unmentioned_fields[0].1, inaccessible)
|
||||
|
@ -4,7 +4,7 @@ use crate::constrained_generic_params::{identify_constrained_generic_params, Par
|
||||
|
||||
use rustc_ast as ast;
|
||||
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::def_id::{DefId, LocalDefId};
|
||||
use rustc_hir::intravisit as hir_visit;
|
||||
@ -1764,7 +1764,7 @@ fn report_bivariance(
|
||||
tcx: TyCtxt<'_>,
|
||||
param: &rustc_hir::GenericParam<'_>,
|
||||
has_explicit_bounds: bool,
|
||||
) -> ErrorReported {
|
||||
) -> ErrorGuaranteed {
|
||||
let span = param.span;
|
||||
let param_name = param.name.ident().name;
|
||||
let mut err = error_392(tcx, span, param_name);
|
||||
@ -1977,7 +1977,7 @@ fn error_392(
|
||||
tcx: TyCtxt<'_>,
|
||||
span: Span,
|
||||
param_name: Symbol,
|
||||
) -> DiagnosticBuilder<'_, ErrorReported> {
|
||||
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
let mut err =
|
||||
struct_span_err!(tcx.sess, span, E0392, "parameter `{}` is never used", param_name);
|
||||
err.span_label(span, "unused parameter");
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user