Don't super-fold types when we hit the recursion limit
This commit is contained in:
parent
e6e931dda5
commit
c91f60e22f
3 changed files with 21 additions and 7 deletions
|
@ -230,17 +230,14 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx>
|
||||||
Reveal::All => {
|
Reveal::All => {
|
||||||
let args = data.args.try_fold_with(self)?;
|
let args = data.args.try_fold_with(self)?;
|
||||||
let recursion_limit = self.interner().recursion_limit();
|
let recursion_limit = self.interner().recursion_limit();
|
||||||
|
|
||||||
if !recursion_limit.value_within_limit(self.anon_depth) {
|
if !recursion_limit.value_within_limit(self.anon_depth) {
|
||||||
// A closure or coroutine may have itself as in its upvars.
|
let guar = self
|
||||||
// This should be checked handled by the recursion check for opaque
|
.infcx
|
||||||
// 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
|
|
||||||
.err_ctxt()
|
.err_ctxt()
|
||||||
.build_overflow_error(&ty, self.cause.span, true)
|
.build_overflow_error(&ty, self.cause.span, true)
|
||||||
.delay_as_bug();
|
.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);
|
let generic_ty = self.interner().type_of(data.def_id);
|
||||||
|
|
|
@ -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() {}
|
|
@ -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…
Add table
Add a link
Reference in a new issue