InferCtxt::is_tainted_by_errors
returns ErrorGuaranteed
This commit is contained in:
parent
c1ec8ff14d
commit
9c510048fd
10 changed files with 33 additions and 35 deletions
|
@ -2060,7 +2060,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
// check upstream for type errors and don't add the obligations to
|
||||
// begin with in those cases.
|
||||
if self.tcx.lang_items().sized_trait() == Some(trait_ref.def_id()) {
|
||||
if !self.is_tainted_by_errors() {
|
||||
if let None = self.is_tainted_by_errors() {
|
||||
self.emit_inference_failure_err(
|
||||
body_id,
|
||||
span,
|
||||
|
@ -2115,16 +2115,14 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
if impls.len() > 1 && impls.len() < 5 && has_non_region_infer {
|
||||
self.annotate_source_of_ambiguity(&mut err, &impls, predicate);
|
||||
} else {
|
||||
if self.is_tainted_by_errors() {
|
||||
err.delay_as_bug();
|
||||
if self.is_tainted_by_errors().is_some() {
|
||||
return;
|
||||
}
|
||||
err.note(&format!("cannot satisfy `{}`", predicate));
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
if self.is_tainted_by_errors() {
|
||||
err.delay_as_bug();
|
||||
if self.is_tainted_by_errors().is_some() {
|
||||
return;
|
||||
}
|
||||
err.note(&format!("cannot satisfy `{}`", predicate));
|
||||
|
@ -2226,7 +2224,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
] = path.segments
|
||||
&& data.trait_ref.def_id == *trait_id
|
||||
&& self.tcx.trait_of_item(*item_id) == Some(*trait_id)
|
||||
&& !self.is_tainted_by_errors()
|
||||
&& let None = self.is_tainted_by_errors()
|
||||
{
|
||||
let (verb, noun) = match self.tcx.associated_item(item_id).kind {
|
||||
ty::AssocKind::Const => ("refer to the", "constant"),
|
||||
|
@ -2295,7 +2293,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
// with error messages.
|
||||
if arg.references_error()
|
||||
|| self.tcx.sess.has_errors().is_some()
|
||||
|| self.is_tainted_by_errors()
|
||||
|| self.is_tainted_by_errors().is_some()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -2306,7 +2304,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
ty::PredicateKind::Subtype(data) => {
|
||||
if data.references_error()
|
||||
|| self.tcx.sess.has_errors().is_some()
|
||||
|| self.is_tainted_by_errors()
|
||||
|| self.is_tainted_by_errors().is_some()
|
||||
{
|
||||
// no need to overload user in such cases
|
||||
return;
|
||||
|
@ -2317,7 +2315,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
self.emit_inference_failure_err(body_id, span, a.into(), ErrorCode::E0282, true)
|
||||
}
|
||||
ty::PredicateKind::Projection(data) => {
|
||||
if predicate.references_error() || self.is_tainted_by_errors() {
|
||||
if predicate.references_error() || self.is_tainted_by_errors().is_some() {
|
||||
return;
|
||||
}
|
||||
let subst = data
|
||||
|
@ -2351,7 +2349,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
|
||||
ty::PredicateKind::ConstEvaluatable(data) => {
|
||||
if predicate.references_error() || self.is_tainted_by_errors() {
|
||||
if predicate.references_error() || self.is_tainted_by_errors().is_some() {
|
||||
return;
|
||||
}
|
||||
let subst = data.walk().find(|g| g.is_non_region_infer());
|
||||
|
@ -2378,7 +2376,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
if self.tcx.sess.has_errors().is_some() || self.is_tainted_by_errors() {
|
||||
if self.tcx.sess.has_errors().is_some() || self.is_tainted_by_errors().is_some() {
|
||||
return;
|
||||
}
|
||||
let mut err = struct_span_err!(
|
||||
|
@ -2422,7 +2420,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
post.sort();
|
||||
post.dedup();
|
||||
|
||||
if self.is_tainted_by_errors()
|
||||
if self.is_tainted_by_errors().is_some()
|
||||
&& (crate_names.len() == 1
|
||||
&& spans.len() == 0
|
||||
&& ["`core`", "`alloc`", "`std`"].contains(&crate_names[0].as_str())
|
||||
|
|
|
@ -33,7 +33,7 @@ use crate::traits::ProjectionCacheKey;
|
|||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_errors::{Diagnostic, ErrorGuaranteed};
|
||||
use rustc_errors::Diagnostic;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_infer::infer::LateBoundRegionConversionTime;
|
||||
|
@ -1089,10 +1089,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
if !self.infcx.tcx.recursion_limit().value_within_limit(depth) {
|
||||
match self.query_mode {
|
||||
TraitQueryMode::Standard => {
|
||||
if self.infcx.is_tainted_by_errors() {
|
||||
return Err(OverflowError::Error(
|
||||
ErrorGuaranteed::unchecked_claim_error_was_emitted(),
|
||||
));
|
||||
if let Some(e) = self.infcx.is_tainted_by_errors() {
|
||||
return Err(OverflowError::Error(e));
|
||||
}
|
||||
self.infcx.err_ctxt().report_overflow_error(error_obligation, true);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue