rust-lang/rust

Hang with weird recursive associated type

Opened this issue · 0 comments

Found by mutating src/test/ui/closures/issue-41366.rs with a modified fuzz-rustc

Code

This hangs the compiler:

trait T<'x> {
    type V;
}

impl<'g> T<'g> for u32 {
    type V = dyn for<'x> Fn(<u32 as T<'x>>::V);
}

fn main() {}

Suspicious recursion

If I decrease the recursion limit with #![recursion_limit = "16"], it finishes in 4 seconds with E0275:

Error output with low recursion limit
error[E0275]: overflow evaluating the requirement `for<'x> u32: T<'x>`
 --> oomq.rs:8:14
  |
8 |     type V = dyn for<'x> Fn(<u32 as T<'x>>::V);
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "32"]` attribute to your crate (`oomq`)

This also allows the use of -Z time-passes, which reveals that the slowness is during wf_checking.

Regression

Regression in nightly-2021-08-26, likely with #85499 (@jackh726)

Commits in range
  commit[0] 2021-08-24UTC: Auto merge of #88266 - nikomatsakis:issue-87879, r=jackh726
  commit[1] 2021-08-24UTC: Auto merge of #88271 - sexxi-goose:liveness, r=nikomatsakis
  commit[2] 2021-08-25UTC: Auto merge of #88242 - bonega:allocation_range, r=oli-obk
  commit[3] 2021-08-25UTC: Auto merge of #84333 - tmiasko:liveness-yield, r=tmandry
  commit[4] 2021-08-25UTC: Auto merge of #87875 - asquared31415:generic-lang-items, r=cjgillot
  commit[5] 2021-08-25UTC: Auto merge of #85344 - cbeuw:remap-across-cwd, r=michaelwoerister
  commit[6] 2021-08-25UTC: Auto merge of #87937 - LeSeulArtichaut:active-if-let-guards, r=nagisa
  commit[7] 2021-08-25UTC: Auto merge of #88329 - LeSeulArtichaut:rollup-blg8hc0, r=LeSeulArtichaut
  commit[8] 2021-08-25UTC: Auto merge of #85499 - jackh726:assoc-type-norm-rebase, r=nikomatsakis

Previously, it complained of an unsized type:

Error output before 2021-08-26
$ rustc +bisector-nightly-2021-08-25-x86_64-apple-darwin oomq.rs
error[E0277]: the size for values of type `(dyn for<'x> Fn(<u32 as T<'x>>::V) + 'static)` cannot be known at compilation time
 --> oomq.rs:8:5
  |
8 |     type V = dyn for<'x> Fn(<u32 as T<'x>>::V);
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `(dyn for<'x> Fn(<u32 as T<'x>>::V) + 'static)`
note: required by a bound in `T::V`
 --> oomq.rs:4:5
  |
4 |     type V;
  |     ^^^^^^^ required by this bound in `T::V`

Version

rustc 1.67.0-nightly (85f4f41de 2022-11-08)
binary: rustc
commit-hash: 85f4f41deb1557ca8ab228319d33003dd2f20f45
commit-date: 2022-11-08
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4

@rustbot label +I-hang +I-compiletime