From e489a94deef3d41513fe4254804d730f0fd6cbc0 Mon Sep 17 00:00:00 2001 From: mark Date: Sun, 23 Jan 2022 12:34:26 -0600 Subject: [PATCH] rename ErrorReported -> ErrorGuaranteed --- .../rustc_borrowck/src/borrowck_errors.rs | 58 ++++++++++--------- .../src/diagnostics/bound_region_errors.rs | 20 +++---- .../src/diagnostics/conflict_errors.rs | 18 +++--- .../src/diagnostics/move_errors.rs | 6 +- .../src/diagnostics/region_errors.rs | 8 +-- compiler/rustc_borrowck/src/lib.rs | 22 +++---- .../rustc_codegen_cranelift/src/constant.rs | 4 +- compiler/rustc_codegen_cranelift/src/lib.rs | 6 +- compiler/rustc_codegen_gcc/src/lib.rs | 6 +- compiler/rustc_codegen_llvm/src/lib.rs | 6 +- compiler/rustc_codegen_ssa/src/back/link.rs | 10 ++-- compiler/rustc_codegen_ssa/src/mir/mod.rs | 4 +- .../rustc_codegen_ssa/src/traits/backend.rs | 6 +- .../src/const_eval/machine.rs | 4 +- .../rustc_const_eval/src/interpret/intern.rs | 6 +- .../rustc_const_eval/src/interpret/operand.rs | 4 +- .../src/transform/check_consts/check.rs | 8 +-- .../src/transform/check_consts/ops.rs | 56 +++++++++--------- .../src/transform/check_consts/qualifs.rs | 4 +- compiler/rustc_driver/src/lib.rs | 14 ++--- compiler/rustc_driver/src/pretty.rs | 4 +- .../rustc_errors/src/diagnostic_builder.rs | 18 +++--- compiler/rustc_errors/src/lib.rs | 20 +++---- compiler/rustc_expand/src/base.rs | 14 ++--- compiler/rustc_expand/src/mbe/macro_rules.rs | 2 +- compiler/rustc_expand/src/module.rs | 6 +- compiler/rustc_expand/src/proc_macro.rs | 10 ++-- compiler/rustc_incremental/src/persist/fs.rs | 14 ++--- .../src/infer/error_reporting/mod.rs | 12 ++-- .../infer/error_reporting/need_type_info.rs | 6 +- .../nice_region_error/different_lifetimes.rs | 6 +- .../mismatched_static_lifetime.rs | 6 +- .../error_reporting/nice_region_error/mod.rs | 8 +-- .../nice_region_error/named_anon_conflict.rs | 4 +- .../nice_region_error/placeholder_error.rs | 8 +-- .../nice_region_error/static_impl_trait.rs | 8 +-- .../trait_impl_difference.rs | 8 +-- .../src/infer/error_reporting/note.rs | 6 +- compiler/rustc_infer/src/infer/mod.rs | 10 ++-- .../src/traits/error_reporting/mod.rs | 6 +- compiler/rustc_interface/src/interface.rs | 4 +- compiler/rustc_interface/src/passes.rs | 14 ++--- compiler/rustc_interface/src/queries.rs | 4 +- .../rustc_macros/src/session_diagnostic.rs | 2 +- .../rustc_middle/src/mir/interpret/error.rs | 20 +++---- compiler/rustc_middle/src/mir/mod.rs | 6 +- compiler/rustc_middle/src/mir/query.rs | 6 +- compiler/rustc_middle/src/query/mod.rs | 14 ++--- .../rustc_middle/src/thir/abstract_const.rs | 10 ++-- .../src/traits/specialization_graph.rs | 6 +- compiler/rustc_middle/src/ty/adt.rs | 4 +- compiler/rustc_middle/src/ty/consts.rs | 4 +- compiler/rustc_middle/src/ty/consts/kind.rs | 4 +- compiler/rustc_middle/src/ty/context.rs | 12 ++-- compiler/rustc_middle/src/ty/instance.rs | 8 +-- compiler/rustc_middle/src/ty/query.rs | 2 +- .../rustc_middle/src/ty/structural_impls.rs | 2 +- compiler/rustc_middle/src/ty/trait_def.rs | 4 +- compiler/rustc_middle/src/ty/util.rs | 4 +- compiler/rustc_mir_build/src/build/mod.rs | 4 +- .../src/thir/pattern/check_match.rs | 4 +- compiler/rustc_monomorphize/src/collector.rs | 8 ++- compiler/rustc_parse/src/lexer/mod.rs | 4 +- .../rustc_parse/src/parser/diagnostics.rs | 22 +++---- compiler/rustc_parse/src/parser/expr.rs | 6 +- compiler/rustc_parse/src/parser/item.rs | 4 +- compiler/rustc_parse/src/parser/mod.rs | 8 ++- compiler/rustc_parse/src/parser/pat.rs | 6 +- compiler/rustc_parse/src/parser/stmt.rs | 4 +- .../rustc_query_system/src/query/config.rs | 4 +- compiler/rustc_query_system/src/query/job.rs | 6 +- .../rustc_query_system/src/query/plumbing.rs | 4 +- compiler/rustc_resolve/src/diagnostics.rs | 8 ++- .../rustc_resolve/src/late/diagnostics.rs | 6 +- compiler/rustc_resolve/src/lib.rs | 6 +- compiler/rustc_session/src/parse.rs | 6 +- compiler/rustc_session/src/session.rs | 28 ++++----- .../src/traits/codegen.rs | 8 +-- .../src/traits/const_evaluatable.rs | 32 +++++----- .../src/traits/error_reporting/mod.rs | 12 ++-- .../src/traits/error_reporting/suggestions.rs | 6 +- .../src/traits/fulfill.rs | 16 ++--- .../rustc_trait_selection/src/traits/mod.rs | 10 ++-- .../src/traits/on_unimplemented.rs | 22 +++---- .../src/traits/project.rs | 6 +- .../src/traits/select/mod.rs | 6 +- compiler/rustc_ty_utils/src/instance.rs | 14 ++--- compiler/rustc_typeck/src/astconv/generics.rs | 4 +- compiler/rustc_typeck/src/astconv/mod.rs | 30 +++++----- compiler/rustc_typeck/src/check/cast.rs | 24 ++++---- compiler/rustc_typeck/src/check/check.rs | 8 +-- compiler/rustc_typeck/src/check/coercion.rs | 6 +- .../rustc_typeck/src/check/compare_method.rs | 57 +++++++++--------- compiler/rustc_typeck/src/check/demand.rs | 12 ++-- compiler/rustc_typeck/src/check/dropck.rs | 16 ++--- compiler/rustc_typeck/src/check/expr.rs | 6 +- .../rustc_typeck/src/check/fn_ctxt/_impl.rs | 6 +- .../rustc_typeck/src/check/method/suggest.rs | 4 +- compiler/rustc_typeck/src/check/pat.rs | 16 ++--- compiler/rustc_typeck/src/check/wfcheck.rs | 6 +- compiler/rustc_typeck/src/check/writeback.rs | 10 ++-- compiler/rustc_typeck/src/coherence/orphan.rs | 12 ++-- compiler/rustc_typeck/src/collect.rs | 4 +- compiler/rustc_typeck/src/collect/type_of.rs | 4 +- compiler/rustc_typeck/src/lib.rs | 6 +- .../rustc_typeck/src/structured_errors.rs | 14 ++--- .../missing_cast_for_variadic_arg.rs | 8 +-- .../structured_errors/sized_unsized_cast.rs | 8 +-- .../wrong_number_of_generic_args.rs | 6 +- src/librustdoc/doctest.rs | 10 ++-- src/librustdoc/lib.rs | 10 ++-- .../hotplug_codegen_backend/the_backend.rs | 6 +- 112 files changed, 580 insertions(+), 559 deletions(-) diff --git a/compiler/rustc_borrowck/src/borrowck_errors.rs b/compiler/rustc_borrowck/src/borrowck_errors.rs index e2b6a48a9e867..21b582ef3345b 100644 --- a/compiler/rustc_borrowck/src/borrowck_errors.rs +++ b/compiler/rustc_borrowck/src/borrowck_errors.rs @@ -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, - ) -> 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, - ) -> 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, - ) -> 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, 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, - ) -> 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, - ) -> 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, - ) -> 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, diff --git a/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs index 3ef002bf74027..7507ea76ed07d 100644 --- a/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs @@ -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>, - ) -> Option>; + ) -> Option>; 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>, - ) -> Option> { + ) -> Option> { 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>, - ) -> Option> { + ) -> Option> { 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>, - ) -> Option> { + ) -> Option> { 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>, -) -> Option> { +) -> Option> { let tcx = infcx.tcx; // We generally shouldn't have errors here because the query was diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index eb906d5fde7b4..4502d15f36fa1 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -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> { + ) -> Option> { 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()); diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index 66f4c28a36d66..19091569b4d27 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -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>, - ) -> 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. diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index 369aef6798ba6..38b16fedd3a49 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -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, diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 82d2d0dd4557f..7502a3e39a191 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -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, (PlaceRef<'tcx>, DiagnosticBuilder<'tcx, ErrorReported>)>, + BTreeMap, (PlaceRef<'tcx>, DiagnosticBuilder<'tcx, ErrorGuaranteed>)>, /// Diagnostics to be reported buffer. buffered: Vec, /// Set to Some if we emit an error during borrowck - tainted_by_errors: Option, + tainted_by_errors: Option, } 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, - 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 { + pub fn emit_errors(&mut self) -> Option { // 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) } } diff --git a/compiler/rustc_codegen_cranelift/src/constant.rs b/compiler/rustc_codegen_cranelift/src/constant.rs index 274fb211b7bbb..66adc1a2ce96d 100644 --- a/compiler/rustc_codegen_cranelift/src/constant.rs +++ b/compiler/rustc_codegen_cranelift/src/constant.rs @@ -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 => { diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs index cb18f42f741d8..331e3e8f5dfc3 100644 --- a/compiler/rustc_codegen_cranelift/src/lib.rs +++ b/compiler/rustc_codegen_cranelift/src/lib.rs @@ -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, _sess: &Session, _outputs: &OutputFilenames, - ) -> Result<(CodegenResults, FxHashMap), ErrorReported> { + ) -> Result<(CodegenResults, FxHashMap), ErrorGuaranteed> { Ok(*ongoing_codegen .downcast::<(CodegenResults, FxHashMap)>() .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::>(sess, &codegen_results, outputs) diff --git a/compiler/rustc_codegen_gcc/src/lib.rs b/compiler/rustc_codegen_gcc/src/lib.rs index 20b9b659f1504..ef95dfb6e2e00 100644 --- a/compiler/rustc_codegen_gcc/src/lib.rs +++ b/compiler/rustc_codegen_gcc/src/lib.rs @@ -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, sess: &Session, _outputs: &OutputFilenames) -> Result<(CodegenResults, FxHashMap), ErrorReported> { + fn join_codegen(&self, ongoing_codegen: Box, sess: &Session, _outputs: &OutputFilenames) -> Result<(CodegenResults, FxHashMap), ErrorGuaranteed> { let (codegen_results, work_products) = ongoing_codegen .downcast::>() .expect("Expected GccCodegenBackend's OngoingCodegen, found Box") @@ -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::>( diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index 09c2c4ec7712a..875b4f033d19f 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -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, sess: &Session, outputs: &OutputFilenames, - ) -> Result<(CodegenResults, FxHashMap), ErrorReported> { + ) -> Result<(CodegenResults, FxHashMap), ErrorGuaranteed> { let (codegen_results, work_products) = ongoing_codegen .downcast::>() .expect("Expected LlvmCodegenBackend's OngoingCodegen, found Box") @@ -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; diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index b36645ad37b93..9e252c0d9b7d5 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -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 { +) -> Result { 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)>, ErrorReported> { +) -> Result)>, ErrorGuaranteed> { // Use index maps to preserve original order of imports and libraries. let mut dylib_table = FxIndexMap::>::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::(sess, codegen_results, RlibFlavor::StaticlibBase, out_filename, tempdir)?; let mut all_native_libs = vec![]; diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs index adb856ef42e2f..40a8e2388e26b 100644 --- a/compiler/rustc_codegen_ssa/src/mir/mod.rs +++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs @@ -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) } diff --git a/compiler/rustc_codegen_ssa/src/traits/backend.rs b/compiler/rustc_codegen_ssa/src/traits/backend.rs index a71eadd3d75fc..856b774258316 100644 --- a/compiler/rustc_codegen_ssa/src/traits/backend.rs +++ b/compiler/rustc_codegen_ssa/src/traits/backend.rs @@ -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, sess: &Session, outputs: &OutputFilenames, - ) -> Result<(CodegenResults, FxHashMap), ErrorReported>; + ) -> Result<(CodegenResults, FxHashMap), ErrorGuaranteed>; /// This is called on the returned `Box` 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 { diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 99888992bc86a..ac25cfd057c17 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -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)) diff --git a/compiler/rustc_const_eval/src/interpret/intern.rs b/compiler/rustc_const_eval/src/interpret/intern.rs index b1f50bc56c908..2096addb9f786 100644 --- a/compiler/rustc_const_eval/src/interpret/intern.rs +++ b/compiler/rustc_const_eval/src/interpret/intern.rs @@ -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. diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index 9b317e8e0abfb..716c01ba78ceb 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -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()) diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index 652f1c94a6149..b78924490cae8 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -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, + tainted_by_errors: Option, ) -> 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>, - error_emitted: Option, + error_emitted: Option, secondary_errors: Vec, } @@ -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(); } diff --git a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs index 5738b38d443a0..f6b92df92c044 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/ops.rs @@ -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, diff --git a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs index 639b798be5431..6421ba9df0f16 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs @@ -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, + tainted_by_errors: Option, ) -> ConstQualifs { ConstQualifs { has_mut_interior: HasMutInterior::in_any_value_of_ty(cx, ty), diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index db03ee8c4bc94..b36ce63dda756 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -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(result: Result, sess: &Session) -> T { +pub fn abort_on_err(result: Result, 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, Option) fn make_input( error_format: ErrorOutputType, free_matches: &[String], -) -> Result)>, ErrorReported> { +) -> Result)>, 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, 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 R, R>(f: F) -> Result { +pub fn catch_fatal_errors R, R>(f: F) -> Result { catch_unwind(panic::AssertUnwindSafe(f)).map_err(|value| { if value.is::() { - ErrorReported + ErrorGuaranteed } else { panic::resume_unwind(value); } diff --git a/compiler/rustc_driver/src/pretty.rs b/compiler/rustc_driver/src/pretty.rs index 2e9050dd672e1..0c0c61309655c 100644 --- a/compiler/rustc_driver/src/pretty.rs +++ b/compiler/rustc_driver/src/pretty.rs @@ -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 => { diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs index 49305d2268417..5dc71f1620096 100644 --- a/compiler/rustc_errors/src/diagnostic_builder.rs +++ b/compiler/rustc_errors/src/diagnostic_builder.rs @@ -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(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`", + from `DiagnosticBuilder`", 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`'s diagnostic \ + "`DiagnosticBuilder`'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` impl as well? +// FIXME(eddyb) should there be a `Option` impl as well? impl EmissionGuarantee for () { fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self { match db.inner.state { diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index fdfedffc52985..e45a57b26587a 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -54,7 +54,7 @@ mod snippet; mod styled_buffer; pub use snippet::Style; -pub type PResult<'a, T> = Result>; +pub type PResult<'a, T> = Result>; // `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, 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, 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, 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, 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); diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 4e951ad9d4b6d..1df48b7fe1520 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -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; + ) -> Result; } impl ProcMacro for F @@ -287,7 +287,7 @@ where _ecx: &'cx mut ExtCtxt<'_>, _span: Span, ts: TokenStream, - ) -> Result { + ) -> Result { // 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; + ) -> Result; } impl AttrProcMacro for F @@ -313,7 +313,7 @@ where _span: Span, annotation: TokenStream, annotated: TokenStream, - ) -> Result { + ) -> Result { // 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, 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(); diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index 4af7d2b7ec6fd..62ea3aa76a46c 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -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, diff --git a/compiler/rustc_expand/src/module.rs b/compiler/rustc_expand/src/module.rs index 1ce3766579bd9..a6e1232628f93 100644 --- a/compiler/rustc_expand/src/module.rs +++ b/compiler/rustc_expand/src/module.rs @@ -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), 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) => { diff --git a/compiler/rustc_expand/src/proc_macro.rs b/compiler/rustc_expand/src/proc_macro.rs index 42c17a60a5d4e..aefbec0e518fa 100644 --- a/compiler/rustc_expand/src/proc_macro.rs +++ b/compiler/rustc_expand/src/proc_macro.rs @@ -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 { + ) -> Result { 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 { + ) -> Result { 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 }) } } diff --git a/compiler/rustc_incremental/src/persist/fs.rs b/compiler/rustc_incremental/src/persist/fs.rs index a6da4b0bab683..ed7ec51d6298b 100644 --- a/compiler/rustc_incremental/src/persist/fs.rs +++ b/compiler/rustc_incremental/src/persist/fs.rs @@ -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) } } } diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 317481a037de6..edb2b11c0397c 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -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>, 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(), diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs index 067f19bbe9426..8ff0eed71ed03 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs @@ -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>, 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); diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs index d7e88d02595e4..0d6dbd8f34398 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs @@ -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 { + pub(super) fn try_report_anon_anon_conflict(&self) -> Option { 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( diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs index 2bc2f78261df3..e0420291aa3f5 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs @@ -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 { + pub(super) fn try_report_mismatched_static_lifetime(&self) -> Option { 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) } } diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mod.rs index a8b878ae344a2..c7bfa686c04dc 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mod.rs @@ -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> { + pub fn try_report_from_nll(&self) -> Option> { // 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 { + pub fn try_report(&self) -> Option { 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()) diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs index 825aadaad9a0c..3de5273d8c78c 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs @@ -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> { + ) -> Option> { let (span, sub, sup) = self.regions()?; debug!( diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs index 5ce5d44e51d15..e2185d8613379 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_error.rs @@ -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> { + ) -> Option> { match &self.error { /////////////////////////////////////////////////////////////////////////// // NB. The ordering of cases in this match is very @@ -155,7 +155,7 @@ impl<'tcx> NiceRegionError<'_, 'tcx> { sub_placeholder: Option>, sup_placeholder: Option>, value_pairs: &ValuePairs<'tcx>, - ) -> Option> { + ) -> Option> { 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", diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs index 210743d7cef7e..a6de0c3d9fb5c 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -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 { + pub(super) fn try_report_static_impl_trait(&self) -> Option { 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) } } diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs index 9216fa3ca1d31..673c112163e1b 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs @@ -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 { + pub(super) fn try_report_impl_not_conforming_to_trait(&self) -> Option { 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 diff --git a/compiler/rustc_infer/src/infer/error_reporting/note.rs b/compiler/rustc_infer/src/infer/error_reporting/note.rs index 5dc8c89460856..e6c8dc302b6ca 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/note.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/note.rs @@ -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 { diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 95608f413d538..5697e73f73a70 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -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) } diff --git a/compiler/rustc_infer/src/traits/error_reporting/mod.rs b/compiler/rustc_infer/src/traits/error_reporting/mod.rs index 35430849290e7..5e93c002168c6 100644 --- a/compiler/rustc_infer/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/traits/error_reporting/mod.rs @@ -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), diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 2083526232423..7f4a4ffadec14 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -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 = result::Result; +pub type Result = result::Result; /// Represents a compiler session. /// diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index c0552fd200be8..2cdcf0b11d151 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -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", || { diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index 4af69f7cd2ee6..d0e533b457159 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -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 }) }) } diff --git a/compiler/rustc_macros/src/session_diagnostic.rs b/compiler/rustc_macros/src/session_diagnostic.rs index f29683e5e1d23..c9e404903f500 100644 --- a/compiler/rustc_macros/src/session_diagnostic.rs +++ b/compiler/rustc_macros/src/session_diagnostic.rs @@ -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 } } diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs index 31468ce73bfc5..98cb90296a521 100644 --- a/compiler/rustc_middle/src/mir/interpret/error.rs +++ b/compiler/rustc_middle/src/mir/interpret/error.rs @@ -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 for ErrorHandled { - fn from(err: ErrorReported) -> ErrorHandled { +impl From for ErrorHandled { + fn from(err: ErrorGuaranteed) -> ErrorHandled { ErrorHandled::Reported(err) } } @@ -39,7 +39,7 @@ pub type EvalToConstValueResult<'tcx> = Result, 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 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 for InterpErrorInfo<'_> { } } -impl From for InterpErrorInfo<'_> { - fn from(err: ErrorReported) -> Self { +impl From 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), diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 9a36230516c17..ce3d6f348d194 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -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, + pub tainted_by_errors: Option, } impl<'tcx> Body<'tcx> { @@ -300,7 +300,7 @@ impl<'tcx> Body<'tcx> { var_debug_info: Vec>, span: Span, generator_kind: Option, - tainted_by_errors: Option, + tainted_by_errors: Option, ) -> Self { // We need `arg_count` locals, and one for the return place. assert!( diff --git a/compiler/rustc_middle/src/mir/query.rs b/compiler/rustc_middle/src/mir/query.rs index 433f69e8da46c..c237ba5c4ba20 100644 --- a/compiler/rustc_middle/src/mir/query.rs +++ b/compiler/rustc_middle/src/mir/query.rs @@ -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, Ty<'tcx>>, pub closure_requirements: Option>, pub used_mut_upvars: SmallVec<[Field; 8]>, - pub tainted_by_errors: Option, + pub tainted_by_errors: Option, } /// 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, + pub tainted_by_errors: Option, } /// After we borrow check a closure, we are left with various diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 1dc01e122520c..6b572690e2113 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -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]>, ErrorReported> { + ) -> Result]>, 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]>, ErrorReported> { + ) -> Result]>, 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>, ErrorReported> { + ) -> Result>, 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>, ErrorReported> { + ) -> Result>, ErrorGuaranteed> { desc { "resolving instance of the const argument `{}`", ty::Instance::new(key.value.0.to_def_id(), key.value.2), diff --git a/compiler/rustc_middle/src/thir/abstract_const.rs b/compiler/rustc_middle/src/thir/abstract_const.rs index e3d004ed133e1..e02ed414574b4 100644 --- a/compiler/rustc_middle/src/thir/abstract_const.rs +++ b/compiler/rustc_middle/src/thir/abstract_const.rs @@ -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 for NotConstEvaluatable { - fn from(e: ErrorReported) -> NotConstEvaluatable { +impl From 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, - ) -> Result]>, ErrorReported> { + ) -> Result]>, ErrorGuaranteed> { if let Some((did, param_did)) = def.as_const_arg() { self.thir_abstract_const_of_const_arg((did, param_did)) } else { diff --git a/compiler/rustc_middle/src/traits/specialization_graph.rs b/compiler/rustc_middle/src/traits/specialization_graph.rs index 03a6daaf8aa4f..4ff8e61ee7437 100644 --- a/compiler/rustc_middle/src/traits/specialization_graph.rs +++ b/compiler/rustc_middle/src/traits/specialization_graph.rs @@ -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, ErrorReported> { +) -> Result, 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, diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index 40fbea7c3d91f..d5a8f5863616c 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -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", diff --git a/compiler/rustc_middle/src/ty/consts.rs b/compiler/rustc_middle/src/ty/consts.rs index b753c6238e147..e72828dd52959 100644 --- a/compiler/rustc_middle/src/ty/consts.rs +++ b/compiler/rustc_middle/src/ty/consts.rs @@ -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 diff --git a/compiler/rustc_middle/src/ty/consts/kind.rs b/compiler/rustc_middle/src/ty/consts/kind.rs index af7c2c5cb4cff..b8da35abd4703 100644 --- a/compiler/rustc_middle/src/ty/consts/kind.rs +++ b/compiler/rustc_middle/src/ty/consts/kind.rs @@ -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, ErrorReported>> { + ) -> Option, ErrorGuaranteed>> { if let ConstKind::Unevaluated(unevaluated) = self { use crate::mir::interpret::ErrorHandled; diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index f9435682e5394..d32276364e0f9 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -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 `::X` associated paths and /// method calls, including those of overloaded operators. - type_dependent_defs: ItemLocalMap>, + type_dependent_defs: ItemLocalMap>, /// 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>, /// If any errors occurred while type-checking this body, - /// this field will be set to `Some(ErrorReported)`. - pub tainted_by_errors: Option, + /// this field will be set to `Some(ErrorGuaranteed)`. + pub tainted_by_errors: Option, /// 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 } } diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index 1cf651be87a8a..00b3639a99776 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -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>, ErrorReported> { + ) -> Result>, 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, substs: SubstsRef<'tcx>, - ) -> Result>, ErrorReported> { + ) -> Result>, ErrorGuaranteed> { // All regions in the result of this query are erased, so it's // fine to erase all of the input regions. diff --git a/compiler/rustc_middle/src/ty/query.rs b/compiler/rustc_middle/src/ty/query.rs index f2e1d129e9ba7..03e4a7dcefd71 100644 --- a/compiler/rustc_middle/src/ty/query.rs +++ b/compiler/rustc_middle/src/ty/query.rs @@ -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}; diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index f5bdcafe780b2..2d51462221c07 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -260,7 +260,7 @@ TrivialTypeFoldableAndLiftImpls! { crate::ty::UniverseIndex, crate::ty::Variance, ::rustc_span::Span, - ::rustc_errors::ErrorReported, + ::rustc_errors::ErrorGuaranteed, } /////////////////////////////////////////////////////////////////////////// diff --git a/compiler/rustc_middle/src/ty/trait_def.rs b/compiler/rustc_middle/src/ty/trait_def.rs index 8f4cc182e7f4e..6100eb48a1863 100644 --- a/compiler/rustc_middle/src/ty/trait_def.rs +++ b/compiler/rustc_middle/src/ty/trait_def.rs @@ -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, ErrorReported> { + ) -> Result, ErrorGuaranteed> { specialization_graph::ancestors(tcx, self.def_id, of_impl) } } diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index c13aecd1b14aa..04e766d16cc49 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -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 { let drop_trait = self.lang_items().drop_trait()?; self.ensure().coherent_trait(drop_trait); diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index 393e67f21bfe2..e12d075efa9b6 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -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); diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index c6026a6ab4b96..27a6b5beb627c 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -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) } diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 2f88c45a2a389..819cffd3a9bf1 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -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: {}", diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 3212fc39fb9c2..601a39e69ab9d 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -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))) diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index c92785bd9afeb..c7aa9ffc7937d 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -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, 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, ) -> 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( diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index a54ab4a92e1b8..df865d77b9bb4 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -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>, + err: Option>, binop_span: Option, - ) -> 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 { diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index af5cc0e094868..ae46bfe354083 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -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() { diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 9d85be93b1dd7..4e229918b6362 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -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> { +) -> Option> { // `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?; diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index ff536d15cbfca..67bbbf249369d 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -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> { 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> = None; + let mut delayed_err: Option> = None; let mut etc_span = None; while self.token != token::CloseDelim(token::Brace) { diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index e39e32ff364fa..e3bcd945db716 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -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; diff --git a/compiler/rustc_query_system/src/query/config.rs b/compiler/rustc_query_system/src/query/config.rs index 9e30d0c644009..7ca668f8a1f06 100644 --- a/compiler/rustc_query_system/src/query/config.rs +++ b/compiler/rustc_query_system/src/query/config.rs @@ -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 { pub compute: fn(CTX::DepContext, K) -> V, pub hash_result: Option, &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 Option>, } diff --git a/compiler/rustc_query_system/src/query/job.rs b/compiler/rustc_query_system/src/query/job.rs index 260fc3bff4471..2a07d9b7f809c 100644 --- a/compiler/rustc_query_system/src/query/job.rs +++ b/compiler/rustc_query_system/src/query/job.rs @@ -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(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| { diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index 8781912fe5978..bd4e1ddd25c46 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -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( 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, ) -> R where diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index b366473cb30c0..e88b6a57376c3 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -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( diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 0ead6708f9a7a..9e38428660e2a 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -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, - ) -> (DiagnosticBuilder<'a, ErrorReported>, Vec) { + ) -> (DiagnosticBuilder<'a, ErrorGuaranteed>, Vec) { 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, count: usize, - ) -> DiagnosticBuilder<'tcx, ErrorReported> { + ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { struct_span_err!( self.tcx.sess, spans, diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 0c386ebc49eaa..086f0249114ba 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -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, /// The `DefId` of the module to place the use-statements in. diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index e287764a52abc..38ddb841d9656 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -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, 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, 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) { diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index b72be735ce485..360682558a5ef 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -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>( @@ -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>( &self, sp: S, msg: &str, - ) -> DiagnosticBuilder<'_, ErrorReported> { + ) -> DiagnosticBuilder<'_, ErrorGuaranteed> { self.diagnostic().struct_span_fatal(sp, msg) } pub fn struct_span_fatal_with_code>( @@ -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(&self, f: F) -> Result + pub fn track_errors(&self, f: F) -> Result 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>(&self, sp: S, msg: &str) { self.diagnostic().span_warn(sp, msg) diff --git a/compiler/rustc_trait_selection/src/traits/codegen.rs b/compiler/rustc_trait_selection/src/traits/codegen.rs index bf6e6a4fcbb9d..3e0c8234edafb 100644 --- a/compiler/rustc_trait_selection/src/traits/codegen.rs +++ b/compiler/rustc_trait_selection/src/traits/codegen.rs @@ -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) diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs index 1994faed70c66..6655541461d01 100644 --- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs +++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs @@ -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>, ErrorReported> { + ) -> Result>, 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>, ErrorReported> { + ) -> Result>, 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 { + fn error(&mut self, span: Span, msg: &str) -> Result { 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 { + fn maybe_supported_error(&mut self, span: Span, msg: &str) -> Result { 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>, ErrorReported> { + ) -> Result>, 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 { + fn recurse_build(&mut self, node: thir::ExprId) -> Result { 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, -) -> Result]>, ErrorReported> { +) -> Result]>, 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>( diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 8e42a41c8cf61..ccbd2dedfeab1 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -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, found_args: Vec, 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, found_args: Vec, is_closure: bool, - ) -> DiagnosticBuilder<'tcx, ErrorReported> { + ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { let kind = if is_closure { "closure" } else { "function" }; let args_str = |arguments: &[ArgKind], other: &[ArgKind]| { diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 7af2ba8b30f87..b194e6a6d89f3 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -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, 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, 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>, diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index 362d669f867e0..b4b2e4cd04229 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -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()), diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 3e095dceb21e1..bf94c61e6c2ce 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -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>, -) -> Result>, ErrorReported> { +) -> Result>, 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) } diff --git a/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs index 7fbdd3689a7eb..9752ff453235a 100644 --- a/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/on_unimplemented.rs @@ -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 { + ) -> Result { 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, ErrorReported> { + ) -> Result, 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 { + ) -> Result { 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); } }, } diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index b4ca1cad1efe2..c32c73c638412 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -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 { +) -> Result { 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); diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index f3c7642f7a318..24a7c2169a36f 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -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()), diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index 91c4398c178ca..41467ce2f622f 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -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>, ErrorReported> { +) -> Result>, 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>, ErrorReported> { +) -> Result>, 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, SubstsRef<'tcx>)>, -) -> Result>, ErrorReported> { +) -> Result>, 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>, ErrorReported> { +) -> Result>, 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); } } diff --git a/compiler/rustc_typeck/src/astconv/generics.rs b/compiler/rustc_typeck/src/astconv/generics.rs index a06b37627e3ca..e8b64587eeea6 100644 --- a/compiler/rustc_typeck/src/astconv/generics.rs +++ b/compiler/rustc_typeck/src/astconv/generics.rs @@ -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 }) }, } } diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index 14a6e686a6424..d409cedddda8d 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -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, + pub reported: Option, /// A list of spans of arguments provided that were not valid. pub invalid_args: Vec, } @@ -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, path_span: Span, - ) -> Result<(), ErrorReported> { + ) -> Result<(), ErrorGuaranteed> { // Given something like `U: SomeTrait`, we want to produce a // predicate like `::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, ErrorReported> { + ) -> Result, 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, - ) -> Result, ErrorReported> + ) -> Result, ErrorGuaranteed> where I: Iterator>, { @@ -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, referenced_regions: FxHashSet, - 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 { diff --git a/compiler/rustc_typeck/src/check/cast.rs b/compiler/rustc_typeck/src/check/cast.rs index cd24969bf283b..3d0f76f7a93eb 100644 --- a/compiler/rustc_typeck/src/check/cast.rs +++ b/compiler/rustc_typeck/src/check/cast.rs @@ -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>, ErrorReported> { + ) -> Result>, 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 for CastError { - fn from(ErrorReported: ErrorReported) -> Self { - CastError::ErrorReported +impl From 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, ErrorReported> { + ) -> Result, 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 => { diff --git a/compiler/rustc_typeck/src/check/check.rs b/compiler/rustc_typeck/src/check/check.rs index 100d2d07a5c9f..765b752691f23 100644 --- a/compiler/rustc_typeck/src/check/check.rs +++ b/compiler/rustc_typeck/src/check/check.rs @@ -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, diff --git a/compiler/rustc_typeck/src/check/coercion.rs b/compiler/rustc_typeck/src/check/coercion.rs index c6b14d3e10458..c0eda02a99967 100644 --- a/compiler/rustc_typeck/src/check/coercion.rs +++ b/compiler/rustc_typeck/src/check/coercion.rs @@ -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; diff --git a/compiler/rustc_typeck/src/check/compare_method.rs b/compiler/rustc_typeck/src/check/compare_method.rs index 38449c2a76a5b..d4a473adaf010 100644 --- a/compiler/rustc_typeck/src/check/compare_method.rs +++ b/compiler/rustc_typeck/src/check/compare_method.rs @@ -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, -) -> 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, -) -> 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, -) -> 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 Foo 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 diff --git a/compiler/rustc_typeck/src/check/demand.rs b/compiler/rustc_typeck/src/check/demand.rs index 3b644099ecf04..040a087b2352e 100644 --- a/compiler/rustc_typeck/src/check/demand.rs +++ b/compiler/rustc_typeck/src/check/demand.rs @@ -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> { + ) -> Option> { 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> { + ) -> Option> { 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> { + ) -> Option> { 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> { + ) -> Option> { 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>) { + ) -> (Ty<'tcx>, Option>) { let expected = self.resolve_vars_with_obligations(expected); let e = match self.try_coerce(expr, checked_ty, expected, allow_two_phase, None) { diff --git a/compiler/rustc_typeck/src/check/dropck.rs b/compiler/rustc_typeck/src/check/dropck.rs index 22d2022902f01..26aade16fd4b0 100644 --- a/compiler/rustc_typeck/src/check/dropck.rs +++ b/compiler/rustc_typeck/src/check/dropck.rs @@ -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; impl Drop for S { ... }`). /// -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); } } diff --git a/compiler/rustc_typeck/src/check/expr.rs b/compiler/rustc_typeck/src/check/expr.rs index a8c9c699ceb54..8e245beaa3db0 100644 --- a/compiler/rustc_typeck/src/check/expr.rs +++ b/compiler/rustc_typeck/src/check/expr.rs @@ -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); diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs index 2c81745836cdb..fed3aac6da3fd 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs @@ -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 diff --git a/compiler/rustc_typeck/src/check/method/suggest.rs b/compiler/rustc_typeck/src/check/method/suggest.rs index 32de5d23c1ea7..1a345a303caea 100644 --- a/compiler/rustc_typeck/src/check/method/suggest.rs +++ b/compiler/rustc_typeck/src/check/method/suggest.rs @@ -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> { + ) -> Option> { // Avoid suggestions when we don't know what's going on. if rcvr_ty.references_error() { return None; diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs index 9963a922268a4..8a369797210af 100644 --- a/compiler/rustc_typeck/src/check/pat.rs +++ b/compiler/rustc_typeck/src/check/pat.rs @@ -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> { + ) -> Option> { 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> { + ) -> Option> { // 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> { + ) -> Option> { 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) diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index a42ed9eab6436..8672bf654669a 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -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"); diff --git a/compiler/rustc_typeck/src/check/writeback.rs b/compiler/rustc_typeck/src/check/writeback.rs index 3843e7e54bec4..62f7c382bc90c 100644 --- a/compiler/rustc_typeck/src/check/writeback.rs +++ b/compiler/rustc_typeck/src/check/writeback.rs @@ -5,7 +5,7 @@ use crate::check::FnCtxt; use rustc_data_structures::stable_map::FxHashMap; -use rustc_errors::ErrorReported; +use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::intravisit::{self, Visitor}; @@ -80,8 +80,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { mem::take(&mut self.typeck_results.borrow_mut().treat_byte_string_as_slice); if self.is_tainted_by_errors() { - // FIXME(eddyb) keep track of `ErrorReported` from where the error was emitted. - wbcx.typeck_results.tainted_by_errors = Some(ErrorReported); + // FIXME(eddyb) keep track of `ErrorGuaranteed` from where the error was emitted. + wbcx.typeck_results.tainted_by_errors = Some(ErrorGuaranteed); } debug!("writeback: typeck results for {:?} are {:#?}", item_def_id, wbcx.typeck_results); @@ -661,8 +661,8 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { // to mark the `TypeckResults` as tainted in that case, so that downstream // users of the typeck results don't produce extra errors, or worse, ICEs. if resolver.replaced_with_error { - // FIXME(eddyb) keep track of `ErrorReported` from where the error was emitted. - self.typeck_results.tainted_by_errors = Some(ErrorReported); + // FIXME(eddyb) keep track of `ErrorGuaranteed` from where the error was emitted. + self.typeck_results.tainted_by_errors = Some(ErrorGuaranteed); } x diff --git a/compiler/rustc_typeck/src/coherence/orphan.rs b/compiler/rustc_typeck/src/coherence/orphan.rs index 6c9059cfdd44a..8ed47226d5f59 100644 --- a/compiler/rustc_typeck/src/coherence/orphan.rs +++ b/compiler/rustc_typeck/src/coherence/orphan.rs @@ -3,7 +3,7 @@ use rustc_data_structures::fx::FxHashSet; use rustc_errors::struct_span_err; -use rustc_errors::ErrorReported; +use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; use rustc_index::bit_set::GrowableBitSet; use rustc_infer::infer::TyCtxtInferExt; @@ -21,7 +21,7 @@ pub(super) fn orphan_check_crate(tcx: TyCtxt<'_>, (): ()) -> &[LocalDefId] { for &impl_of_trait in impls_of_trait { match orphan_check_impl(tcx, impl_of_trait) { Ok(()) => {} - Err(ErrorReported) => errors.push(impl_of_trait), + Err(ErrorGuaranteed) => errors.push(impl_of_trait), } } @@ -33,7 +33,7 @@ pub(super) fn orphan_check_crate(tcx: TyCtxt<'_>, (): ()) -> &[LocalDefId] { } #[instrument(skip(tcx), level = "debug")] -fn orphan_check_impl(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), ErrorReported> { +fn orphan_check_impl(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), ErrorGuaranteed> { let trait_ref = tcx.impl_trait_ref(def_id).unwrap(); let trait_def_id = trait_ref.def_id; @@ -136,7 +136,7 @@ fn orphan_check_impl(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), ErrorRep if let Some((msg, label)) = msg { struct_span_err!(tcx.sess, sp, E0321, "{}", msg).span_label(sp, label).emit(); - return Err(ErrorReported); + return Err(ErrorGuaranteed); } } @@ -145,7 +145,7 @@ fn orphan_check_impl(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), ErrorRep .struct_span_err(sp, "cannot implement trait on type alias impl trait") .span_note(tcx.def_span(def_id), "type alias impl trait defined here") .emit(); - return Err(ErrorReported); + return Err(ErrorGuaranteed); } Ok(()) @@ -158,7 +158,7 @@ fn emit_orphan_check_error<'tcx>( self_ty_span: Span, generics: &hir::Generics<'tcx>, err: traits::OrphanCheckErr<'tcx>, -) -> Result { +) -> Result { Err(match err { traits::OrphanCheckErr::NonLocalInputType(tys) => { let mut err = struct_span_err!( diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index 88e3e67c99ee3..8229f4a80e10c 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -26,7 +26,7 @@ use rustc_ast::{MetaItemKind, NestedMetaItem}; use rustc_attr::{list_contains_name, InlineAttr, InstructionSetAttr, OptimizeAttr}; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; -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::{CtorKind, DefKind}; use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID, LOCAL_CRATE}; @@ -319,7 +319,7 @@ fn bad_placeholder<'tcx>( tcx: TyCtxt<'tcx>, mut spans: Vec, kind: &'static str, -) -> DiagnosticBuilder<'tcx, ErrorReported> { +) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { let kind = if kind.ends_with('s') { format!("{}es", kind) } else { format!("{}s", kind) }; spans.sort(); diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index 39da7c82c4eec..2867574e6562e 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -1,4 +1,4 @@ -use rustc_errors::{Applicability, ErrorReported, StashKey}; +use rustc_errors::{Applicability, ErrorGuaranteed, StashKey}; use rustc_hir as hir; use rustc_hir::def::Res; use rustc_hir::def_id::{DefId, LocalDefId}; @@ -366,7 +366,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> { owner, def_id, ), ); - if let Some(ErrorReported) = + if let Some(ErrorGuaranteed) = tcx.typeck(owner).tainted_by_errors { // Some error in the diff --git a/compiler/rustc_typeck/src/lib.rs b/compiler/rustc_typeck/src/lib.rs index de030c5b60bcc..d665b6d068e06 100644 --- a/compiler/rustc_typeck/src/lib.rs +++ b/compiler/rustc_typeck/src/lib.rs @@ -97,7 +97,7 @@ mod outlives; mod structured_errors; mod variance; -use rustc_errors::{struct_span_err, ErrorReported}; +use rustc_errors::{struct_span_err, ErrorGuaranteed}; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::{Node, CRATE_HIR_ID}; @@ -491,7 +491,7 @@ pub fn provide(providers: &mut Providers) { hir_wf_check::provide(providers); } -pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorReported> { +pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> { let _prof_timer = tcx.sess.timer("type_check_crate"); // this ensures that later parts of type checking can assume that items @@ -537,7 +537,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorReported> { check_unused::check_crate(tcx); check_for_entry_fn(tcx); - if tcx.sess.err_count() == 0 { Ok(()) } else { Err(ErrorReported) } + if tcx.sess.err_count() == 0 { Ok(()) } else { Err(ErrorGuaranteed) } } /// A quasi-deprecated helper used in rustdoc and clippy to get diff --git a/compiler/rustc_typeck/src/structured_errors.rs b/compiler/rustc_typeck/src/structured_errors.rs index 8621375fc63e0..0b46fce173549 100644 --- a/compiler/rustc_typeck/src/structured_errors.rs +++ b/compiler/rustc_typeck/src/structured_errors.rs @@ -6,7 +6,7 @@ pub use self::{ missing_cast_for_variadic_arg::*, sized_unsized_cast::*, wrong_number_of_generic_args::*, }; -use rustc_errors::{DiagnosticBuilder, DiagnosticId, ErrorReported}; +use rustc_errors::{DiagnosticBuilder, DiagnosticId, ErrorGuaranteed}; use rustc_session::Session; pub trait StructuredDiagnostic<'tcx> { @@ -14,7 +14,7 @@ pub trait StructuredDiagnostic<'tcx> { fn code(&self) -> DiagnosticId; - fn diagnostic(&self) -> DiagnosticBuilder<'tcx, ErrorReported> { + fn diagnostic(&self) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { let err = self.diagnostic_common(); if self.session().teach(&self.code()) { @@ -24,19 +24,19 @@ pub trait StructuredDiagnostic<'tcx> { } } - fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx, ErrorReported>; + fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>; fn diagnostic_regular( &self, - err: DiagnosticBuilder<'tcx, ErrorReported>, - ) -> DiagnosticBuilder<'tcx, ErrorReported> { + err: DiagnosticBuilder<'tcx, ErrorGuaranteed>, + ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { err } fn diagnostic_extended( &self, - err: DiagnosticBuilder<'tcx, ErrorReported>, - ) -> DiagnosticBuilder<'tcx, ErrorReported> { + err: DiagnosticBuilder<'tcx, ErrorGuaranteed>, + ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { err } } diff --git a/compiler/rustc_typeck/src/structured_errors/missing_cast_for_variadic_arg.rs b/compiler/rustc_typeck/src/structured_errors/missing_cast_for_variadic_arg.rs index 2dc9f26004cf8..79965c1dc2875 100644 --- a/compiler/rustc_typeck/src/structured_errors/missing_cast_for_variadic_arg.rs +++ b/compiler/rustc_typeck/src/structured_errors/missing_cast_for_variadic_arg.rs @@ -1,5 +1,5 @@ use crate::structured_errors::StructuredDiagnostic; -use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticId, ErrorReported}; +use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticId, ErrorGuaranteed}; use rustc_middle::ty::{Ty, TypeFoldable}; use rustc_session::Session; use rustc_span::Span; @@ -20,7 +20,7 @@ impl<'tcx> StructuredDiagnostic<'tcx> for MissingCastForVariadicArg<'tcx> { rustc_errors::error_code!(E0617) } - fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx, ErrorReported> { + fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { let mut err = self.sess.struct_span_fatal_with_code( self.span, &format!("can't pass `{}` to variadic function", self.ty), @@ -47,8 +47,8 @@ impl<'tcx> StructuredDiagnostic<'tcx> for MissingCastForVariadicArg<'tcx> { fn diagnostic_extended( &self, - mut err: DiagnosticBuilder<'tcx, ErrorReported>, - ) -> DiagnosticBuilder<'tcx, ErrorReported> { + mut err: DiagnosticBuilder<'tcx, ErrorGuaranteed>, + ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { err.note(&format!( "certain types, like `{}`, must be casted before passing them to a \ variadic function, because of arcane ABI rules dictated by the C \ diff --git a/compiler/rustc_typeck/src/structured_errors/sized_unsized_cast.rs b/compiler/rustc_typeck/src/structured_errors/sized_unsized_cast.rs index 8d2cdbb170b98..9b058d32f79ee 100644 --- a/compiler/rustc_typeck/src/structured_errors/sized_unsized_cast.rs +++ b/compiler/rustc_typeck/src/structured_errors/sized_unsized_cast.rs @@ -1,5 +1,5 @@ use crate::structured_errors::StructuredDiagnostic; -use rustc_errors::{DiagnosticBuilder, DiagnosticId, ErrorReported}; +use rustc_errors::{DiagnosticBuilder, DiagnosticId, ErrorGuaranteed}; use rustc_middle::ty::{Ty, TypeFoldable}; use rustc_session::Session; use rustc_span::Span; @@ -20,7 +20,7 @@ impl<'tcx> StructuredDiagnostic<'tcx> for SizedUnsizedCast<'tcx> { rustc_errors::error_code!(E0607) } - fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx, ErrorReported> { + fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { let mut err = self.sess.struct_span_fatal_with_code( self.span, &format!( @@ -39,8 +39,8 @@ impl<'tcx> StructuredDiagnostic<'tcx> for SizedUnsizedCast<'tcx> { fn diagnostic_extended( &self, - mut err: DiagnosticBuilder<'tcx, ErrorReported>, - ) -> DiagnosticBuilder<'tcx, ErrorReported> { + mut err: DiagnosticBuilder<'tcx, ErrorGuaranteed>, + ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { err.help( "Thin pointers are \"simple\" pointers: they are purely a reference to a memory address. diff --git a/compiler/rustc_typeck/src/structured_errors/wrong_number_of_generic_args.rs b/compiler/rustc_typeck/src/structured_errors/wrong_number_of_generic_args.rs index 62f89a2e6cf88..4a11771df493f 100644 --- a/compiler/rustc_typeck/src/structured_errors/wrong_number_of_generic_args.rs +++ b/compiler/rustc_typeck/src/structured_errors/wrong_number_of_generic_args.rs @@ -1,6 +1,6 @@ use crate::structured_errors::StructuredDiagnostic; use rustc_errors::{ - pluralize, Applicability, Diagnostic, DiagnosticBuilder, DiagnosticId, ErrorReported, + pluralize, Applicability, Diagnostic, DiagnosticBuilder, DiagnosticId, ErrorGuaranteed, }; use rustc_hir as hir; use rustc_middle::hir::map::fn_sig; @@ -374,7 +374,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } } - fn start_diagnostics(&self) -> DiagnosticBuilder<'tcx, ErrorReported> { + fn start_diagnostics(&self) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { let span = self.path_segment.ident.span; let msg = self.create_error_message(); @@ -810,7 +810,7 @@ impl<'tcx> StructuredDiagnostic<'tcx> for WrongNumberOfGenericArgs<'_, 'tcx> { rustc_errors::error_code!(E0107) } - fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx, ErrorReported> { + fn diagnostic_common(&self) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> { let mut err = self.start_diagnostics(); self.notify(&mut err); diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 5b6c7626239bc..dad045887031e 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -1,7 +1,7 @@ use rustc_ast as ast; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::sync::Lrc; -use rustc_errors::{ColorConfig, ErrorReported, FatalError}; +use rustc_errors::{ColorConfig, ErrorGuaranteed, FatalError}; use rustc_hir as hir; use rustc_hir::def_id::LOCAL_CRATE; use rustc_hir::intravisit; @@ -44,7 +44,7 @@ crate struct GlobalTestOptions { crate attrs: Vec, } -crate fn run(options: RustdocOptions) -> Result<(), ErrorReported> { +crate fn run(options: RustdocOptions) -> Result<(), ErrorGuaranteed> { let input = config::Input::File(options.input.clone()); let invalid_codeblock_attributes_name = crate::lint::INVALID_CODEBLOCK_ATTRIBUTES.name; @@ -154,14 +154,14 @@ crate fn run(options: RustdocOptions) -> Result<(), ErrorReported> { let unused_extern_reports = collector.unused_extern_reports.clone(); let compiling_test_count = collector.compiling_test_count.load(Ordering::SeqCst); - let ret: Result<_, ErrorReported> = + let ret: Result<_, ErrorGuaranteed> = Ok((collector.tests, unused_extern_reports, compiling_test_count)); ret }) }); let (tests, unused_extern_reports, compiling_test_count) = match res { Ok(res) => res, - Err(ErrorReported) => return Err(ErrorReported), + Err(ErrorGuaranteed) => return Err(ErrorGuaranteed), }; run_tests(test_args, nocapture, tests); @@ -619,7 +619,7 @@ crate fn make_test( }); let (already_has_main, already_has_extern_crate, found_macro) = match result { Ok(result) => result, - Err(ErrorReported) => { + Err(ErrorGuaranteed) => { // If the parser panicked due to a fatal error, pass the test code through unchanged. // The error will be reported during compilation. return (s.to_owned(), 0, false); diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 5c8a8fb80f1f4..4d88a4da45f44 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -80,7 +80,7 @@ use std::io; use std::process; use rustc_driver::{abort_on_err, describe_lints}; -use rustc_errors::ErrorReported; +use rustc_errors::ErrorGuaranteed; use rustc_interface::interface; use rustc_middle::ty::TyCtxt; use rustc_session::config::{make_crate_type_option, ErrorOutputType, RustcOptGroup}; @@ -178,7 +178,7 @@ pub fn main() { let exit_code = rustc_driver::catch_with_exit_code(|| match get_args() { Some(args) => main_args(&args), - _ => Err(ErrorReported), + _ => Err(ErrorGuaranteed), }); process::exit(exit_code); } @@ -671,7 +671,7 @@ fn usage(argv0: &str) { } /// A result type used by several functions under `main()`. -type MainResult = Result<(), ErrorReported>; +type MainResult = Result<(), ErrorGuaranteed>; fn main_args(at_args: &[String]) -> MainResult { let args = rustc_driver::args::arg_expand_all(at_args); @@ -691,7 +691,7 @@ fn main_args(at_args: &[String]) -> MainResult { // codes from `from_matches` here. let options = match config::Options::from_matches(&matches) { Ok(opts) => opts, - Err(code) => return if code == 0 { Ok(()) } else { Err(ErrorReported) }, + Err(code) => return if code == 0 { Ok(()) } else { Err(ErrorGuaranteed) }, }; rustc_interface::util::run_in_thread_pool_with_globals( options.edition, @@ -705,7 +705,7 @@ fn wrap_return(diag: &rustc_errors::Handler, res: Result<(), String>) -> MainRes Ok(()) => Ok(()), Err(err) => { diag.struct_err(&err).emit(); - Err(ErrorReported) + Err(ErrorGuaranteed) } } } diff --git a/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs index 8047a42c2b176..2c4309fbe66f9 100644 --- a/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs +++ b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs @@ -16,7 +16,7 @@ extern crate rustc_target; use rustc_codegen_ssa::traits::CodegenBackend; use rustc_codegen_ssa::{CodegenResults, CrateInfo}; 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::TyCtxt; @@ -47,7 +47,7 @@ impl CodegenBackend for TheBackend { ongoing_codegen: Box, _sess: &Session, _outputs: &OutputFilenames, - ) -> Result<(CodegenResults, FxHashMap), ErrorReported> { + ) -> Result<(CodegenResults, FxHashMap), ErrorGuaranteed> { let codegen_results = ongoing_codegen .downcast::() .expect("in join_codegen: ongoing_codegen is not a CodegenResults"); @@ -59,7 +59,7 @@ impl CodegenBackend for TheBackend { sess: &Session, codegen_results: CodegenResults, outputs: &OutputFilenames, - ) -> Result<(), ErrorReported> { + ) -> Result<(), ErrorGuaranteed> { use rustc_session::{config::CrateType, output::out_filename}; use std::io::Write; let crate_name = codegen_results.crate_info.local_crate_name;