diff options
| author | Michael Goulet <michael@errs.io> | 2023-10-30 19:24:08 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-10-30 19:24:15 +0000 |
| commit | c91f60e22fccbd1ee7701b2a1b88457985f9df0b (patch) | |
| tree | d1ea49365086c0685414603a445e48761edbe1dd /compiler/rustc_trait_selection/src | |
| parent | e6e931dda5fffbae0fd87c5b1af753cc95556880 (diff) | |
| download | rust-c91f60e22fccbd1ee7701b2a1b88457985f9df0b.tar.gz rust-c91f60e22fccbd1ee7701b2a1b88457985f9df0b.zip | |
Don't super-fold types when we hit the recursion limit
Diffstat (limited to 'compiler/rustc_trait_selection/src')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/query/normalize.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs index c761d0d103e..2e31b560b38 100644 --- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs @@ -230,17 +230,14 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx> Reveal::All => { let args = data.args.try_fold_with(self)?; let recursion_limit = self.interner().recursion_limit(); + if !recursion_limit.value_within_limit(self.anon_depth) { - // A closure or coroutine may have itself as in its upvars. - // This should be checked handled by the recursion check for opaque - // types, but we may end up here before that check can happen. - // In that case, we delay a bug to mark the trip, and continue without - // revealing the opaque. - self.infcx + let guar = self + .infcx .err_ctxt() .build_overflow_error(&ty, self.cause.span, true) .delay_as_bug(); - return ty.try_super_fold_with(self); + return Ok(Ty::new_error(self.interner(), guar)); } let generic_ty = self.interner().type_of(data.def_id); |
