Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pnkfelix opened this issue Nov 18, 2014 · 1 comment · Fixed by #19087
Closed

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

pnkfelix opened this issue Nov 18, 2014 · 1 comment · Fixed by #19087

Comments

@pnkfelix
Copy link
Member

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),
    }
}
@pnkfelix
Copy link
Member Author

Nomating for P-backcompat-lang, 1.0

lnicola pushed a commit to lnicola/rust that referenced this issue Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant