Stack overflow from closure TAIT in a method on the opaque type itself with recursion
Open
Nobody has claimed this yet.
C-bug
F-type_alias_impl_trait
I-crash
I-ICE
S-has-mcve
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
#![feature(type_alias_impl_trait)]
#![allow(incomplete_features)]
type Opaque = impl Sized;
trait Trait {
fn foo();
}
impl Trait for Opaque {
#[define_opaque(Opaque)]
fn foo() {
let _: Opaque = || {};
Opaque::foo();
}
}
fn main() {
Opaque::foo();
}
@rustbot labels +F-type_alias_impl_trait +I-crash
This is similar to https://github.com/rust-lang/rust/issues/144832, but this one happens in both debug mode and release mode.
Meta
Reproducible on the playground with version version: 1.90.0-nightly (2025-08-01 4b55fe199cfe9c710555)
Error output
error: rustc interrupted by SIGSEGV, printing backtrace
Backtrace
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x3c8efcf)[0x7bf11da8efcf]
/lib/x86_64-linux-gnu/libc.so.6(+0x45330)[0x7bf119c33330]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x67e3c7c)[0x7bf1205e3c7c]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e2959d)[0x7bf11fc2959d]
### cycle encountered after 4 frames with period 6
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e256f8)[0x7bf11fc256f8]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e256f8)[0x7bf11fc256f8]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e29171)[0x7bf11fc29171]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e256f8)[0x7bf11fc256f8]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e256f8)[0x7bf11fc256f8]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e29171)[0x7bf11fc29171]
### recursed 42 times
note: rustc unexpectedly overflowed its stack! this is a bug
note: maximum backtrace depth reached, frames may have been lost
note: we would appreciate a report at https://github.com/rust-lang/rust
help: you can increase rustc's stack size by setting RUST_MIN_STACK=16777216
error: could not compile `playground` (bin "playground")
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 by compiling the provided reproducer with the specified nightly Rust version and inspect the type_alias_impl_trait handling around the recursive Opaque::foo call. Confirm the compiler no longer overflows its stack or crashes, while preserving appropriate diagnostics or successful compilation behavior for the example.
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
- Clearly specified
- Newbie friendliness
- 35/100