Repository: rust
Issue: Hang: type_alias_impl_trait
Labels: T-compiler,I-compilemem,C-bug,I-hang,F-type_alias_impl_trait

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.
-->

I tried this code:

```shell
rustc file.rs
```

```rust
#![feature(type_alias_impl_trait)]
trait Id {
    type Assoc;
}
impl<T> *const u8 {
    type Assoc = T;
}
type Ty
where
    Ty: Id<Assoc = Ty>,
= impl Sized;
fn define() -> Ty {}
fn main() {}

```

This file causes rustc to hang and is derived from mutant #109387. #109387 can terminate successfully.

### 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 (b91a3a056 2024-11-07)
binary: rustc
commit-hash: b91a3a05609a46f73d23e0995ae7ebb4a4f429a5
commit-date: 2024-11-07
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.3
```


<details><summary>Compiler Output (before the hang)</summary>

```
error[E0658]: inherent associated types are unstable
 --> file.rs:6:5
  |
6 |     type Assoc = T;
  |     ^^^^^^^^^^^^^^^
  |
  = note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information
  = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable
  = note: this compiler was built on 2024-11-04; consider upgrading it if it is out of date

error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
 --> file.rs:5:6
  |
5 | impl<T> *const u8 {
  |      ^ unconstrained type parameter

error[E0277]: the trait bound `Ty: Id` is not satisfied
  --> file.rs:8:1
   |
8  | type Ty
   | ^^^^^^^ the trait `Id` is not implemented for `Ty`
   |
help: this trait has no implementations, consider adding one
  --> file.rs:2:1
   |
2  | trait Id {
   | ^^^^^^^^
note: required by a bound on the type alias `Ty`
  --> file.rs:10:9
   |
10 |     Ty: Id<Assoc = Ty>,
   |         ^^^^^^^^^^^^^^ required by this bound

error[E0277]: the trait bound `Ty: Id` is not satisfied
  --> file.rs:10:5
   |
10 |     Ty: Id<Assoc = Ty>,
   |     ^^^^^^^^^^^^^^^^^^ the trait `Id` is not implemented for `Ty`
   |
help: this trait has no implementations, consider adding one
  --> file.rs:2:1
   |
2  | trait Id {
   | ^^^^^^^^
   = help: see issue #48214
help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
   |
2  + #![feature(trivial_bounds)]
   |

error[E0277]: the trait bound `Ty: Id` is not satisfied
  --> file.rs:11:3
   |
11 | = impl Sized;
   |   ^^^^^^^^^^ the trait `Id` is not implemented for `Ty`
   |
help: this trait has no implementations, consider adding one
  --> file.rs:2:1
   |
2  | trait Id {
   | ^^^^^^^^
note: required by a bound on the type alias `Ty`
  --> file.rs:10:9
   |
10 |     Ty: Id<Assoc = Ty>,
   |         ^^^^^^^^^^^^^^ required by this bound

error[E0277]: the trait bound `Ty: Id` is not satisfied
  --> file.rs:12:16
   |
12 | fn define() -> Ty {}
   |                ^^ the trait `Id` is not implemented for `Ty`
   |
help: this trait has no implementations, consider adding one
  --> file.rs:2:1
   |
2  | trait Id {
   | ^^^^^^^^
note: required by a bound on the type alias `Ty`
  --> file.rs:10:9
   |
10 |     Ty: Id<Assoc = Ty>,
   |         ^^^^^^^^^^^^^^ required by this bound

error[E0277]: the trait bound `Ty: Id` is not satisfied
  --> file.rs:12:19
   |
12 | fn define() -> Ty {}
   |                   ^^ the trait `Id` is not implemented for `Ty`
   |
help: this trait has no implementations, consider adding one
  --> file.rs:2:1
   |
2  | trait Id {
   | ^^^^^^^^
note: required by a bound on the type alias `Ty`
  --> file.rs:10:9
   |
10 |     Ty: Id<Assoc = Ty>,
   |         ^^^^^^^^^^^^^^ required by this bound

error[E0390]: cannot define inherent `impl` for primitive types
 --> file.rs:5:1
  |
5 | impl<T> *const u8 {
  | ^^^^^^^^^^^^^^^^^
  |
  = help: consider using an extension trait instead
```

</details>