Skip to content

rustc appears to hang on this RPITIT example #159051

Open

Description

@623637646

I found a small example where rustc appear to hang during type checking.

pub struct BoundDropDisposal<D>(D);

pub trait Observable {
    fn subscribe<OR>(self, observer: OR) -> BoundDropDisposal<impl Clone>;
}

fn test(source: impl Observable) {
    subscribe_unsub_after_termination(|observer| {
        source.subscribe(observer)
    });
}

pub fn subscribe_unsub_after_termination<D, F>(_builder: F)
where
    F: FnOnce(D) -> BoundDropDisposal<D>,
{
}

Running this does not finish for me and keeps CPU busy:

timeout 10 rustc --crate-type lib lib.rs

With the next solver, it reports an error immediately:

rustc +nightly -Znext-solver=globally --crate-type lib lib.rs
error[E0271]: type mismatch resolving `impl Clone == impl Clone`
 --> lib.rs:9:26
  |
9 |         source.subscribe(observer)
  |                          ^^^^^^^^ types differ

So I expected the current solver to also terminate with a type error instead of continuing to run.

Toolchain:

rustc 1.97.0 (2d8144b78 2026-07-07)
binary: rustc
commit-hash: 2d8144b7880597b6e6d3dfd63a9a9efae3f533d3
commit-date: 2026-07-07
host: aarch64-apple-darwin
release: 1.97.0
LLVM version: 22.1.6

Activity

  1. added
    needs-triage
    on Jul 10, 2026
  2. added
    fixed-by-next-solver
    on Jul 10, 2026
  3. workingjubilee commented on Jul 10, 2026

    @workingjubilee
    Member

    With the next solver, it reports an error immediately:

    So I expected the current solver to also terminate with a type error instead of continuing to run.

    That is indeed why we are making the next solver. It is not a mere "upgrade", the old one is deeply flawed, so this may or may not be fixed as fixing it may or may not even be possible. I'm not sure. Types will know/decide/shrug and carry on as they see fit.

  4. added
    A-trait-system
    T-types
    I-hang
    C-bug
    and removed
    needs-triage
    on Jul 10, 2026
  5. zakrad commented on Sep 28, 2026

    @zakrad
    Contributor

    This no longer hangs since nightly-2026-07-28, looks like fixed by #159774, which added regression tests for the same no-progress cycle. Can this be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemC-bugI-hangT-typesfixed-by-next-solver

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions