Skip to content

Hang : next-solver hang with recursive trait obligations involving type_alias_impl_trait #150989

Description

@trait-Cong

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

#![feature(type_alias_impl_trait)]
use std::fmt::Display;
type Opaque<X: Trait> = impl Sized + 'static;

#[define_opaque(Opaque)]
fn define<X>() -> Opaque<X> {}

trait Trait {
    type Assoc: Display;
}
impl<'a> Trait for Opaque<&'a str> {
    type Assoc = &'a str;
}

fn extend<T: Trait + 'static>(s: T::Assoc) -> Box<dyn Display> {
    Box::new(s)
}
fn main() {
    let val = extend::<Opaque<&'_ str>>(&String::from("blah blah blah"));
    println!("{}", val);
}

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

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

I expected to see this happen: The compiler should behave consistently across solvers. In particular, when using
-Znext-solver

Instead, this happened: The compiler hangs.

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

error[E0277]: the trait bound `X: Trait` is not satisfied
 --> results/hang/case_iter_1357_var_6/after.rs:5:19
  |
5 | fn define<X>() -> Opaque<X> {}
  |                   ^^^^^^^^^ the trait `Trait` is not implemented for `X`
  |
note: required by a bound in `Opaque`
 --> results/hang/case_iter_1357_var_6/after.rs:3:16
  |
3 | type Opaque<X: Trait> = impl Sized + 'static;
  |                ^^^^^ required by this bound in `Opaque`
help: consider restricting type parameter `X` with trait `Trait`
  |
5 | fn define<X: Trait>() -> Opaque<X> {}
  |            +++++++

error[E0277]: the trait bound `&'a str: Trait` is not satisfied
 --> results/hang/case_iter_1357_var_6/after.rs:9:20
  |
9 | impl<'a> Trait for Opaque<&'a str> {
  |                    ^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `&'a str`
  |
help: the trait `Trait` is implemented for `Opaque<&'a str>`
 --> results/hang/case_iter_1357_var_6/after.rs:9:1
  |
9 | impl<'a> Trait for Opaque<&'a str> {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
 --> results/hang/case_iter_1357_var_6/after.rs:9:6
  |
9 | impl<'a> Trait for Opaque<&'a str> {
  |      ^^ unconstrained lifetime parameter

Then the compiler hangs;

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jan 12, 2026
  2. feishiheng commented on Jan 12, 2026

    @feishiheng

    @rustbot label +T-compiler +I-hang

  3. added
    I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jan 12, 2026
  4. SpriteOvO commented on Jan 13, 2026

    @SpriteOvO
  5. added
    E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
    on Jan 13, 2026
  6. trait-Cong commented on Jan 13, 2026

    @trait-Cong
    Author
  7. SpriteOvO commented on Jan 13, 2026

    @SpriteOvO
    Member

    Reproduced now! ~

    UPDATE: I have edited the code in OP to the new MCVE.

    @rustbot label -E-needs-mcve +S-has-mcve

  8. added
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    and removed
    E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
    on Jan 13, 2026
  9. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jan 19, 2026
  10. trait-Cong commented on Apr 1, 2026

    @trait-Cong
    Author
  11. lcnr commented on Oct 8, 2026

    @lcnr
    Contributor

    this no longer hangs, should figure out the PR which fixed this and then maybe add a regression test if no relevant test for this exists yet

  12. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
    on Oct 8, 2026
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

    C-bugCategory: This is a bug.E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustcE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions