rust-lang / rust-lang/rust-analyzer
Rust Analyzer false positive: "expected pattern" in match expression 🐛
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Summary
The Rust Analyzer extension shows Syntax Error: expected pattern, when an unbounded RangeFrom range pattern is already present.
See line 24 below. Line 26 is already correct.
let x = 5;
let y: i32 = 0;
let z = 5;
match x {
z => {
println!("It's five!");
}
6.. if y == 1 => {
}
6.. {
}
}
Expected Behavior
Rust Analyzer should display only the error "Expected: FAT_ARROW".
Actual Behavior
Rust Analyzer displays two errors:
- Expected: FAT_ARROW
- expected pattern
rust-analyzer version: v0.3.1623
rustc version: rustc 1.70.0 (90c541806 2023-05-31)
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with the Rust match-expression snippet and compare the diagnostics around the unbounded range pattern. No source file or test is named, so locate the parser or diagnostic entry point for match expressions first. Done means the reproduction shows only the expected FAT_ARROW error without the false “expected pattern” diagnostic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100