Skip to content

Stack overflow from closure TAIT in a method on the opaque type itself in debug mode #144832

@theemathas

Description

@theemathas

Code

#![feature(type_alias_impl_trait)]

type Opaque = impl Sized;

trait Trait {
    fn foo();
}

impl Trait for Opaque {
    #[define_opaque(Opaque)]
    fn foo() {
        let _: Opaque = || {};
    }
}

fn main() {
    Opaque::foo();
}

@rustbot labels +F-type_alias_impl_trait +I-crash

Crash only occurs when compiling in debug mode

Possibly related to #136390

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)[0x7e5504e8efcf]
/lib/x86_64-linux-gnu/libc.so.6(+0x45330)[0x7e550102e330]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x67e3c7c)[0x7e55079e3c7c]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e2959d)[0x7e550702959d]

### cycle encountered after 4 frames with period 6
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e256f8)[0x7e55070256f8]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e256f8)[0x7e55070256f8]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e29171)[0x7e5507029171]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e256f8)[0x7e55070256f8]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e256f8)[0x7e55070256f8]
/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-2a52e13f9d86ed3d.so(+0x5e29171)[0x7e5507029171]
### 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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions