about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-11-04 14:33:39 +0000
committerbors <bors@rust-lang.org>2023-11-04 14:33:39 +0000
commitf81d6f0cb00b1e314107b81bcb9aa72b9df9f564 (patch)
tree513b8276ab23493ffd10aef05f7d9d8a916c2660 /src
parent2db26d3d55387930f1b1dfb84810bcde5a787a09 (diff)
parentf0e83308791698b47a738c8fe0a762624c88a2e0 (diff)
Auto merge of #117094 - Nadrieril:warn-lint-on-arm, r=cjgillot
Warn users who set `non_exhaustive_omitted_patterns` lint level on a match arm

Before https://github.com/rust-lang/rust/pull/116734, the recommended usage of the [`non_exhaustive_omitted_patterns` lint](https://github.com/rust-lang/rust/issues/89554) was:
```rust
match Bar::A {
    Bar::A => {},
    #[warn(non_exhaustive_omitted_patterns)]
    _ => {},
}
```
After https://github.com/rust-lang/rust/pull/116734 this no longer makes sense, and recommended usage is now:
```rust
#[warn(non_exhaustive_omitted_patterns)]
match Bar::A {
    Bar::A => {},
    _ => {},
}
```

As you can guess, this silently breaks all uses of the lint that used the previous form. This is a problem in particular because `syn` recommends usage of this lint to its users in the old way. This PR emits a warning when the previous form is used so users can update.

r? `@cjgillot`
Diffstat (limited to 'src')
-rw-r--r--src/tools/clippy/tests/ui/match_same_arms_non_exhaustive.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/tools/clippy/tests/ui/match_same_arms_non_exhaustive.rs b/src/tools/clippy/tests/ui/match_same_arms_non_exhaustive.rs
index e1b95aa5776..5c277f925a8 100644
--- a/src/tools/clippy/tests/ui/match_same_arms_non_exhaustive.rs
+++ b/src/tools/clippy/tests/ui/match_same_arms_non_exhaustive.rs
@@ -9,12 +9,12 @@ fn repeat() -> ! {
 }
 
 pub fn f(x: Ordering) {
+    #[deny(non_exhaustive_omitted_patterns)]
     match x {
         Ordering::Relaxed => println!("relaxed"),
         Ordering::Release => println!("release"),
         Ordering::Acquire => println!("acquire"),
         Ordering::AcqRel | Ordering::SeqCst => repeat(),
-        #[deny(non_exhaustive_omitted_patterns)]
         _ => repeat(),
     }
 }