Skip to content

rustc hangs with the next solver #155626

@nossie531

Description

@nossie531

I’m not good at English. I’m sorry if this is hard to read.

When editing the short code described below in VSCode, it takes about 30 seconds for the tooltip contents to appear.

Informations

rust-analyzer version: 0.4.2871

rustc version: 1.95.0 (5980761 2026-04-14)

editor or extension: VSCode 1.116.0

relevant settings: all default

code snippet to reproduce: See below

Related issues

Before the tooltip content is displayed, only "Loading..." appears.

Posts rust-lang/rust-analyzer#15478 and rust-lang/rust-analyzer#17688 address similar performance issues.

Impact size

Many users may encounter this issue.

Because the target code contains several implementations that combine the following trait and type.

ImplTarget - HasSeveralImpls

And before simplification, this was a combination of the following trait and type from rand crate.

Distribution - StandardUniform

Therefore, the scope of impact is wide, but speed up workarounds exists (See comment in below code).

Code to reproduce

use std::marker::PhantomData;

pub fn return_impl() -> impl MyTrait<Assoc = i32> {
    my_type()  // workaround: `my_type::<i32>()`
}

fn my_type<T>() -> MyType<T, ImplTarget> {
    MyType(PhantomData)
}

pub struct MyType<T, U>(PhantomData<(T, U)>);

pub struct ImplTarget;

pub trait MyTrait {
    type Assoc;
}

impl<T, U> MyTrait for MyType<T, U>
where
    U: HasSeveralImpls<T>,
{
    type Assoc = T;
}

pub trait HasSeveralImpls<T> {}

impl HasSeveralImpls<i32> for ImplTarget
{}

impl HasSeveralImpls<()> for ImplTarget
{}

impl<A> HasSeveralImpls<(A,)> for ImplTarget
where
    ImplTarget: HasSeveralImpls<A> 
{}

impl<A, B> HasSeveralImpls<(A, B)> for ImplTarget
where
    ImplTarget: HasSeveralImpls<A>,
    ImplTarget: HasSeveralImpls<B>,
{}

impl<A, B, C> HasSeveralImpls<(A, B, C)> for ImplTarget
where
    ImplTarget: HasSeveralImpls<A>,
    ImplTarget: HasSeveralImpls<B>,
    ImplTarget: HasSeveralImpls<C>,
{}

impl<A, B, C, D> HasSeveralImpls<(A, B, C, D)> for ImplTarget
where
    ImplTarget: HasSeveralImpls<A>,
    ImplTarget: HasSeveralImpls<B>,
    ImplTarget: HasSeveralImpls<C>,
    ImplTarget: HasSeveralImpls<D>,
{}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions