rust-lang / rust-lang/rust

next-solver hang: infinite recursion during hidden type inference for TAIT

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

Nobody has claimed this yet.

C-bug F-type_alias_impl_trait I-hang needs-triage WG-trait-system-refactor
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

I tried this code:(auto-reduced)

#![feature(type_alias_impl_trait)]
trait UnwrapItemsExt {
    type Iter;
}
trait MyTrait<'a> {}
impl<'a> MyTrait<'a> for <() as UnwrapItemsExt>::Iter {}
impl<'a, I> UnwrapItemsExt for I {
    type Iter = impl MyTrait<'a>;
    fn unwrap_items() -> Self::Iter {
    }
}
fn main(){}


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

rustc --version --verbose:

rustc 1.95.0-nightly (e96bb7e44 2026-01-27)
binary: rustc
commit-hash: e96bb7e44fbcc23c1e6009e8d0ee8ab208668fb4
commit-date: 2026-01-27
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 21.1.8
Backtrace

error[E0407]: method `unwrap_items` is not a member of trait `UnwrapItemsExt`
  --> bug.rs:9:5
   |
 9 | /     fn unwrap_items() -> Self::Iter {
10 | |     }
   | |_____^ not a member of trait `UnwrapItemsExt`

error[E0658]: `impl Trait` in associated types is unstable
 --> bug.rs:8:17
  |
8 |     type Iter = impl MyTrait<'a>;
  |                 ^^^^^^^^^^^^^^^^
  |
  = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
  = help: add `#![feature(impl_trait_in_assoc_type)]` to the crate attributes to enable
  = note: this compiler was built on 2026-01-27; consider upgrading it if it is out of date

error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
 --> bug.rs:7:6
  |
7 | impl<'a, I> UnwrapItemsExt for I {
  |      ^^ unconstrained lifetime parameter

hang.

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

Reproduce the minimized case in bug.rs with a nightly rustc and -Znext-solver=globally, then compare it with the default solver's diagnostics. Trace the hidden type inference path for TAIT to identify the recursion, and consider how to cover this reproducer in compiler regression testing. Done means the case terminates with an appropriate error instead of hanging.

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
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.