- Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.
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
Metadata
Metadata
Assignees
Labels
A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.