`match` matching ignores the branches enum variant names
Ten0 opened this issue · comments
Thomas B commented
Describe the bug
In semgrep's Rust matching, match
matching ignores the branches enum variant names
To Reproduce
https://semgrep.dev/playground/s/ZqJ1W
rules:
- id: my_pattern_id
languages:
- rust
severity: ERROR
message: Semgrep found a match
pattern: match ... { Ok(_) => ..., Err(_) => ... }
match f() {
Abc(_) => {}
Def(_) => {}
}
Expected behavior
Does not match
What is the priority of the bug to you?
- P0: blocking your adoption of Semgrep or workflow
- P1: important to fix or quite annoying
- P2: regular bug that should get fixed
Use case
CI makes good practices check based on semgrep. We want to forbid underscore-matching both the Ok and Err variant of a result, but this creates a lot of false positives.