Skip to content

compiler gets stuck on recursive impl with duplicated for<'a> Trait bounds #142832

Open
@sososopy

Description

@sososopy

The code is generated by a fuzzer and reduced manually

I tried this code:

trait Trait {}
struct W<T>(T);
impl<T> Trait for W<W<T>>
where
    W < T > : for < 'a > Trait,
    W < T > : for < 'a > Trait,
{ }
fn func<T: Trait>() {}
fn main() {
    func::<W<_>>();
}

Running the code with rustc causes an infinite loop. This is the first time I've encountered a hang issue, and I'm not sure how to check if it's a duplicate problem.

Meta

rustc --version --verbose:

rustc 1.89.0-nightly (5526a2f47 2025-06-20)
binary: rustc
commit-hash: 5526a2f47cd676ceeedc08cf71ae75ce2e9284ae
commit-date: 2025-06-20
host: x86_64-pc-windows-msvc
release: 1.89.0-nightly
LLVM version: 20.1.7

Error output

<None>

-Z time-passes

time:   0.000; rss:   16MB ->   17MB (   +1MB)  parse_crate
time:   0.000; rss:   20MB ->   20MB (   +0MB)  crate_injection
time:   0.007; rss:   20MB ->   23MB (   +3MB)  expand_crate
time:   0.008; rss:   20MB ->   23MB (   +3MB)  macro_expand_crate
time:   0.000; rss:   23MB ->   23MB (   +0MB)  AST_validation
time:   0.000; rss:   23MB ->   23MB (   +0MB)  finalize_imports
time:   0.000; rss:   23MB ->   23MB (   +0MB)  compute_effective_visibilities
time:   0.000; rss:   23MB ->   23MB (   +0MB)  finalize_macro_resolutions
time:   0.000; rss:   23MB ->   23MB (   +0MB)  late_resolve_crate
time:   0.000; rss:   23MB ->   23MB (   +0MB)  resolve_main
time:   0.000; rss:   23MB ->   23MB (   +0MB)  resolve_check_unused
time:   0.000; rss:   23MB ->   23MB (   +0MB)  resolve_postprocess
time:   0.007; rss:   23MB ->   23MB (   +1MB)  resolve_crate
time:   0.000; rss:   23MB ->   23MB (   +0MB)  write_dep_info
time:   0.000; rss:   24MB ->   24MB (   +0MB)  complete_gated_feature_checking
time:   0.000; rss:   24MB ->   24MB (   +0MB)  drop_ast
time:   0.000; rss:   25MB ->   25MB (   +0MB)  looking_for_entry_point
time:   0.000; rss:   25MB ->   25MB (   +0MB)  looking_for_derive_registrar
time:   0.000; rss:   26MB ->   26MB (   +0MB)  unused_lib_feature_checking
time:   0.003; rss:   25MB ->   26MB (   +1MB)  misc_checking_1
time:   0.002; rss:   26MB ->   31MB (   +5MB)  coherence_checking

Metadata

Metadata

Assignees

No one assigned

    Labels

    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-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