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

Closed
dtolnay opened this issue Nov 5, 2023 · 0 comments · Fixed by #1662
Closed

Parse struct literals in match guards #1527

dtolnay opened this issue Nov 5, 2023 · 0 comments · Fixed by #1662
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant