rust-lang / rust-lang/rust

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

Open
#142,832 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-higher-ranked A-trait-system C-bug fixed-by-next-solver I-hang T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue provides a reduced Rust reproducer rather than a source file or test path. Start by compiling it with the reported rustc version and -Z time-passes, focusing on the reported stall during coherence_checking; done means the compiler terminates instead of looping on the duplicated higher-ranked bounds.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.