-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't havegood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
Summary
match_same_arms
lints on two arms, if the comments are different.
Lint Name
match_same_arms
Reproducer
I tried this code:
#![warn(clippy::pedantic)]
fn main() {
let test = Some(12);
match test {
Some(_) => {
// My explaination for something cool
println!("Test code");
},
None => {
// My explaination
println!("Test code");
},
}
}
I saw this happen:
warning: this match arm has an identical body to another arm
--> src/main.rs:10:9
|
10 | None => {
| ^---
| |
| _________help: try merging the arm patterns: `None | Some(_)`
| |
11 | | // My explaination
12 | | println!("Test code");
13 | | },
| |_________^
|
= help: or try changing either arm body
note: other arm here
--> src/main.rs:6:9
|
6 | / Some(_) => {
7 | | // My explaination for something cool
8 | | println!("Test code");
9 | | },
| |_________^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#match_same_arms
note: the lint level is defined here
--> src/main.rs:1:9
|
1 | #![warn(clippy::pedantic)]
| ^^^^^^^^^^^^^^^^
= note: `#[warn(clippy::match_same_arms)]` implied by `#[warn(clippy::pedantic)]`
I expected to see this happen:
No warning
Version
rustc 1.77.0-nightly (89e2160c4 2023-12-27)
binary: rustc
commit-hash: 89e2160c4ca5808657ed55392620ed1dbbce78d1
commit-date: 2023-12-27
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6
Additional Labels
These utils might be good to look at:
- https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.span_contains_comment.html
- https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.span_extract_comment.html
@rustbot label +good-first-issue
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't havegood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy