Rustc hang, likely due to infinite recusion
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
trait Chain<'a, H: Chain<'a, H>> {
fn run(head: &mut H, get: impl FnMut(&mut H) -> &mut Self);
}
struct FinalStage;
impl<'a, H: Chain<'a, H>> Chain<'a, H> for FinalStage {
fn run(_head: &mut H, _get: impl FnMut(&mut H) -> &mut Self) {}
}
struct BasicStage<C> {
next_stage: C,
}
impl<'a, H: Chain<'a, H>, C: Chain<'a, H>> Chain<'a, H> for BasicStage<C> {
fn run(head: &mut H, mut get: impl FnMut(&mut H) -> &mut Self) {
// let _this = get(head);
// C::run(head, |h| &mut get(h).next_stage);
}
}
fn run_chain<'a, H: Chain<'a, H>>(head: &mut H) {
H::run(head, |h| h);
}
fn test_example_chain() {
let mut chain = BasicStage {
next_stage: FinalStage,
};
run_chain(&mut chain);
}
I expected to see this happen: compiler to exit, either successfully or unsuccessfully
Instead, this happened: rustc hangs indefinitely
(I will hazard a guess that this is probably just due to a missing check on the recursion limit, because similar versions of this code fail with overflow evaluating the requirement).
Meta
rustc --version --verbose:
rustc 1.88.0 (6b00bc388 2025-06-23)
binary: rustc
commit-hash: 6b00bc3880198600130e1cf62b8f8a93494488cc
commit-date: 2025-06-23
host: aarch64-apple-darwin
release: 1.88.0
LLVM version: 20.1.5
Backtrace: N/A.
Sampler output: Sample of rustc.txt
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 reproducing the minimized Rust program with rustc 1.88.0 and inspect the linked sampler output. The report names no source file or test entry point, so tracing the compiler's recursive trait-evaluation path will be required. Done means rustc terminates successfully or reports an evaluation error instead of hanging indefinitely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100