Skip to content

Compiler hang with recursive bound and generic impl on opaque type #150583

@trait-Cong

Description

@trait-Cong

I tried this code :

#![feature(type_alias_impl_trait)]

trait Base {}
impl Base for () {}

trait Link {}

type X
where
    X: Link,
= impl Base;

impl<T> Link for X {}

fn main() {
    let _: X = ();
}

I expected to see this happen: The compiler should report an error.

Instead, this happened: The compiler hangs indefinitely (infinite loop).

Meta

rustc --version --verbose:

rustc 1.91.0-nightly (f34ba774c 2025-08-03)
binary: rustc
commit-hash: f34ba774c78ea32b7c40598b8ad23e75cdac42a6
commit-date: 2025-08-03
host: x86_64-pc-windows-msvc
release: 1.91.0-nightly
LLVM version: 20.1.8
Backtrace

error[E0282]: type annotations needed
 --> example2.rs:8:1
  |
8 | type X
  | ^^^^^^ cannot infer type for type parameter `T`

then the process hangs

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemC-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`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.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions