Skip to content

endless loop instead of an overflow error, in the presence of multiple requirements that would overflow. #140946

Open
@moshevds

Description

@moshevds

I tried this code:

pub trait Foo {
    type Bar<'a>;
    type Baz<'a>;
}
impl Foo for ()
where
    T: for<'a> Foo<
        Bar<'a> = Self::Bar<'a>,
        Baz<'a> = Self::Baz<'a>,
    >
{}

I expected to see this happen:

An "overflow evaluating the requirement" error message should be reported. Probably it should generate:

error[E0275]: overflow evaluating the requirement `for<'a> <() as Foo>::Bar<'a> == _`

or

error[E0275]: overflow evaluating the requirement `for<'a> <() as Foo>::Baz<'a> == _`

Or perhaps another specific overflow error for the specific combined requirement it is evaluating.

Instead, this happened:
The compiler reached an endless loop.

Meta

rustc --version --verbose:

rustc 1.89.0-nightly (ce7e97f73 2025-05-11)
binary: rustc
commit-hash: ce7e97f7371af47e0786f74aa169f6ac9473ff4e
commit-date: 2025-05-11
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-GATsArea: Generic associated types (GATs)A-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)A-trait-systemArea: Trait systemC-bugCategory: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.T-typesRelevant 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`.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions