about summary refs log tree commit diff
diff options
context:
space:
mode:
authormark <markm@cs.wisc.edu>2020-11-21 15:22:32 -0600
committermark <markm@cs.wisc.edu>2021-03-19 19:45:42 -0500
commitd2f0b27f0a2c5821a966ee2a02c6ba7191a27fe7 (patch)
tree9b1ded1166ef4634d72bee481a462b7e94910e8d
parent2c4570c9587b5b41955b6664046de1fc335c0a05 (diff)
downloadrust-d2f0b27f0a2c5821a966ee2a02c6ba7191a27fe7.tar.gz
rust-d2f0b27f0a2c5821a966ee2a02c6ba7191a27fe7.zip
clippy: stabilize or_patterns lint
-rw-r--r--clippy_lints/src/lib.rs2
-rw-r--r--clippy_lints/src/unnested_or_patterns.rs5
-rw-r--r--clippy_utils/src/lib.rs2
-rw-r--r--tests/ui/unnested_or_patterns.fixed1
-rw-r--r--tests/ui/unnested_or_patterns.rs1
-rw-r--r--tests/ui/unnested_or_patterns.stderr32
-rw-r--r--tests/ui/unnested_or_patterns2.fixed1
-rw-r--r--tests/ui/unnested_or_patterns2.rs1
-rw-r--r--tests/ui/unnested_or_patterns2.stderr16
-rw-r--r--tests/ui/unnested_or_patterns3.rs6
-rw-r--r--tests/ui/while_let_on_iterator.fixed1
-rw-r--r--tests/ui/while_let_on_iterator.rs1
-rw-r--r--tests/ui/while_let_on_iterator.stderr14
13 files changed, 33 insertions, 50 deletions
diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs
index 04e151df8e8..b4c450bda5c 100644
--- a/clippy_lints/src/lib.rs
+++ b/clippy_lints/src/lib.rs
@@ -5,7 +5,7 @@
 #![feature(drain_filter)]
 #![feature(in_band_lifetimes)]
 #![feature(once_cell)]
-#![feature(or_patterns)]
+#![cfg_attr(bootstrap, feature(or_patterns))]
 #![feature(rustc_private)]
 #![feature(stmt_expr_attributes)]
 #![feature(control_flow_enum)]
diff --git a/clippy_lints/src/unnested_or_patterns.rs b/clippy_lints/src/unnested_or_patterns.rs
index fa613bb7da3..5826e9a4aa5 100644
--- a/clippy_lints/src/unnested_or_patterns.rs
+++ b/clippy_lints/src/unnested_or_patterns.rs
@@ -72,11 +72,6 @@ impl EarlyLintPass for UnnestedOrPatterns {
 }
 
 fn lint_unnested_or_patterns(cx: &EarlyContext<'_>, pat: &Pat) {
-    if !cx.sess.features_untracked().or_patterns {
-        // Do not suggest nesting the patterns if the feature `or_patterns` is not enabled.
-        return;
-    }
-
     if let Ident(.., None) | Lit(_) | Wild | Path(..) | Range(..) | Rest | MacCall(_) = pat.kind {
         // This is a leaf pattern, so cloning is unprofitable.
         return;
diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs
index d81b89dd001..7d3584333af 100644
--- a/clippy_utils/src/lib.rs
+++ b/clippy_utils/src/lib.rs
@@ -1,6 +1,6 @@
 #![feature(box_patterns)]
 #![feature(in_band_lifetimes)]
-#![feature(or_patterns)]
+#![cfg_attr(bootstrap, feature(or_patterns))]
 #![feature(rustc_private)]
 #![recursion_limit = "512"]
 #![allow(clippy::missing_errors_doc, clippy::missing_panics_doc, clippy::must_use_candidate)]
diff --git a/tests/ui/unnested_or_patterns.fixed b/tests/ui/unnested_or_patterns.fixed
index 13a036cd800..46463a29e9b 100644
--- a/tests/ui/unnested_or_patterns.fixed
+++ b/tests/ui/unnested_or_patterns.fixed
@@ -1,6 +1,5 @@
 // run-rustfix
 
-#![feature(or_patterns)]
 #![feature(box_patterns)]
 #![warn(clippy::unnested_or_patterns)]
 #![allow(clippy::cognitive_complexity, clippy::match_ref_pats, clippy::upper_case_acronyms)]
diff --git a/tests/ui/unnested_or_patterns.rs b/tests/ui/unnested_or_patterns.rs
index 4a10cc702c4..8ce0738bfc2 100644
--- a/tests/ui/unnested_or_patterns.rs
+++ b/tests/ui/unnested_or_patterns.rs
@@ -1,6 +1,5 @@
 // run-rustfix
 
-#![feature(or_patterns)]
 #![feature(box_patterns)]
 #![warn(clippy::unnested_or_patterns)]
 #![allow(clippy::cognitive_complexity, clippy::match_ref_pats, clippy::upper_case_acronyms)]
diff --git a/tests/ui/unnested_or_patterns.stderr b/tests/ui/unnested_or_patterns.stderr
index 1899dc657df..f7cb513c15c 100644
--- a/tests/ui/unnested_or_patterns.stderr
+++ b/tests/ui/unnested_or_patterns.stderr
@@ -1,5 +1,5 @@
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns.rs:10:12
+  --> $DIR/unnested_or_patterns.rs:9:12
    |
 LL |     if let box 0 | box 2 = Box::new(0) {}
    |            ^^^^^^^^^^^^^
@@ -11,7 +11,7 @@ LL |     if let box (0 | 2) = Box::new(0) {}
    |            ^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns.rs:11:12
+  --> $DIR/unnested_or_patterns.rs:10:12
    |
 LL |     if let box ((0 | 1)) | box (2 | 3) | box 4 = Box::new(0) {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -22,7 +22,7 @@ LL |     if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns.rs:13:12
+  --> $DIR/unnested_or_patterns.rs:12:12
    |
 LL |     if let &0 | C0 | &2 = &0 {}
    |            ^^^^^^^^^^^^
@@ -33,7 +33,7 @@ LL |     if let &(0 | 2) | C0 = &0 {}
    |            ^^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns.rs:14:12
+  --> $DIR/unnested_or_patterns.rs:13:12
    |
 LL |     if let &mut 0 | &mut 2 = &mut 0 {}
    |            ^^^^^^^^^^^^^^^
@@ -44,7 +44,7 @@ LL |     if let &mut (0 | 2) = &mut 0 {}
    |            ^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns.rs:15:12
+  --> $DIR/unnested_or_patterns.rs:14:12
    |
 LL |     if let x @ 0 | x @ 2 = 0 {}
    |            ^^^^^^^^^^^^^
@@ -55,7 +55,7 @@ LL |     if let x @ (0 | 2) = 0 {}
    |            ^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns.rs:16:12
+  --> $DIR/unnested_or_patterns.rs:15:12
    |
 LL |     if let (0, 1) | (0, 2) | (0, 3) = (0, 0) {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -66,7 +66,7 @@ LL |     if let (0, 1 | 2 | 3) = (0, 0) {}
    |            ^^^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns.rs:17:12
+  --> $DIR/unnested_or_patterns.rs:16:12
    |
 LL |     if let (1, 0) | (2, 0) | (3, 0) = (0, 0) {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -77,7 +77,7 @@ LL |     if let (1 | 2 | 3, 0) = (0, 0) {}
    |            ^^^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns.rs:18:12
+  --> $DIR/unnested_or_patterns.rs:17:12
    |
 LL |     if let (x, ..) | (x, 1) | (x, 2) = (0, 1) {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -88,7 +88,7 @@ LL |     if let (x, ..) | (x, 1 | 2) = (0, 1) {}
    |            ^^^^^^^^^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns.rs:19:12
+  --> $DIR/unnested_or_patterns.rs:18:12
    |
 LL |     if let [0] | [1] = [0] {}
    |            ^^^^^^^^^
@@ -99,7 +99,7 @@ LL |     if let [0 | 1] = [0] {}
    |            ^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns.rs:20:12
+  --> $DIR/unnested_or_patterns.rs:19:12
    |
 LL |     if let [x, 0] | [x, 1] = [0, 1] {}
    |            ^^^^^^^^^^^^^^^
@@ -110,7 +110,7 @@ LL |     if let [x, 0 | 1] = [0, 1] {}
    |            ^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns.rs:21:12
+  --> $DIR/unnested_or_patterns.rs:20:12
    |
 LL |     if let [x, 0] | [x, 1] | [x, 2] = [0, 1] {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -121,7 +121,7 @@ LL |     if let [x, 0 | 1 | 2] = [0, 1] {}
    |            ^^^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns.rs:22:12
+  --> $DIR/unnested_or_patterns.rs:21:12
    |
 LL |     if let [x, ..] | [x, 1] | [x, 2] = [0, 1] {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -132,7 +132,7 @@ LL |     if let [x, ..] | [x, 1 | 2] = [0, 1] {}
    |            ^^^^^^^^^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns.rs:24:12
+  --> $DIR/unnested_or_patterns.rs:23:12
    |
 LL |     if let TS(0, x) | TS(1, x) = TS(0, 0) {}
    |            ^^^^^^^^^^^^^^^^^^^
@@ -143,7 +143,7 @@ LL |     if let TS(0 | 1, x) = TS(0, 0) {}
    |            ^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns.rs:25:12
+  --> $DIR/unnested_or_patterns.rs:24:12
    |
 LL |     if let TS(1, 0) | TS(2, 0) | TS(3, 0) = TS(0, 0) {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -154,7 +154,7 @@ LL |     if let TS(1 | 2 | 3, 0) = TS(0, 0) {}
    |            ^^^^^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns.rs:26:12
+  --> $DIR/unnested_or_patterns.rs:25:12
    |
 LL |     if let TS(x, ..) | TS(x, 1) | TS(x, 2) = TS(0, 0) {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -165,7 +165,7 @@ LL |     if let TS(x, ..) | TS(x, 1 | 2) = TS(0, 0) {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns.rs:31:12
+  --> $DIR/unnested_or_patterns.rs:30:12
    |
 LL |     if let S { x: 0, y } | S { y, x: 1 } = (S { x: 0, y: 1 }) {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/unnested_or_patterns2.fixed b/tests/ui/unnested_or_patterns2.fixed
index 02a129c55a3..d3539d79815 100644
--- a/tests/ui/unnested_or_patterns2.fixed
+++ b/tests/ui/unnested_or_patterns2.fixed
@@ -1,6 +1,5 @@
 // run-rustfix
 
-#![feature(or_patterns)]
 #![feature(box_patterns)]
 #![warn(clippy::unnested_or_patterns)]
 #![allow(clippy::cognitive_complexity, clippy::match_ref_pats)]
diff --git a/tests/ui/unnested_or_patterns2.rs b/tests/ui/unnested_or_patterns2.rs
index acf3158989d..9cea5cdea69 100644
--- a/tests/ui/unnested_or_patterns2.rs
+++ b/tests/ui/unnested_or_patterns2.rs
@@ -1,6 +1,5 @@
 // run-rustfix
 
-#![feature(or_patterns)]
 #![feature(box_patterns)]
 #![warn(clippy::unnested_or_patterns)]
 #![allow(clippy::cognitive_complexity, clippy::match_ref_pats)]
diff --git a/tests/ui/unnested_or_patterns2.stderr b/tests/ui/unnested_or_patterns2.stderr
index 1847fd8e098..9042c9c00b1 100644
--- a/tests/ui/unnested_or_patterns2.stderr
+++ b/tests/ui/unnested_or_patterns2.stderr
@@ -1,5 +1,5 @@
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns2.rs:10:12
+  --> $DIR/unnested_or_patterns2.rs:9:12
    |
 LL |     if let Some(Some(0)) | Some(Some(1)) = None {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -11,7 +11,7 @@ LL |     if let Some(Some(0 | 1)) = None {}
    |            ^^^^^^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns2.rs:11:12
+  --> $DIR/unnested_or_patterns2.rs:10:12
    |
 LL |     if let Some(Some(0)) | Some(Some(1) | Some(2)) = None {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -22,7 +22,7 @@ LL |     if let Some(Some(0 | 1 | 2)) = None {}
    |            ^^^^^^^^^^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns2.rs:12:12
+  --> $DIR/unnested_or_patterns2.rs:11:12
    |
 LL |     if let Some(Some(0 | 1) | Some(2)) | Some(Some(3) | Some(4)) = None {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -33,7 +33,7 @@ LL |     if let Some(Some(0 | 1 | 2 | 3 | 4)) = None {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns2.rs:13:12
+  --> $DIR/unnested_or_patterns2.rs:12:12
    |
 LL |     if let Some(Some(0) | Some(1 | 2)) = None {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -44,7 +44,7 @@ LL |     if let Some(Some(0 | 1 | 2)) = None {}
    |            ^^^^^^^^^^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns2.rs:14:12
+  --> $DIR/unnested_or_patterns2.rs:13:12
    |
 LL |     if let ((0,),) | ((1,) | (2,),) = ((0,),) {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -55,7 +55,7 @@ LL |     if let ((0 | 1 | 2,),) = ((0,),) {}
    |            ^^^^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns2.rs:15:12
+  --> $DIR/unnested_or_patterns2.rs:14:12
    |
 LL |     if let 0 | (1 | 2) = 0 {}
    |            ^^^^^^^^^^^
@@ -66,7 +66,7 @@ LL |     if let 0 | 1 | 2 = 0 {}
    |            ^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns2.rs:16:12
+  --> $DIR/unnested_or_patterns2.rs:15:12
    |
 LL |     if let box (0 | 1) | (box 2 | box (3 | 4)) = Box::new(0) {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -77,7 +77,7 @@ LL |     if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^
 
 error: unnested or-patterns
-  --> $DIR/unnested_or_patterns2.rs:17:12
+  --> $DIR/unnested_or_patterns2.rs:16:12
    |
 LL |     if let box box 0 | box (box 2 | box 4) = Box::new(Box::new(0)) {}
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/unnested_or_patterns3.rs b/tests/ui/unnested_or_patterns3.rs
deleted file mode 100644
index 6bd35057bfa..00000000000
--- a/tests/ui/unnested_or_patterns3.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-#![warn(clippy::unnested_or_patterns)]
-
-// Test that `unnested_or_patterns` does not trigger without enabling `or_patterns`
-fn main() {
-    if let (0, 1) | (0, 2) | (0, 3) = (0, 0) {}
-}
diff --git a/tests/ui/while_let_on_iterator.fixed b/tests/ui/while_let_on_iterator.fixed
index e99c98ac79f..749393db124 100644
--- a/tests/ui/while_let_on_iterator.fixed
+++ b/tests/ui/while_let_on_iterator.fixed
@@ -2,7 +2,6 @@
 
 #![warn(clippy::while_let_on_iterator)]
 #![allow(clippy::never_loop, unreachable_code, unused_mut)]
-#![feature(or_patterns)]
 
 fn base() {
     let mut iter = 1..20;
diff --git a/tests/ui/while_let_on_iterator.rs b/tests/ui/while_let_on_iterator.rs
index ba13172428e..30e3b82a7cc 100644
--- a/tests/ui/while_let_on_iterator.rs
+++ b/tests/ui/while_let_on_iterator.rs
@@ -2,7 +2,6 @@
 
 #![warn(clippy::while_let_on_iterator)]
 #![allow(clippy::never_loop, unreachable_code, unused_mut)]
-#![feature(or_patterns)]
 
 fn base() {
     let mut iter = 1..20;
diff --git a/tests/ui/while_let_on_iterator.stderr b/tests/ui/while_let_on_iterator.stderr
index aa980d9965c..6554977c798 100644
--- a/tests/ui/while_let_on_iterator.stderr
+++ b/tests/ui/while_let_on_iterator.stderr
@@ -1,5 +1,5 @@
 error: this loop could be written as a `for` loop
-  --> $DIR/while_let_on_iterator.rs:9:5
+  --> $DIR/while_let_on_iterator.rs:8:5
    |
 LL |     while let Option::Some(x) = iter.next() {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in iter`
@@ -7,37 +7,37 @@ LL |     while let Option::Some(x) = iter.next() {
    = note: `-D clippy::while-let-on-iterator` implied by `-D warnings`
 
 error: this loop could be written as a `for` loop
-  --> $DIR/while_let_on_iterator.rs:14:5
+  --> $DIR/while_let_on_iterator.rs:13:5
    |
 LL |     while let Some(x) = iter.next() {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in iter`
 
 error: this loop could be written as a `for` loop
-  --> $DIR/while_let_on_iterator.rs:19:5
+  --> $DIR/while_let_on_iterator.rs:18:5
    |
 LL |     while let Some(_) = iter.next() {}
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in iter`
 
 error: this loop could be written as a `for` loop
-  --> $DIR/while_let_on_iterator.rs:102:9
+  --> $DIR/while_let_on_iterator.rs:101:9
    |
 LL |         while let Some([..]) = it.next() {}
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for [..] in it`
 
 error: this loop could be written as a `for` loop
-  --> $DIR/while_let_on_iterator.rs:109:9
+  --> $DIR/while_let_on_iterator.rs:108:9
    |
 LL |         while let Some([_x]) = it.next() {}
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for [_x] in it`
 
 error: this loop could be written as a `for` loop
-  --> $DIR/while_let_on_iterator.rs:122:9
+  --> $DIR/while_let_on_iterator.rs:121:9
    |
 LL |         while let Some(x @ [_]) = it.next() {
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x @ [_] in it`
 
 error: this loop could be written as a `for` loop
-  --> $DIR/while_let_on_iterator.rs:154:9
+  --> $DIR/while_let_on_iterator.rs:153:9
    |
 LL |         while let Some(_) = y.next() {
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in y`