Skip to content
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

Parse struct literals in match guards #1527

Open
dtolnay opened this issue Nov 5, 2023 · 0 comments
Open

Parse struct literals in match guards #1527

dtolnay opened this issue Nov 5, 2023 · 0 comments
Labels

Comments

@dtolnay
Copy link
Owner

dtolnay commented Nov 5, 2023

Unlike if condition, match guards accept struct literals.

Syn currently fails to parse it.

#![feature(if_let_guard)]

#[derive(PartialEq)]
struct Foo {
    x: isize,
}

fn foo(f: Foo) {
    match () {
        () if f == Foo { x: 42 } => {}
        () if let Foo { x: 0.. } = Foo { x: 42 } => {}
        _ => {}
    }
}
error: expected `=>`
  --> dev/main.rs:11:40
   |
11 |         () if let Foo { x: 0.. } = Foo { x: 42 } => {}
   |                                        ^

Tracking issue: rust-lang/rust#51114

@dtolnay dtolnay added the syntax label Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant