Open
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