Fix ice when error reporting recursion errors

Fixes: #90319, #92148, #93955
This commit is contained in:
lightning1141 2022-02-26 11:55:07 +08:00
parent 37b55c8a0c
commit 85e67b9a59
No known key found for this signature in database
GPG key ID: 1094D31F57130E68
9 changed files with 66 additions and 14 deletions

View file

@ -27,6 +27,7 @@ use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
use rustc_hir::lang_items::LangItem;
use rustc_infer::infer::resolve::OpportunisticRegionResolver;
use rustc_middle::traits::select::OverflowError;
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder};
use rustc_middle::ty::subst::Subst;
use rustc_middle::ty::{self, Term, ToPredicate, Ty, TyCtxt};
@ -1139,7 +1140,9 @@ fn project<'cx, 'tcx>(
if !selcx.tcx().recursion_limit().value_within_limit(obligation.recursion_depth) {
// This should really be an immediate error, but some existing code
// relies on being able to recover from this.
return Err(ProjectionError::TraitSelectionError(SelectionError::Overflow));
return Err(ProjectionError::TraitSelectionError(SelectionError::Overflow(
OverflowError::Canonical,
)));
}
if obligation.predicate.references_error() {