rustc appears to hang on this RPITIT example
Open
Nobody has claimed this yet.
A-trait-system
C-bug
fixed-by-next-solver
I-hang
T-types
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I found a small example where rustc appear to hang during type checking.
pub struct BoundDropDisposal<D>(D);
pub trait Observable {
fn subscribe<OR>(self, observer: OR) -> BoundDropDisposal<impl Clone>;
}
fn test(source: impl Observable) {
subscribe_unsub_after_termination(|observer| {
source.subscribe(observer)
});
}
pub fn subscribe_unsub_after_termination<D, F>(_builder: F)
where
F: FnOnce(D) -> BoundDropDisposal<D>,
{
}
Running this does not finish for me and keeps CPU busy:
timeout 10 rustc --crate-type lib lib.rs
With the next solver, it reports an error immediately:
rustc +nightly -Znext-solver=globally --crate-type lib lib.rs
error[E0271]: type mismatch resolving `impl Clone == impl Clone`
--> lib.rs:9:26
|
9 | source.subscribe(observer)
| ^^^^^^^^ types differ
So I expected the current solver to also terminate with a type error instead of continuing to run.
Toolchain:
rustc 1.97.0 (2d8144b78 2026-07-07)
binary: rustc
commit-hash: 2d8144b7880597b6e6d3dfd63a9a9efae3f533d3
commit-date: 2026-07-07
host: aarch64-apple-darwin
release: 1.97.0
LLVM version: 22.1.6
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 self-contained example in lib.rs and reproduce the hang using timeout 10 rustc --crate-type lib lib.rs. Compare it with rustc +nightly -Znext-solver=globally --crate-type lib lib.rs; done means the current solver terminates with an appropriate type error instead of continuing to consume CPU.
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
- Clearly specified
- Newbie friendliness
- 45/100