rust-lang / rust-lang/rust

[ICE]: Compiler hangs with generic_const_exprs + over 9 trait bounds

Open
#152,608 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-associated-items A-trait-system C-bug F-generic_const_exprs I-hang S-has-mcve T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code

Compiler hangs with 10 or more trait bounds. Still compiles within a few seconds when 9 is used.

#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Cfg { const A:usize; const B:usize; const C:usize; const D:usize; const E:usize;
            const F:usize; const G:usize; const H:usize; const I:usize; const J:usize; }
struct S<C:Cfg>(std::marker::PhantomData<C>) where
    [();C::A]:,[();C::B]:,[();C::C]:,[();C::D]:,[();C::E]:,
    [();C::F]:,[();C::G]:,[();C::H]:,[();C::I]:,[();C::J]:;
trait T { fn f()->Self; }
impl<C:Cfg> T for S<C> where
    [();C::A]:,[();C::B]:,[();C::C]:,[();C::D]:,[();C::E]:,
    [();C::F]:,[();C::G]:,[();C::H]:,[();C::I]:,[();C::J]:
{ fn f()->Self { S(std::marker::PhantomData) } }
struct X;
impl Cfg for X { const A:usize=1;const B:usize=1;const C:usize=1;const D:usize=1;const E:usize=1;
                 const F:usize=1;const G:usize=1;const H:usize=1;const I:usize=1;const J:usize=1; }
#[test] fn t() { let _:S<X>=S::f(); }

Playground link

Meta

rustc --version --verbose:

rustc 1.93.1 (01f6ddf75 2026-02-11)
binary: rustc
commit-hash: 01f6ddf7588f42ae2d7eb0a2f21d44e8e96674cf
commit-date: 2026-02-11
host: aarch64-apple-darwin
release: 1.93.1
LLVM version: 21.1.8
Error output

Based on sampling, a hang somewhere in

  compiler/rustc_trait_selection/src/traits/select/mod.rs                                                                                                 
    -> expand_abstract_consts
    → evaluate_predicate_recursively                                                                                                                      
    → evaluate_predicates_recursively 

I'll try and trace to see what exactly blows up here.

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

Reproduce the provided generic_const_exprs example, comparing the 9- and 10-bound cases. Start in compiler/rustc_trait_selection/src/traits/select/mod.rs and trace expand_abstract_consts through evaluate_predicate_recursively and evaluate_predicates_recursively. Done means the reproducer no longer hangs and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.