Compiler hang with recursive bound and generic impl on opaque type
Open
Nobody has claimed this yet.
A-trait-system
C-bug
F-type_alias_impl_trait
fixed-by-next-solver
I-hang
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code :
#![feature(type_alias_impl_trait)]
trait Base {}
impl Base for () {}
trait Link {}
type X
where
X: Link,
= impl Base;
impl<T> Link for X {}
fn main() {
let _: X = ();
}
I expected to see this happen: The compiler should report an error.
Instead, this happened: The compiler hangs indefinitely (infinite loop).
Meta
rustc --version --verbose:
rustc 1.91.0-nightly (f34ba774c 2025-08-03)
binary: rustc
commit-hash: f34ba774c78ea32b7c40598b8ad23e75cdac42a6
commit-date: 2025-08-03
host: x86_64-pc-windows-msvc
release: 1.91.0-nightly
LLVM version: 20.1.8
Backtrace
error[E0282]: type annotations needed
--> example2.rs:8:1
|
8 | type X
| ^^^^^^ cannot infer type for type parameter `T`
then the process hangs
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 by compiling the provided example2.rs with the reported rustc 1.91.0-nightly toolchain and confirm the E0282 diagnostic followed by an indefinite hang. Investigate the compiler path handling the recursive bound on the opaque type; done means the example terminates with an error rather than hanging, with regression coverage for this case.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100