rename ErrorReported -> ErrorGuaranteed

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

View file

@ -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)

View file

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

View file

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

View file

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

View file

@ -3,7 +3,7 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::obligation_forest::ProcessResult;
use rustc_data_structures::obligation_forest::{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()),

View file

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

View file

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

View file

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

View file

@ -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()),