Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't normalize to an un-revealed opaque when we hit the recursion limit #117414

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions compiler/rustc_trait_selection/src/traits/query/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![feature(type_alias_impl_trait)]

type T = impl Copy;
//~^ ERROR cannot resolve opaque type

static STATIC: T = None::<&'static T>;

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0720]: cannot resolve opaque type
--> $DIR/infinite-cycle-involving-weak.rs:3:10
|
LL | type T = impl Copy;
| ^^^^^^^^^ cannot resolve opaque type

error: aborting due to previous error

For more information about this error, try `rustc --explain E0720`.
Loading