Skip to content

Compiler freezes on trait with generic associated type #130640

Open
@antonilol

Description

@antonilol

I tried this code:

trait What {
    type This<'a>: 'a
    where
        for<'b> Self::This<'b>: 'a + 'b;
}

impl<T> What for T {
    type This<'a> = T where T: 'a;
}

I expected to see this happen: The compiler returning with a success (probably not) or a compilation error

Instead, this happened: Compiler freezes, cpu usage shows one core of 100% usage (infinite loop?)

Meta

rustc --version --verbose:

rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7

I tried some versions between GATs stabilizing and current nightly, and all had the same behavior.

This could be a duplicate of existing similar issues, but I am not sure if that is the case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-GATsArea: Generic associated types (GATs)A-associated-itemsArea: Associated items (types, constants & functions)A-lifetimesArea: Lifetimes / regionsA-trait-systemArea: Trait systemC-bugCategory: This is a bug.I-hangIssue: 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.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