Skip to content

Compiler crash pattern matching unsized tuple in enum variant #37685

Closed
@CasualX

Description

@CasualX

I was trying to get an enum which owns some String or Vec<u8> be able to deref into an unsized enum whose variants have str or [u8] but this appears to be unsupported at the moment.

But I am persistent so I try to make the variants hold refs to their original owners but one of them is a tuple.

I found plenty of issues where tuples are also not allowed to have their tail unsized (which seems odd as tuple structs are perfectly fine having their last member unsized) but I tried it anyway in the context of an enum variant tuple.

I tried this code: playground

enum FooRef<'a> {
    A(&'a (str,))
}

fn foo(f: FooRef) {
    match f {
        FooRef::A(&(ref s,)) => (),
    }
}

fn main() {}

I expected to see this happen: A sane error about tuples not being allowed to have an unsized tail.

Instead, this happened: mysterious exit (error: Could not compile ... without any further explanation) with error code 3221225477. On the playground this results in Segmentation fault (core dumped).

As I wrote this I found out that the above example only breaks in Debug builds, Release builds print Program ended. on any Rust version on the playground.

Meta

rustc 1.12.0 (3191fbae9 2016-09-23)
binary: rustc
commit-hash: 3191fbae9da539442351f883bdabcad0d72efcb6
commit-date: 2016-09-23
host: x86_64-pc-windows-msvc
release: 1.12.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions