Skip to content

rustc does not detect incorrect (generic) enum structure and overflow its stack instead #100618

Closed
@aurantiaco-sucus

Description

@aurantiaco-sucus

I tried this code:

enum Foo<T: 'static> {
    Value(T),
    Recursive(&'static Foo<Option<T>>),
}

fn main() {
    let _x = Foo::Value(());
}

I expected to see this happen: rustc refuses to compile this enum and tell me this (definition) does not work

Instead, this happened: rustc overflows its stack and the compile process ends abruptly

Meta

rustc --version --verbose:

rustc 1.65.0-nightly (40336865f 2022-08-15)
binary: rustc
commit-hash: 40336865fe7d4a01139a3336639c6971647e885c
commit-date: 2022-08-15
host: x86_64-pc-windows-msvc
release: 1.65.0-nightly
LLVM version: 15.0.0
Backtrace

thread 'rustc' has overflowed its stack
warning: `whlist` (bin "whlist") generated 9 warnings
error: could not compile `whlist`; 9 warnings emitted

Caused by:
  process didn't exit successfully: `rustc --crate-name whlist --edition=2021 src\main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=0d4447f233920318 --out-dir C:\Users\raida\CLionProjects\whlist\target\debug\deps -C incremental=C:\Users\raida\CLionProjects\whlist\target\debug\incremental -L dependency=C:\Users\raida\CLionProjects\whlist\target\debug\deps` (exit code: 0xc00000fd, STATUS_STACK_OVERFLOW)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationC-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions