-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #10946 - Centri3:match_same_arms, r=blyxyas,xFrednet
[`match_same_arms`]: don't lint if `non_exhaustive_omitted_patterns` Fixes #10327 changelog: [`match_same_arms`]: Don't lint if `non_exhaustive_omitted_patterns` is `warn` or `deny`
- Loading branch information
Showing
4 changed files
with
107 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#![feature(non_exhaustive_omitted_patterns_lint)] | ||
#![warn(clippy::match_same_arms)] | ||
#![no_main] | ||
|
||
use std::sync::atomic::Ordering; // #[non_exhaustive] enum | ||
|
||
pub fn f(x: Ordering) { | ||
match x { | ||
Ordering::Relaxed => println!("relaxed"), | ||
Ordering::Release => println!("release"), | ||
Ordering::Acquire => println!("acquire"), | ||
Ordering::AcqRel | Ordering::SeqCst => panic!(), | ||
#[deny(non_exhaustive_omitted_patterns)] | ||
_ => panic!(), | ||
} | ||
} | ||
|
||
mod f { | ||
#![deny(non_exhaustive_omitted_patterns)] | ||
|
||
use super::*; | ||
|
||
pub fn f(x: Ordering) { | ||
match x { | ||
Ordering::Relaxed => println!("relaxed"), | ||
Ordering::Release => println!("release"), | ||
Ordering::Acquire => println!("acquire"), | ||
Ordering::AcqRel | Ordering::SeqCst => panic!(), | ||
_ => panic!(), | ||
} | ||
} | ||
} | ||
|
||
// Below should still lint | ||
|
||
pub fn g(x: Ordering) { | ||
match x { | ||
Ordering::Relaxed => println!("relaxed"), | ||
Ordering::Release => println!("release"), | ||
Ordering::Acquire => println!("acquire"), | ||
Ordering::AcqRel | Ordering::SeqCst => panic!(), | ||
_ => panic!(), | ||
} | ||
} | ||
|
||
mod g { | ||
use super::*; | ||
|
||
pub fn g(x: Ordering) { | ||
match x { | ||
Ordering::Relaxed => println!("relaxed"), | ||
Ordering::Release => println!("release"), | ||
Ordering::Acquire => println!("acquire"), | ||
Ordering::AcqRel | Ordering::SeqCst => panic!(), | ||
_ => panic!(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
error: this match arm has an identical body to the `_` wildcard arm | ||
--> $DIR/match_same_arms_non_exhaustive.rs:41:9 | ||
| | ||
LL | Ordering::AcqRel | Ordering::SeqCst => panic!(), | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the arm | ||
| | ||
= help: or try changing either arm body | ||
note: `_` wildcard arm here | ||
--> $DIR/match_same_arms_non_exhaustive.rs:42:9 | ||
| | ||
LL | _ => panic!(), | ||
| ^^^^^^^^^^^^^ | ||
= note: `-D clippy::match-same-arms` implied by `-D warnings` | ||
|
||
error: this match arm has an identical body to the `_` wildcard arm | ||
--> $DIR/match_same_arms_non_exhaustive.rs:54:13 | ||
| | ||
LL | Ordering::AcqRel | Ordering::SeqCst => panic!(), | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try removing the arm | ||
| | ||
= help: or try changing either arm body | ||
note: `_` wildcard arm here | ||
--> $DIR/match_same_arms_non_exhaustive.rs:55:13 | ||
| | ||
LL | _ => panic!(), | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|