Skip to content

rust-analyzer can't parse leading | in patterns #13094

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
jinxdash opened this issue Aug 23, 2022 · 0 comments · Fixed by #13096
Closed

rust-analyzer can't parse leading | in patterns #13094

jinxdash opened this issue Aug 23, 2022 · 0 comments · Fixed by #13096
Assignees
Labels
A-parser parser issues C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now

Comments

@jinxdash
Copy link

jinxdash commented Aug 23, 2022

rust-analyzer version: 0.3.1178-standalone (latest)

rustc version: 1.60.0

#[derive(Debug)]
enum KeyCode {
    Up,
    Down,
	Left,
}

fn main() {
    foo(KeyCode::Up);
}

fn foo(x: KeyCode) {
	if let (a @ (  KeyCode::Up | KeyCode::Down),) = (x,) {
		println!("{:?}", a);
	}
}

fn bar(x: KeyCode) {
	if let (a @ (| KeyCode::Up | KeyCode::Down),) = (x,) {
                  // ^ Syntax Error: expected a pattern rust-analyzer
		println!("{:?}", a);
	}
}

Actual: Syntax Error at leading | in fn bar

Expected: No Syntax Error (see rust spec)

EDIT: looks like this is a duplicate of #12894

@lnicola lnicola added S-actionable Someone could pick this issue up and work on it right now A-parser parser issues C-bug Category: bug labels Aug 23, 2022
@jonas-schievink jonas-schievink self-assigned this Aug 23, 2022
@bors bors closed this as completed in e73b7a9 Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser parser issues C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants