Compiler hang with GAT in impl where clause
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
The following code causes the compiler to hang:
pub trait Apply {
type Output<A>: Apply;
}
pub trait Trait {}
impl<A: Apply> Trait for A where <A as Apply>::Output<A>: Trait {}
Using -Znext-solver causes this code to compile without errors.
Adding #![recursion_limit = "16"] to the top produces the following compile error:
error[E0275]: overflow evaluating the requirement `<<<<<<<... as Apply>::Output<...> as Apply>::Output<...> as Apply>::Output<...> as Apply>::Output<...> as Apply>::Output<...> as Apply>::Output<...> as Apply>::Output<...>: Trait`
--> src/lib.rs:9:59
|
9 | impl<A: Apply> Trait for A where <A as Apply>::Output<A>: Trait {}
| ^^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "32"]` attribute to your crate (`foo`)
note: required for `<... as Apply>::Output<...>` to implement `Trait`
--> src/lib.rs:9:16
|
9 | impl<A: Apply> Trait for A where <A as Apply>::Output<A>: Trait {}
| ^^^^^ ^ ----- unsatisfied trait bound introduced here
= note: 14 redundant requirements hidden
= note: required for `<A as Apply>::Output<A>` to implement `Trait`
= note: the full name for the type has been written to '/Users/timch/foo/target/debug/deps/foo-890f97683d406f94.long-type-13481938346205059950.txt'
= note: consider using `--verbose` to print the full type name to the console
For more information about this error, try `rustc --explain E0275`.
Changing type Output<A>: Apply; to type Output<A>; makes the program compile without errors.
Meta
rustc --version --verbose:
rustc 1.96.0-nightly (cf7da0b72 2026-03-30)
binary: rustc
commit-hash: cf7da0b7277cad05b79f91b60c290aa08a17a6f0
commit-date: 2026-03-30
host: aarch64-apple-darwin
release: 1.96.0-nightly
LLVM version: 22.1.2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproducer in src/lib.rs, especially the GAT bound and impl where clause at line 9, and compare the default solver with -Znext-solver. Confirm the hang and the recursion-limit overflow, then verify that the compiler terminates with appropriate behavior without requiring the bound to be removed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100