2023-07-02 07:35:19 -05:00
|
|
|
#![feature(non_exhaustive_omitted_patterns_lint)]
|
|
|
|
#![warn(clippy::match_same_arms)]
|
|
|
|
#![no_main]
|
|
|
|
use std::sync::atomic::Ordering; // #[non_exhaustive] enum
|
|
|
|
|
2023-09-02 23:31:56 -05:00
|
|
|
fn repeat() -> ! {
|
|
|
|
panic!()
|
|
|
|
}
|
|
|
|
|
2023-07-02 07:35:19 -05:00
|
|
|
pub fn f(x: Ordering) {
|
2023-10-23 11:55:04 -05:00
|
|
|
#[deny(non_exhaustive_omitted_patterns)]
|
2023-07-02 07:35:19 -05:00
|
|
|
match x {
|
|
|
|
Ordering::Relaxed => println!("relaxed"),
|
|
|
|
Ordering::Release => println!("release"),
|
|
|
|
Ordering::Acquire => println!("acquire"),
|
2023-09-02 23:31:56 -05:00
|
|
|
Ordering::AcqRel | Ordering::SeqCst => repeat(),
|
|
|
|
_ => repeat(),
|
2023-07-02 07:35:19 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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"),
|
2023-09-02 23:31:56 -05:00
|
|
|
Ordering::AcqRel | Ordering::SeqCst => repeat(),
|
|
|
|
_ => repeat(),
|
2023-07-02 07:35:19 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Below should still lint
|
|
|
|
|
|
|
|
pub fn g(x: Ordering) {
|
|
|
|
match x {
|
|
|
|
Ordering::Relaxed => println!("relaxed"),
|
|
|
|
Ordering::Release => println!("release"),
|
|
|
|
Ordering::Acquire => println!("acquire"),
|
2023-09-02 23:31:56 -05:00
|
|
|
Ordering::AcqRel | Ordering::SeqCst => repeat(),
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: this match arm has an identical body to the `_` wildcard arm
|
2023-09-02 23:31:56 -05:00
|
|
|
_ => repeat(),
|
2023-07-02 07:35:19 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod g {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
pub fn g(x: Ordering) {
|
|
|
|
match x {
|
|
|
|
Ordering::Relaxed => println!("relaxed"),
|
|
|
|
Ordering::Release => println!("release"),
|
|
|
|
Ordering::Acquire => println!("acquire"),
|
2023-09-02 23:31:56 -05:00
|
|
|
Ordering::AcqRel | Ordering::SeqCst => repeat(),
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: this match arm has an identical body to the `_` wildcard arm
|
2023-09-02 23:31:56 -05:00
|
|
|
_ => repeat(),
|
2023-07-02 07:35:19 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|