Skip to content

rustc allows enum struct variants to be matched as if they were tuple variants #19086

Closed
@pnkfelix

Description

@pnkfelix

struct variants have been unfeature gated, but there are corner cases that we did not intend.

Here is (playpen compatible) code that demonstrates this:
link: http://is.gd/uUVO80

 #![feature(struct_variant)]

 fn main() {
    enum Foo {
        FooB { x: i32, y: i32 }
    }

    let f = FooB { x: 3, y: 4 };
    match f {
        // The pattern for the arm below is problematic.
        FooB(a, b) => println!("{} {}", a, b),
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions