Repository: rust
Issue: crash: lazy type alias: stack overflow
Labels: I-crash,T-compiler,C-bug,F-lazy_type_alias

<!--
Thank you for finding an Internal Compiler Error! 🧊  If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.
http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/
-->

### Code

```Rust
#![feature(lazy_type_alias)]
type A = [[Y; {}]; {
    type A = [A; {}];
}];

```


### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.84.0-nightly (662180b34 2024-10-20)
binary: rustc
commit-hash: 662180b34d95f72d05b7c467b0baf4d23d36b1e1
commit-date: 2024-10-20
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1
```

### Error output

```
<output>
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Backtrace</strong></summary>
<p>

```
error[E0412]: cannot find type `Y` in this scope
 --> /tmp/crash.rs:2:12
  |
2 | type A = [[Y; {}]; {
  |            ^ not found in this scope

warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/crash.rs:1:12
  |
1 | #![feature(lazy_type_alias)]
  |            ^^^^^^^^^^^^^^^
  |
  = note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information
  = note: `#[warn(incomplete_features)]` on by default

error[E0601]: `main` function not found in crate `crash`
 --> /tmp/crash.rs:4:4
  |
4 | }];
  |    ^ consider adding a `main` function to `/tmp/crash.rs`

error[E0308]: mismatched types
 --> /tmp/crash.rs:2:15
  |
2 | type A = [[Y; {}]; {
  |               ^^ expected `usize`, found `()`

error: rustc interrupted by SIGSEGV, printing backtrace

/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-5396912e8af1f65d.so(+0x37207d3) [0x732bf89207d3]
/usr/lib/libc.so.6(+0x3d1d0) [0x732bfc5bb1d0]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-5396912e8af1f65d.so(+0x5011e81) [0x732bfa211e81]

### cycle encountered after 3 frames with period 4
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-5396912e8af1f65d.so(+0x50124ce) [0x732bfa2124ce]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-5396912e8af1f65d.so(+0x5011e86) [0x732bfa211e86]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-5396912e8af1f65d.so(+0x50124ce) [0x732bfa2124ce]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-5396912e8af1f65d.so(+0x5011e86) [0x732bfa211e86]
### recursed 63 times

/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-5396912e8af1f65d.so(+0x50124ce) [0x732bfa2124ce]

note: rustc unexpectedly overflowed its stack! this is a bug
note: maximum backtrace depth reached, frames may have been lost
note: we would appreciate a report at https://github.com/rust-lang/rust
help: you can increase rustc's stack size by setting RUST_MIN_STACK=16777216
```

</p>
</details>