Rollup merge of #100757 - ouz-a:issue-95134, r=jackh726
Catch overflow early Although this code should raise an overflow error, it didn't because [check_recursion_limit](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/traits/select/struct.SelectionContext.html#method.check_recursion_limit) it checks for `depth = 128` but not for `129` which should have triggered the overflow error. Anyways this catches that error early. Fixes #95134
This commit is contained in:
commit
88e39b2c2e
5 changed files with 51 additions and 7 deletions
|
@ -554,6 +554,18 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
|
|||
.flatten()
|
||||
.unwrap_or_else(|| ty::Term::Ty(ty.super_fold_with(self)))
|
||||
};
|
||||
// For cases like #95134 we would like to catch overflows early
|
||||
// otherwise they slip away away and cause ICE.
|
||||
let recursion_limit = self.tcx().recursion_limit();
|
||||
if !recursion_limit.value_within_limit(self.depth) {
|
||||
let obligation = Obligation::with_depth(
|
||||
self.cause.clone(),
|
||||
recursion_limit.0,
|
||||
self.param_env,
|
||||
ty,
|
||||
);
|
||||
self.selcx.infcx().report_overflow_error(&obligation, true);
|
||||
}
|
||||
debug!(
|
||||
?self.depth,
|
||||
?ty,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue