Skip to content

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

Closed
@jinxdash

Description

@jinxdash

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

Metadata

Metadata

Labels

A-parserparser issuesC-bugCategory: bugS-actionableSomeone could pick this issue up and work on it right now

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions