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
|
@ -1208,7 +1208,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
/// reporting errors that often occur as a result of earlier
|
||||
/// errors, but where it's hard to be 100% sure (e.g., unresolved
|
||||
/// inference variables, regionck errors).
|
||||
pub fn is_tainted_by_errors(&self) -> bool {
|
||||
pub fn is_tainted_by_errors(&self) -> Option<ErrorGuaranteed> {
|
||||
debug!(
|
||||
"is_tainted_by_errors(err_count={}, err_count_on_creation={}, \
|
||||
tainted_by_errors={})",
|
||||
|
@ -1218,9 +1218,13 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
);
|
||||
|
||||
if self.tcx.sess.err_count() > self.err_count_on_creation {
|
||||
return true; // errors reported since this infcx was made
|
||||
// errors reported since this infcx was made
|
||||
return Some(self.tcx.sess.delay_span_bug(
|
||||
DUMMY_SP,
|
||||
"`tcx.sess.error_count()` incorrectly returned non zero value",
|
||||
));
|
||||
}
|
||||
self.tainted_by_errors.get().is_some()
|
||||
self.tainted_by_errors.get()
|
||||
}
|
||||
|
||||
/// Set the "tainted by errors" flag to true. We call this when we
|
||||
|
@ -1270,7 +1274,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
let mut inner = self.inner.borrow_mut();
|
||||
let inner = &mut *inner;
|
||||
assert!(
|
||||
self.is_tainted_by_errors() || inner.region_obligations.is_empty(),
|
||||
self.is_tainted_by_errors().is_some() || inner.region_obligations.is_empty(),
|
||||
"region_obligations not empty: {:#?}",
|
||||
inner.region_obligations
|
||||
);
|
||||
|
@ -1707,7 +1711,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
) {
|
||||
let errors = self.resolve_regions(outlives_env);
|
||||
|
||||
if !self.is_tainted_by_errors() {
|
||||
if let None = self.is_tainted_by_errors() {
|
||||
// As a heuristic, just skip reporting region errors
|
||||
// altogether if other errors have been reported while
|
||||
// this infcx was in use. This is totally hokey but
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue