Repository: rust
Issue: Hang with weird recursive associated type
Labels: I-compiletime,T-compiler,C-bug,I-hang

Found by mutating [src/test/ui/closures/issue-41366.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/closures/issue-41366.rs) with a [modified fuzz-rustc](https://github.com/jruderman/fuzz-rustc)

### Code

This hangs the compiler:

```rust
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](https://doc.rust-lang.org/reference/attributes/limits.html#the-recursion_limit-attribute) with `#![recursion_limit = "16"]`, it finishes in 4 seconds with [E0275](https://doc.rust-lang.org/error_codes/E0275.html):

<details><summary>Error output with low recursion limit</summary>

```
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`)
```

</details>

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)

<details><summary>Commits in range</summary>

```
  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
```

</details>

Previously, it complained of an unsized type:

<details><summary>Error output before 2021-08-26</summary>

```
$ 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`
```

</details>

### 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