Hang : next-solver hang with recursive trait obligations involving type_alias_impl_trait
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproducer in results/hang/case_iter_1357_var_6/after.rs and run it on nightly with -Znext-solver=globally, comparing it with the default solver behavior reported in the issue. Trace the next-solver handling of the recursive trait obligations involving type_alias_impl_trait; done means the reproducer no longer hangs and the solver behavior is consistent across the listed modes.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100