- 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.T-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.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.
Description
When compiling the code below, rustc hangs indefinitely by calling a chain of functions recursively and continuously allocates memory, eventually causing the computer to run out of memory.
Note keeping FooTypeA and removing FooTypeB seems to produce the intended behaviour.
Code
pub trait Foo { type FooTypeA<'a>; type FooTypeB<'a>; } pub struct Implementor<C> { member: C } impl<C> Foo for Implementor<C> where for<'a> C: Foo<FooTypeA<'a>=Self::FooTypeA<'a>, FooTypeB<'a>=Self::FooTypeB<'a>>, { type FooTypeA<'a> = (); type FooTypeB<'a> = (); }Meta
The bug can be reproduced with both the latest stable and nightly compiler.
Stable
rustc --version --verbose:
rustc 1.89.0 (29483883e 2025-08-04) binary: rustc commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2 commit-date: 2025-08-04 host: x86_64-unknown-linux-gnu release: 1.89.0 LLVM version: 20.1.7 Nightly
rustc --version --verbose:
rustc 1.91.0-nightly (f2824da98 2025-08-28) binary: rustc commit-hash: f2824da98d44c4a4e17bf39eb45103c8fc249117 commit-date: 2025-08-28 host: x86_64-unknown-linux-gnu release: 1.91.0-nightly LLVM version: 21.1.0 Error output
No error output, the compiler hangs until the machine gets OOM.
Stacktrace
To produce a stacktrace, I used heaptrack and attached it to the running compiler.
I obviously only kept a short part of the stacktrace, since it's calling functions recursively.
Backtrace
rustc_trait_selection::traits::project::opt_normalize_projection_term in librustc_driver-10840eac1eb39611.so <rustc_trait_selection::traits::select::SelectionContext>::poly_select::{closure#0} in librustc_driver-10840eac1eb39611.so <rustc_trait_selection::traits::normalize::AssocTypeNormalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_binder::<rustc_type_ir::predicate_kind::PredicateKind<rustc_middle::ty::context::TyCtxt>> in librustc_driver-10840eac1eb39611.so <rustc_trait_selection::traits::normalize::AssocTypeNormalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty in librustc_driver-10840eac1eb39611.so rustc_trait_selection::traits::project::opt_normalize_projection_term in librustc_driver-10840eac1eb39611.so <rustc_trait_selection::traits::select::SelectionContext>::poly_select::{closure#0} in librustc_driver-10840eac1eb39611.so <rustc_trait_selection::traits::normalize::AssocTypeNormalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_binder::<rustc_type_ir::predicate_kind::PredicateKind<rustc_middle::ty::context::TyCtxt>> in librustc_driver-10840eac1eb39611.so <rustc_trait_selection::traits::normalize::AssocTypeNormalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty in librustc_driver-10840eac1eb39611.so rustc_trait_selection::traits::project::opt_normalize_projection_term in librustc_driver-10840eac1eb39611.so <rustc_trait_selection::traits::select::SelectionContext>::poly_select::{closure#0} in librustc_driver-10840eac1eb39611.so <rustc_trait_selection::traits::normalize::AssocTypeNormalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_binder::<rustc_type_ir::predicate_kind::PredicateKind<rustc_middle::ty::context::TyCtxt>> in librustc_driver-10840eac1eb39611.so <rustc_trait_selection::traits::normalize::AssocTypeNormalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty in librustc_driver-10840eac1eb39611.so rustc_trait_selection::traits::project::opt_normalize_projection_term in librustc_driver-10840eac1eb39611.so [snip] 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.T-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.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.