rust-lang / rust-lang/rust

Hang when resolving complex type alias constraints

Open
#151,068 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The bug is found by a fuzzer.
I tried this code:

trait PrivateSquareRoot {}
pub trait Mul<Rhs = Self> {
    type Output: Mul;
}
pub trait IsGreaterOrEqual<Rhs> {
    type Output;
}
pub type Square<A: PrivateSquareRoot> = <A as Mul>::Output;
pub type GrEq<A, B> = <A as IsGreaterOrEqual<B>>::Output;
impl<A, B: PrivateSquareRoot> IsGreaterOrEqual<B> for A {
    type Output = ();
}
impl<U> PrivateSquareRoot for U
where
    U: Mul,
    Square<U>: Mul,
    GrEq<Self, Square<Square<U>>>: Sized,
    U: PrivateSquareRoot,
{}
fn main() {}


The compiler behavior differs depending on the release channel and trait solver used:

Release channel Result
current Stable Hang
current Nightly (default solver) Hang
Nightly + -Znext-solver=globally error

The compiler hangs. Fixed by next solver.

Meta

rustc --version --verbose:

rustc 1.94.0-nightly (f57eac1bf 2026-01-10)
binary: rustc
commit-hash: f57eac1bf98cb5d578e3364b64365ec398c137df
commit-date: 2026-01-10
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8
Backtrace

 The compiler hangs;

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

Start with the Rust reproducer in the issue and compare compilation with the default solver against nightly with -Znext-solver=globally. Trace the trait-solver handling of the nested type aliases and constraints; done means the default solver no longer hangs and produces a terminating result consistent with the next solver.

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.