Skip to content

Compiler stack overflow when calling function on generic struct with TAIT resolving to lambda #136390

Open
@Elekrisk

Description

@Elekrisk

I tried this code:

#![feature(type_alias_impl_trait)]

type X = impl FnOnce();

struct S<F>(F);

impl S<X> {
    fn new() -> Self {
        Self(|| {})
    }
}

fn main() {
    S::new();
}

I expected to see this happen: Compilation succeeds.

Instead, this happened: Compiler crashes with a stack overflow, although only in debug mode.

I ran this through cargo bisect-rustc and got the following:

Regression in rust-lang-ci@89bc42c
The PR introducing the regression in this rollup is #134081: Try to evaluate constants in legacy mangling

searched nightlies: from nightly-2024-10-11 to nightly-2025-02-01
regressed nightly: nightly-2024-12-15
searched commit range: 327c7ee...0aeaa5e
regressed commit: f1ec5d6

bisected with cargo-bisect-rustc v0.6.9

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start=2024-10-11 

I am guessing that the TAIT being in the symbol path of new messes something up with creating the mangled symbol name.

Meta

rustc --version --verbose:

rustc 1.86.0-nightly (854f22563 2025-01-31)
binary: rustc
commit-hash: 854f22563c8daf92709fae18ee6aed52953835cd
commit-date: 2025-01-31
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7
Backtrace

/home/elekrisk/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8cb71fa651fbc0f4.so(+0x37a6cc3) [0x705d645a6cc3]
/usr/lib/libc.so.6(+0x3d1d0) [0x705d60c4c1d0]
/home/elekrisk/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8cb71fa651fbc0f4.so(+0x5521865) [0x705d66321865]

### cycle encountered after 3 frames with period 5
/home/elekrisk/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8cb71fa651fbc0f4.so(+0x5520108) [0x705d66320108]
/home/elekrisk/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8cb71fa651fbc0f4.so(+0x55228a1) [0x705d663228a1]
/home/elekrisk/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8cb71fa651fbc0f4.so(+0x5521a2b) [0x705d66321a2b]
/home/elekrisk/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8cb71fa651fbc0f4.so(+0x5521a2b) [0x705d66321a2b]
/home/elekrisk/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8cb71fa651fbc0f4.so(+0x5522183) [0x705d66322183]
### recursed 50 times

/home/elekrisk/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8cb71fa651fbc0f4.so(+0x5520108) [0x705d66320108]
/home/elekrisk/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8cb71fa651fbc0f4.so(+0x55228a1) [0x705d663228a1]
/home/elekrisk/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8cb71fa651fbc0f4.so(+0x5521a2b) [0x705d66321a2b]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.S-has-bisectionStatus: a bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions