about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui
diff options
context:
space:
mode:
authorflip1995 <hello@philkrones.com>2021-01-30 18:06:34 +0100
committerflip1995 <hello@philkrones.com>2021-01-30 18:06:34 +0100
commit21758bf1fbeb0993fe39daf073b4bf883d36e779 (patch)
tree24e6ce5e1552a540571c7f92c951254e1e0b2119 /src/tools/clippy/tests/ui
parent7ce1b3b24491cbe10669cbe2b5733c2fe7cfe5b7 (diff)
parent95c0459217d1661edfa794c8bb122452b92fb485 (diff)
downloadrust-21758bf1fbeb0993fe39daf073b4bf883d36e779.tar.gz
rust-21758bf1fbeb0993fe39daf073b4bf883d36e779.zip
Merge commit '95c0459217d1661edfa794c8bb122452b92fb485' into clippyup
Diffstat (limited to 'src/tools/clippy/tests/ui')
-rw-r--r--src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.rs44
-rw-r--r--src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.stderr43
-rw-r--r--src/tools/clippy/tests/ui/collapsible_match2.rs29
-rw-r--r--src/tools/clippy/tests/ui/collapsible_match2.stderr38
-rw-r--r--src/tools/clippy/tests/ui/complex_types.rs2
-rw-r--r--src/tools/clippy/tests/ui/complex_types.stderr2
-rw-r--r--src/tools/clippy/tests/ui/crashes/ice-6256.rs1
-rw-r--r--src/tools/clippy/tests/ui/crashes/ice-6256.stderr6
-rw-r--r--src/tools/clippy/tests/ui/crashes/ice-6539.rs16
-rw-r--r--src/tools/clippy/tests/ui/deprecated.rs1
-rw-r--r--src/tools/clippy/tests/ui/deprecated.stderr8
-rw-r--r--src/tools/clippy/tests/ui/doc.rs1
-rw-r--r--src/tools/clippy/tests/ui/doc.stderr44
-rw-r--r--src/tools/clippy/tests/ui/enum_variants.rs2
-rw-r--r--src/tools/clippy/tests/ui/exhaustive_items.fixed82
-rw-r--r--src/tools/clippy/tests/ui/exhaustive_items.rs79
-rw-r--r--src/tools/clippy/tests/ui/exhaustive_items.stderr61
-rw-r--r--src/tools/clippy/tests/ui/filter_methods.stderr12
-rw-r--r--src/tools/clippy/tests/ui/find_map.stderr26
-rw-r--r--src/tools/clippy/tests/ui/inspect_for_each.rs22
-rw-r--r--src/tools/clippy/tests/ui/inspect_for_each.stderr16
-rw-r--r--src/tools/clippy/tests/ui/manual_filter_map.fixed37
-rw-r--r--src/tools/clippy/tests/ui/manual_filter_map.rs37
-rw-r--r--src/tools/clippy/tests/ui/manual_filter_map.stderr22
-rw-r--r--src/tools/clippy/tests/ui/manual_find_map.fixed37
-rw-r--r--src/tools/clippy/tests/ui/manual_find_map.rs37
-rw-r--r--src/tools/clippy/tests/ui/manual_find_map.stderr22
-rw-r--r--src/tools/clippy/tests/ui/match_expr_like_matches_macro.fixed47
-rw-r--r--src/tools/clippy/tests/ui/match_expr_like_matches_macro.rs62
-rw-r--r--src/tools/clippy/tests/ui/match_expr_like_matches_macro.stderr85
-rw-r--r--src/tools/clippy/tests/ui/needless_question_mark.fixed8
-rw-r--r--src/tools/clippy/tests/ui/needless_question_mark.rs8
-rw-r--r--src/tools/clippy/tests/ui/needless_question_mark.stderr28
-rw-r--r--src/tools/clippy/tests/ui/needless_return.fixed19
-rw-r--r--src/tools/clippy/tests/ui/needless_return.rs19
-rw-r--r--src/tools/clippy/tests/ui/needless_return.stderr26
-rw-r--r--src/tools/clippy/tests/ui/print_literal.rs6
-rw-r--r--src/tools/clippy/tests/ui/print_literal.stderr30
-rw-r--r--src/tools/clippy/tests/ui/redundant_slicing.rs11
-rw-r--r--src/tools/clippy/tests/ui/redundant_slicing.stderr16
-rw-r--r--src/tools/clippy/tests/ui/similar_names.rs5
-rw-r--r--src/tools/clippy/tests/ui/single_match.rs56
-rw-r--r--src/tools/clippy/tests/ui/single_match.stderr68
-rw-r--r--src/tools/clippy/tests/ui/single_match_else.stderr6
-rw-r--r--src/tools/clippy/tests/ui/size_of_in_element_count/expressions.rs37
-rw-r--r--src/tools/clippy/tests/ui/size_of_in_element_count/expressions.stderr35
-rw-r--r--src/tools/clippy/tests/ui/size_of_in_element_count/functions.rs (renamed from src/tools/clippy/tests/ui/size_of_in_element_count.rs)15
-rw-r--r--src/tools/clippy/tests/ui/size_of_in_element_count/functions.stderr (renamed from src/tools/clippy/tests/ui/size_of_in_element_count.stderr)68
-rw-r--r--src/tools/clippy/tests/ui/stable_sort_primitive.stderr27
-rw-r--r--src/tools/clippy/tests/ui/suspicious_operation_groupings.rs8
-rw-r--r--src/tools/clippy/tests/ui/transmute_ptr_to_ptr.rs6
-rw-r--r--src/tools/clippy/tests/ui/unnecessary_ref.fixed11
-rw-r--r--src/tools/clippy/tests/ui/unnecessary_ref.rs11
-rw-r--r--src/tools/clippy/tests/ui/unnecessary_ref.stderr10
-rw-r--r--src/tools/clippy/tests/ui/unnested_or_patterns.fixed2
-rw-r--r--src/tools/clippy/tests/ui/unnested_or_patterns.rs2
-rw-r--r--src/tools/clippy/tests/ui/upper_case_acronyms.rs21
-rw-r--r--src/tools/clippy/tests/ui/upper_case_acronyms.stderr70
-rw-r--r--src/tools/clippy/tests/ui/use_self.fixed2
-rw-r--r--src/tools/clippy/tests/ui/use_self.rs2
-rw-r--r--src/tools/clippy/tests/ui/write_literal.rs6
-rw-r--r--src/tools/clippy/tests/ui/write_literal.stderr30
62 files changed, 1360 insertions, 230 deletions
diff --git a/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.rs b/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.rs
new file mode 100644
index 00000000000..68719c2bc6d
--- /dev/null
+++ b/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.rs
@@ -0,0 +1,44 @@
+#![warn(clippy::case_sensitive_file_extension_comparisons)]
+
+use std::string::String;
+
+struct TestStruct {}
+
+impl TestStruct {
+    fn ends_with(self, arg: &str) {}
+}
+
+fn is_rust_file(filename: &str) -> bool {
+    filename.ends_with(".rs")
+}
+
+fn main() {
+    // std::string::String and &str should trigger the lint failure with .ext12
+    let _ = String::from("").ends_with(".ext12");
+    let _ = "str".ends_with(".ext12");
+
+    // The test struct should not trigger the lint failure with .ext12
+    TestStruct {}.ends_with(".ext12");
+
+    // std::string::String and &str should trigger the lint failure with .EXT12
+    let _ = String::from("").ends_with(".EXT12");
+    let _ = "str".ends_with(".EXT12");
+
+    // The test struct should not trigger the lint failure with .EXT12
+    TestStruct {}.ends_with(".EXT12");
+
+    // Should not trigger the lint failure with .eXT12
+    let _ = String::from("").ends_with(".eXT12");
+    let _ = "str".ends_with(".eXT12");
+    TestStruct {}.ends_with(".eXT12");
+
+    // Should not trigger the lint failure with .EXT123 (too long)
+    let _ = String::from("").ends_with(".EXT123");
+    let _ = "str".ends_with(".EXT123");
+    TestStruct {}.ends_with(".EXT123");
+
+    // Shouldn't fail if it doesn't start with a dot
+    let _ = String::from("").ends_with("a.ext");
+    let _ = "str".ends_with("a.extA");
+    TestStruct {}.ends_with("a.ext");
+}
diff --git a/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.stderr b/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.stderr
new file mode 100644
index 00000000000..05b98169f2d
--- /dev/null
+++ b/src/tools/clippy/tests/ui/case_sensitive_file_extension_comparisons.stderr
@@ -0,0 +1,43 @@
+error: case-sensitive file extension comparison
+  --> $DIR/case_sensitive_file_extension_comparisons.rs:12:14
+   |
+LL |     filename.ends_with(".rs")
+   |              ^^^^^^^^^^^^^^^^
+   |
+   = note: `-D clippy::case-sensitive-file-extension-comparisons` implied by `-D warnings`
+   = help: consider using a case-insensitive comparison instead
+
+error: case-sensitive file extension comparison
+  --> $DIR/case_sensitive_file_extension_comparisons.rs:17:30
+   |
+LL |     let _ = String::from("").ends_with(".ext12");
+   |                              ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: consider using a case-insensitive comparison instead
+
+error: case-sensitive file extension comparison
+  --> $DIR/case_sensitive_file_extension_comparisons.rs:18:19
+   |
+LL |     let _ = "str".ends_with(".ext12");
+   |                   ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: consider using a case-insensitive comparison instead
+
+error: case-sensitive file extension comparison
+  --> $DIR/case_sensitive_file_extension_comparisons.rs:24:30
+   |
+LL |     let _ = String::from("").ends_with(".EXT12");
+   |                              ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: consider using a case-insensitive comparison instead
+
+error: case-sensitive file extension comparison
+  --> $DIR/case_sensitive_file_extension_comparisons.rs:25:19
+   |
+LL |     let _ = "str".ends_with(".EXT12");
+   |                   ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: consider using a case-insensitive comparison instead
+
+error: aborting due to 5 previous errors
+
diff --git a/src/tools/clippy/tests/ui/collapsible_match2.rs b/src/tools/clippy/tests/ui/collapsible_match2.rs
index d571ac4ab69..8372a212477 100644
--- a/src/tools/clippy/tests/ui/collapsible_match2.rs
+++ b/src/tools/clippy/tests/ui/collapsible_match2.rs
@@ -40,6 +40,35 @@ fn lint_cases(opt_opt: Option<Option<u32>>, res_opt: Result<Option<u32>, String>
         // there is still a better way to write this.
         mac!(res_opt => Ok(val), val => Some(n), foo(n));
     }
+
+    // deref reference value
+    match Some(&[1]) {
+        Some(s) => match *s {
+            [n] => foo(n),
+            _ => (),
+        },
+        _ => (),
+    }
+
+    // ref pattern and deref
+    match Some(&[1]) {
+        Some(ref s) => match &*s {
+            [n] => foo(n),
+            _ => (),
+        },
+        _ => (),
+    }
+}
+
+fn no_lint() {
+    // deref inner value (cannot pattern match with Vec)
+    match Some(vec![1]) {
+        Some(s) => match *s {
+            [n] => foo(n),
+            _ => (),
+        },
+        _ => (),
+    }
 }
 
 fn make<T>() -> T {
diff --git a/src/tools/clippy/tests/ui/collapsible_match2.stderr b/src/tools/clippy/tests/ui/collapsible_match2.stderr
index 490d82d12cd..b2eb457d173 100644
--- a/src/tools/clippy/tests/ui/collapsible_match2.stderr
+++ b/src/tools/clippy/tests/ui/collapsible_match2.stderr
@@ -57,5 +57,41 @@ LL |         mac!(res_opt => Ok(val), val => Some(n), foo(n));
    |                            Replace this binding
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error: aborting due to 3 previous errors
+error: Unnecessary nested match
+  --> $DIR/collapsible_match2.rs:46:20
+   |
+LL |           Some(s) => match *s {
+   |  ____________________^
+LL | |             [n] => foo(n),
+LL | |             _ => (),
+LL | |         },
+   | |_________^
+   |
+help: The outer pattern can be modified to include the inner pattern.
+  --> $DIR/collapsible_match2.rs:46:14
+   |
+LL |         Some(s) => match *s {
+   |              ^ Replace this binding
+LL |             [n] => foo(n),
+   |             ^^^ with this pattern
+
+error: Unnecessary nested match
+  --> $DIR/collapsible_match2.rs:55:24
+   |
+LL |           Some(ref s) => match &*s {
+   |  ________________________^
+LL | |             [n] => foo(n),
+LL | |             _ => (),
+LL | |         },
+   | |_________^
+   |
+help: The outer pattern can be modified to include the inner pattern.
+  --> $DIR/collapsible_match2.rs:55:14
+   |
+LL |         Some(ref s) => match &*s {
+   |              ^^^^^ Replace this binding
+LL |             [n] => foo(n),
+   |             ^^^ with this pattern
+
+error: aborting due to 5 previous errors
 
diff --git a/src/tools/clippy/tests/ui/complex_types.rs b/src/tools/clippy/tests/ui/complex_types.rs
index be61fb6b9be..383bbb49dbe 100644
--- a/src/tools/clippy/tests/ui/complex_types.rs
+++ b/src/tools/clippy/tests/ui/complex_types.rs
@@ -11,7 +11,7 @@ struct S {
     f: Vec<Vec<Box<(u32, u32, u32, u32)>>>,
 }
 
-struct TS(Vec<Vec<Box<(u32, u32, u32, u32)>>>);
+struct Ts(Vec<Vec<Box<(u32, u32, u32, u32)>>>);
 
 enum E {
     Tuple(Vec<Vec<Box<(u32, u32, u32, u32)>>>),
diff --git a/src/tools/clippy/tests/ui/complex_types.stderr b/src/tools/clippy/tests/ui/complex_types.stderr
index 8f5dbd27956..7fcbb4bce88 100644
--- a/src/tools/clippy/tests/ui/complex_types.stderr
+++ b/src/tools/clippy/tests/ui/complex_types.stderr
@@ -21,7 +21,7 @@ LL |     f: Vec<Vec<Box<(u32, u32, u32, u32)>>>,
 error: very complex type used. Consider factoring parts into `type` definitions
   --> $DIR/complex_types.rs:14:11
    |
-LL | struct TS(Vec<Vec<Box<(u32, u32, u32, u32)>>>);
+LL | struct Ts(Vec<Vec<Box<(u32, u32, u32, u32)>>>);
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: very complex type used. Consider factoring parts into `type` definitions
diff --git a/src/tools/clippy/tests/ui/crashes/ice-6256.rs b/src/tools/clippy/tests/ui/crashes/ice-6256.rs
index 6f60d45d68a..5409f36b3f1 100644
--- a/src/tools/clippy/tests/ui/crashes/ice-6256.rs
+++ b/src/tools/clippy/tests/ui/crashes/ice-6256.rs
@@ -1,5 +1,6 @@
 // originally from rustc ./src/test/ui/regions/issue-78262.rs
 // ICE: to get the signature of a closure, use substs.as_closure().sig() not fn_sig()
+#![allow(clippy::upper_case_acronyms)]
 
 trait TT {}
 
diff --git a/src/tools/clippy/tests/ui/crashes/ice-6256.stderr b/src/tools/clippy/tests/ui/crashes/ice-6256.stderr
index 0e8353a418a..d1a8bdc3c8d 100644
--- a/src/tools/clippy/tests/ui/crashes/ice-6256.stderr
+++ b/src/tools/clippy/tests/ui/crashes/ice-6256.stderr
@@ -1,13 +1,13 @@
 error[E0308]: mismatched types
-  --> $DIR/ice-6256.rs:11:28
+  --> $DIR/ice-6256.rs:12:28
    |
 LL |     let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types
    |                            ^^^^ lifetime mismatch
    |
    = note: expected reference `&(dyn TT + 'static)`
               found reference `&dyn TT`
-note: the anonymous lifetime #1 defined on the body at 11:13...
-  --> $DIR/ice-6256.rs:11:13
+note: the anonymous lifetime #1 defined on the body at 12:13...
+  --> $DIR/ice-6256.rs:12:13
    |
 LL |     let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types
    |             ^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/tools/clippy/tests/ui/crashes/ice-6539.rs b/src/tools/clippy/tests/ui/crashes/ice-6539.rs
new file mode 100644
index 00000000000..ac6c3e4aba0
--- /dev/null
+++ b/src/tools/clippy/tests/ui/crashes/ice-6539.rs
@@ -0,0 +1,16 @@
+// The test for the ICE 6539: https://github.com/rust-lang/rust-clippy/issues/6539.
+// The cause is that `zero_sized_map_values` used `layout_of` with types from type aliases,
+// which is essentially the same as the ICE 4968.
+// Note that only type aliases with associated types caused the crash this time,
+// not others such as trait impls.
+
+use std::collections::{BTreeMap, HashMap};
+
+pub trait Trait {
+    type Assoc;
+}
+
+type TypeAlias<T> = HashMap<(), <T as Trait>::Assoc>;
+type TypeAlias2<T> = BTreeMap<(), <T as Trait>::Assoc>;
+
+fn main() {}
diff --git a/src/tools/clippy/tests/ui/deprecated.rs b/src/tools/clippy/tests/ui/deprecated.rs
index 4a538021b98..fc444c0bea7 100644
--- a/src/tools/clippy/tests/ui/deprecated.rs
+++ b/src/tools/clippy/tests/ui/deprecated.rs
@@ -10,5 +10,6 @@
 #[warn(clippy::temporary_cstring_as_ptr)]
 #[warn(clippy::panic_params)]
 #[warn(clippy::unknown_clippy_lints)]
+#[warn(clippy::find_map)]
 
 fn main() {}
diff --git a/src/tools/clippy/tests/ui/deprecated.stderr b/src/tools/clippy/tests/ui/deprecated.stderr
index f361db6b147..64efcd18f88 100644
--- a/src/tools/clippy/tests/ui/deprecated.stderr
+++ b/src/tools/clippy/tests/ui/deprecated.stderr
@@ -72,11 +72,17 @@ error: lint `clippy::unknown_clippy_lints` has been removed: this lint has been
 LL | #[warn(clippy::unknown_clippy_lints)]
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+error: lint `clippy::find_map` has been removed: this lint has been replaced by `manual_find_map`, a more specific lint
+  --> $DIR/deprecated.rs:13:8
+   |
+LL | #[warn(clippy::find_map)]
+   |        ^^^^^^^^^^^^^^^^
+
 error: lint `clippy::unstable_as_slice` has been removed: `Vec::as_slice` has been stabilized in 1.7
   --> $DIR/deprecated.rs:1:8
    |
 LL | #[warn(clippy::unstable_as_slice)]
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error: aborting due to 13 previous errors
+error: aborting due to 14 previous errors
 
diff --git a/src/tools/clippy/tests/ui/doc.rs b/src/tools/clippy/tests/ui/doc.rs
index 68c5d32846f..e30970ed952 100644
--- a/src/tools/clippy/tests/ui/doc.rs
+++ b/src/tools/clippy/tests/ui/doc.rs
@@ -53,6 +53,7 @@ fn test_units() {
 /// DirectX
 /// ECMAScript
 /// OAuth GraphQL
+/// WebGL
 /// TeX LaTeX BibTeX BibLaTeX
 /// CamelCase (see also #2395)
 /// be_sure_we_got_to_the_end_of_it
diff --git a/src/tools/clippy/tests/ui/doc.stderr b/src/tools/clippy/tests/ui/doc.stderr
index 23fca43590b..e1c1aa85a60 100644
--- a/src/tools/clippy/tests/ui/doc.stderr
+++ b/src/tools/clippy/tests/ui/doc.stderr
@@ -55,133 +55,133 @@ LL | /// be_sure_we_got_to_the_end_of_it
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
-  --> $DIR/doc.rs:58:5
+  --> $DIR/doc.rs:59:5
    |
 LL | /// be_sure_we_got_to_the_end_of_it
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: you should put `link_with_underscores` between ticks in the documentation
-  --> $DIR/doc.rs:62:22
+  --> $DIR/doc.rs:63:22
    |
 LL | /// This test has [a link_with_underscores][chunked-example] inside it. See #823.
    |                      ^^^^^^^^^^^^^^^^^^^^^
 
 error: you should put `inline_link2` between ticks in the documentation
-  --> $DIR/doc.rs:65:21
+  --> $DIR/doc.rs:66:21
    |
 LL | /// It can also be [inline_link2].
    |                     ^^^^^^^^^^^^
 
 error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
-  --> $DIR/doc.rs:75:5
+  --> $DIR/doc.rs:76:5
    |
 LL | /// be_sure_we_got_to_the_end_of_it
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: you should put `CamelCaseThing` between ticks in the documentation
-  --> $DIR/doc.rs:83:8
+  --> $DIR/doc.rs:84:8
    |
 LL | /// ## CamelCaseThing
    |        ^^^^^^^^^^^^^^
 
 error: you should put `CamelCaseThing` between ticks in the documentation
-  --> $DIR/doc.rs:86:7
+  --> $DIR/doc.rs:87:7
    |
 LL | /// # CamelCaseThing
    |       ^^^^^^^^^^^^^^
 
 error: you should put `CamelCaseThing` between ticks in the documentation
-  --> $DIR/doc.rs:88:22
+  --> $DIR/doc.rs:89:22
    |
 LL | /// Not a title #897 CamelCaseThing
    |                      ^^^^^^^^^^^^^^
 
 error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
-  --> $DIR/doc.rs:89:5
+  --> $DIR/doc.rs:90:5
    |
 LL | /// be_sure_we_got_to_the_end_of_it
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
-  --> $DIR/doc.rs:96:5
+  --> $DIR/doc.rs:97:5
    |
 LL | /// be_sure_we_got_to_the_end_of_it
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
-  --> $DIR/doc.rs:109:5
+  --> $DIR/doc.rs:110:5
    |
 LL | /// be_sure_we_got_to_the_end_of_it
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: you should put `FooBar` between ticks in the documentation
-  --> $DIR/doc.rs:120:43
+  --> $DIR/doc.rs:121:43
    |
 LL | /** E.g., serialization of an empty list: FooBar
    |                                           ^^^^^^
 
 error: you should put `BarQuz` between ticks in the documentation
-  --> $DIR/doc.rs:125:5
+  --> $DIR/doc.rs:126:5
    |
 LL | And BarQuz too.
    |     ^^^^^^
 
 error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
-  --> $DIR/doc.rs:126:1
+  --> $DIR/doc.rs:127:1
    |
 LL | be_sure_we_got_to_the_end_of_it
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: you should put `FooBar` between ticks in the documentation
-  --> $DIR/doc.rs:131:43
+  --> $DIR/doc.rs:132:43
    |
 LL | /** E.g., serialization of an empty list: FooBar
    |                                           ^^^^^^
 
 error: you should put `BarQuz` between ticks in the documentation
-  --> $DIR/doc.rs:136:5
+  --> $DIR/doc.rs:137:5
    |
 LL | And BarQuz too.
    |     ^^^^^^
 
 error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
-  --> $DIR/doc.rs:137:1
+  --> $DIR/doc.rs:138:1
    |
 LL | be_sure_we_got_to_the_end_of_it
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: you should put `be_sure_we_got_to_the_end_of_it` between ticks in the documentation
-  --> $DIR/doc.rs:148:5
+  --> $DIR/doc.rs:149:5
    |
 LL | /// be_sure_we_got_to_the_end_of_it
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: you should put bare URLs between `<`/`>` or make a proper Markdown link
-  --> $DIR/doc.rs:175:13
+  --> $DIR/doc.rs:176:13
    |
 LL | /// Not ok: http://www.unicode.org
    |             ^^^^^^^^^^^^^^^^^^^^^^
 
 error: you should put bare URLs between `<`/`>` or make a proper Markdown link
-  --> $DIR/doc.rs:176:13
+  --> $DIR/doc.rs:177:13
    |
 LL | /// Not ok: https://www.unicode.org
    |             ^^^^^^^^^^^^^^^^^^^^^^^
 
 error: you should put bare URLs between `<`/`>` or make a proper Markdown link
-  --> $DIR/doc.rs:177:13
+  --> $DIR/doc.rs:178:13
    |
 LL | /// Not ok: http://www.unicode.org/
    |             ^^^^^^^^^^^^^^^^^^^^^^
 
 error: you should put bare URLs between `<`/`>` or make a proper Markdown link
-  --> $DIR/doc.rs:178:13
+  --> $DIR/doc.rs:179:13
    |
 LL | /// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: you should put `mycrate::Collection` between ticks in the documentation
-  --> $DIR/doc.rs:181:22
+  --> $DIR/doc.rs:182:22
    |
 LL | /// An iterator over mycrate::Collection's values.
    |                      ^^^^^^^^^^^^^^^^^^^
diff --git a/src/tools/clippy/tests/ui/enum_variants.rs b/src/tools/clippy/tests/ui/enum_variants.rs
index 01774a2a984..89d99dcf0c8 100644
--- a/src/tools/clippy/tests/ui/enum_variants.rs
+++ b/src/tools/clippy/tests/ui/enum_variants.rs
@@ -1,6 +1,6 @@
 #![feature(non_ascii_idents)]
 #![warn(clippy::enum_variant_names, clippy::pub_enum_variant_names)]
-#![allow(non_camel_case_types)]
+#![allow(non_camel_case_types, clippy::upper_case_acronyms)]
 
 enum FakeCallType {
     CALL,
diff --git a/src/tools/clippy/tests/ui/exhaustive_items.fixed b/src/tools/clippy/tests/ui/exhaustive_items.fixed
new file mode 100644
index 00000000000..8174a0175ab
--- /dev/null
+++ b/src/tools/clippy/tests/ui/exhaustive_items.fixed
@@ -0,0 +1,82 @@
+// run-rustfix
+
+#![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)]
+#![allow(unused)]
+
+fn main() {
+    // nop
+}
+
+pub mod enums {
+    #[non_exhaustive]
+    pub enum Exhaustive {
+        Foo,
+        Bar,
+        Baz,
+        Quux(String),
+    }
+
+    /// Some docs
+    #[repr(C)]
+    #[non_exhaustive]
+    pub enum ExhaustiveWithAttrs {
+        Foo,
+        Bar,
+        Baz,
+        Quux(String),
+    }
+
+    // no warning, already non_exhaustive
+    #[non_exhaustive]
+    pub enum NonExhaustive {
+        Foo,
+        Bar,
+        Baz,
+        Quux(String),
+    }
+
+    // no warning, private
+    enum ExhaustivePrivate {
+        Foo,
+        Bar,
+        Baz,
+        Quux(String),
+    }
+
+    // no warning, private
+    #[non_exhaustive]
+    enum NonExhaustivePrivate {
+        Foo,
+        Bar,
+        Baz,
+        Quux(String),
+    }
+}
+
+pub mod structs {
+    #[non_exhaustive]
+    pub struct Exhaustive {
+        foo: u8,
+        bar: String,
+    }
+
+    // no warning, already non_exhaustive
+    #[non_exhaustive]
+    pub struct NonExhaustive {
+        foo: u8,
+        bar: String,
+    }
+
+    // no warning, private
+    struct ExhaustivePrivate {
+        foo: u8,
+        bar: String,
+    }
+
+    // no warning, private
+    #[non_exhaustive]
+    struct NonExhaustivePrivate {
+        foo: u8,
+        bar: String,
+    }
+}
diff --git a/src/tools/clippy/tests/ui/exhaustive_items.rs b/src/tools/clippy/tests/ui/exhaustive_items.rs
new file mode 100644
index 00000000000..b476f09f8a0
--- /dev/null
+++ b/src/tools/clippy/tests/ui/exhaustive_items.rs
@@ -0,0 +1,79 @@
+// run-rustfix
+
+#![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)]
+#![allow(unused)]
+
+fn main() {
+    // nop
+}
+
+pub mod enums {
+    pub enum Exhaustive {
+        Foo,
+        Bar,
+        Baz,
+        Quux(String),
+    }
+
+    /// Some docs
+    #[repr(C)]
+    pub enum ExhaustiveWithAttrs {
+        Foo,
+        Bar,
+        Baz,
+        Quux(String),
+    }
+
+    // no warning, already non_exhaustive
+    #[non_exhaustive]
+    pub enum NonExhaustive {
+        Foo,
+        Bar,
+        Baz,
+        Quux(String),
+    }
+
+    // no warning, private
+    enum ExhaustivePrivate {
+        Foo,
+        Bar,
+        Baz,
+        Quux(String),
+    }
+
+    // no warning, private
+    #[non_exhaustive]
+    enum NonExhaustivePrivate {
+        Foo,
+        Bar,
+        Baz,
+        Quux(String),
+    }
+}
+
+pub mod structs {
+    pub struct Exhaustive {
+        foo: u8,
+        bar: String,
+    }
+
+    // no warning, already non_exhaustive
+    #[non_exhaustive]
+    pub struct NonExhaustive {
+        foo: u8,
+        bar: String,
+    }
+
+    // no warning, private
+    struct ExhaustivePrivate {
+        foo: u8,
+        bar: String,
+    }
+
+    // no warning, private
+    #[non_exhaustive]
+    struct NonExhaustivePrivate {
+        foo: u8,
+        bar: String,
+    }
+}
diff --git a/src/tools/clippy/tests/ui/exhaustive_items.stderr b/src/tools/clippy/tests/ui/exhaustive_items.stderr
new file mode 100644
index 00000000000..7369fe75a4f
--- /dev/null
+++ b/src/tools/clippy/tests/ui/exhaustive_items.stderr
@@ -0,0 +1,61 @@
+error: exported enums should not be exhaustive
+  --> $DIR/exhaustive_items.rs:11:5
+   |
+LL | /     pub enum Exhaustive {
+LL | |         Foo,
+LL | |         Bar,
+LL | |         Baz,
+LL | |         Quux(String),
+LL | |     }
+   | |_____^
+   |
+note: the lint level is defined here
+  --> $DIR/exhaustive_items.rs:3:9
+   |
+LL | #![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^
+help: try adding #[non_exhaustive]
+   |
+LL |     #[non_exhaustive]
+LL |     pub enum Exhaustive {
+   |
+
+error: exported enums should not be exhaustive
+  --> $DIR/exhaustive_items.rs:20:5
+   |
+LL | /     pub enum ExhaustiveWithAttrs {
+LL | |         Foo,
+LL | |         Bar,
+LL | |         Baz,
+LL | |         Quux(String),
+LL | |     }
+   | |_____^
+   |
+help: try adding #[non_exhaustive]
+   |
+LL |     #[non_exhaustive]
+LL |     pub enum ExhaustiveWithAttrs {
+   |
+
+error: exported structs should not be exhaustive
+  --> $DIR/exhaustive_items.rs:55:5
+   |
+LL | /     pub struct Exhaustive {
+LL | |         foo: u8,
+LL | |         bar: String,
+LL | |     }
+   | |_____^
+   |
+note: the lint level is defined here
+  --> $DIR/exhaustive_items.rs:3:35
+   |
+LL | #![deny(clippy::exhaustive_enums, clippy::exhaustive_structs)]
+   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: try adding #[non_exhaustive]
+   |
+LL |     #[non_exhaustive]
+LL |     pub struct Exhaustive {
+   |
+
+error: aborting due to 3 previous errors
+
diff --git a/src/tools/clippy/tests/ui/filter_methods.stderr b/src/tools/clippy/tests/ui/filter_methods.stderr
index 11922681379..c7b4f28be3a 100644
--- a/src/tools/clippy/tests/ui/filter_methods.stderr
+++ b/src/tools/clippy/tests/ui/filter_methods.stderr
@@ -1,12 +1,3 @@
-error: called `filter(..).map(..)` on an `Iterator`
-  --> $DIR/filter_methods.rs:6:21
-   |
-LL |     let _: Vec<_> = vec![5; 6].into_iter().filter(|&x| x == 0).map(|x| x * 2).collect();
-   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: `-D clippy::filter-map` implied by `-D warnings`
-   = help: this is more succinctly expressed by calling `.filter_map(..)` instead
-
 error: called `filter(..).flat_map(..)` on an `Iterator`
   --> $DIR/filter_methods.rs:8:21
    |
@@ -17,6 +8,7 @@ LL | |         .filter(|&x| x == 0)
 LL | |         .flat_map(|x| x.checked_mul(2))
    | |_______________________________________^
    |
+   = note: `-D clippy::filter-map` implied by `-D warnings`
    = help: this is more succinctly expressed by calling `.flat_map(..)` and filtering by returning `iter::empty()`
 
 error: called `filter_map(..).flat_map(..)` on an `Iterator`
@@ -43,5 +35,5 @@ LL | |         .map(|x| x.checked_mul(2))
    |
    = help: this is more succinctly expressed by only calling `.filter_map(..)` instead
 
-error: aborting due to 4 previous errors
+error: aborting due to 3 previous errors
 
diff --git a/src/tools/clippy/tests/ui/find_map.stderr b/src/tools/clippy/tests/ui/find_map.stderr
deleted file mode 100644
index aea3cc62afc..00000000000
--- a/src/tools/clippy/tests/ui/find_map.stderr
+++ /dev/null
@@ -1,26 +0,0 @@
-error: called `find(..).map(..)` on an `Iterator`
-  --> $DIR/find_map.rs:20:26
-   |
-LL |     let _: Option<i32> = a.iter().find(|s| s.parse::<i32>().is_ok()).map(|s| s.parse().unwrap());
-   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: `-D clippy::find-map` implied by `-D warnings`
-   = help: this is more succinctly expressed by calling `.find_map(..)` instead
-
-error: called `find(..).map(..)` on an `Iterator`
-  --> $DIR/find_map.rs:23:29
-   |
-LL |       let _: Option<Flavor> = desserts_of_the_week
-   |  _____________________________^
-LL | |         .iter()
-LL | |         .find(|dessert| match *dessert {
-LL | |             Dessert::Cake(_) => true,
-...  |
-LL | |             _ => unreachable!(),
-LL | |         });
-   | |__________^
-   |
-   = help: this is more succinctly expressed by calling `.find_map(..)` instead
-
-error: aborting due to 2 previous errors
-
diff --git a/src/tools/clippy/tests/ui/inspect_for_each.rs b/src/tools/clippy/tests/ui/inspect_for_each.rs
new file mode 100644
index 00000000000..7fe45c83bca
--- /dev/null
+++ b/src/tools/clippy/tests/ui/inspect_for_each.rs
@@ -0,0 +1,22 @@
+#![warn(clippy::inspect_for_each)]
+
+fn main() {
+    let a: Vec<usize> = vec![1, 2, 3, 4, 5];
+
+    let mut b: Vec<usize> = Vec::new();
+    a.into_iter().inspect(|x| assert!(*x > 0)).for_each(|x| {
+        let y = do_some(x);
+        let z = do_more(y);
+        b.push(z);
+    });
+
+    assert_eq!(b, vec![4, 5, 6, 7, 8]);
+}
+
+fn do_some(a: usize) -> usize {
+    a + 1
+}
+
+fn do_more(a: usize) -> usize {
+    a + 2
+}
diff --git a/src/tools/clippy/tests/ui/inspect_for_each.stderr b/src/tools/clippy/tests/ui/inspect_for_each.stderr
new file mode 100644
index 00000000000..9f976bb7458
--- /dev/null
+++ b/src/tools/clippy/tests/ui/inspect_for_each.stderr
@@ -0,0 +1,16 @@
+error: called `inspect(..).for_each(..)` on an `Iterator`
+  --> $DIR/inspect_for_each.rs:7:19
+   |
+LL |       a.into_iter().inspect(|x| assert!(*x > 0)).for_each(|x| {
+   |  ___________________^
+LL | |         let y = do_some(x);
+LL | |         let z = do_more(y);
+LL | |         b.push(z);
+LL | |     });
+   | |______^
+   |
+   = note: `-D clippy::inspect-for-each` implied by `-D warnings`
+   = help: move the code from `inspect(..)` to `for_each(..)` and remove the `inspect(..)`
+
+error: aborting due to previous error
+
diff --git a/src/tools/clippy/tests/ui/manual_filter_map.fixed b/src/tools/clippy/tests/ui/manual_filter_map.fixed
new file mode 100644
index 00000000000..fc8f58f8ea5
--- /dev/null
+++ b/src/tools/clippy/tests/ui/manual_filter_map.fixed
@@ -0,0 +1,37 @@
+// run-rustfix
+#![allow(dead_code)]
+#![warn(clippy::manual_filter_map)]
+#![allow(clippy::redundant_closure)] // FIXME suggestion may have redundant closure
+
+fn main() {
+    // is_some(), unwrap()
+    let _ = (0..).filter_map(|a| to_opt(a));
+
+    // ref pattern, expect()
+    let _ = (0..).filter_map(|a| to_opt(a));
+
+    // is_ok(), unwrap_or()
+    let _ = (0..).filter_map(|a| to_res(a).ok());
+}
+
+fn no_lint() {
+    // no shared code
+    let _ = (0..).filter(|n| *n > 1).map(|n| n + 1);
+
+    // very close but different since filter() provides a reference
+    let _ = (0..).filter(|n| to_opt(n).is_some()).map(|a| to_opt(a).unwrap());
+
+    // similar but different
+    let _ = (0..).filter(|n| to_opt(n).is_some()).map(|n| to_res(n).unwrap());
+    let _ = (0..)
+        .filter(|n| to_opt(n).map(|n| n + 1).is_some())
+        .map(|a| to_opt(a).unwrap());
+}
+
+fn to_opt<T>(_: T) -> Option<T> {
+    unimplemented!()
+}
+
+fn to_res<T>(_: T) -> Result<T, ()> {
+    unimplemented!()
+}
diff --git a/src/tools/clippy/tests/ui/manual_filter_map.rs b/src/tools/clippy/tests/ui/manual_filter_map.rs
new file mode 100644
index 00000000000..3af4bbee3bf
--- /dev/null
+++ b/src/tools/clippy/tests/ui/manual_filter_map.rs
@@ -0,0 +1,37 @@
+// run-rustfix
+#![allow(dead_code)]
+#![warn(clippy::manual_filter_map)]
+#![allow(clippy::redundant_closure)] // FIXME suggestion may have redundant closure
+
+fn main() {
+    // is_some(), unwrap()
+    let _ = (0..).filter(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap());
+
+    // ref pattern, expect()
+    let _ = (0..).filter(|&n| to_opt(n).is_some()).map(|a| to_opt(a).expect("hi"));
+
+    // is_ok(), unwrap_or()
+    let _ = (0..).filter(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1));
+}
+
+fn no_lint() {
+    // no shared code
+    let _ = (0..).filter(|n| *n > 1).map(|n| n + 1);
+
+    // very close but different since filter() provides a reference
+    let _ = (0..).filter(|n| to_opt(n).is_some()).map(|a| to_opt(a).unwrap());
+
+    // similar but different
+    let _ = (0..).filter(|n| to_opt(n).is_some()).map(|n| to_res(n).unwrap());
+    let _ = (0..)
+        .filter(|n| to_opt(n).map(|n| n + 1).is_some())
+        .map(|a| to_opt(a).unwrap());
+}
+
+fn to_opt<T>(_: T) -> Option<T> {
+    unimplemented!()
+}
+
+fn to_res<T>(_: T) -> Result<T, ()> {
+    unimplemented!()
+}
diff --git a/src/tools/clippy/tests/ui/manual_filter_map.stderr b/src/tools/clippy/tests/ui/manual_filter_map.stderr
new file mode 100644
index 00000000000..4d4e2d5c12f
--- /dev/null
+++ b/src/tools/clippy/tests/ui/manual_filter_map.stderr
@@ -0,0 +1,22 @@
+error: `filter(..).map(..)` can be simplified as `filter_map(..)`
+  --> $DIR/manual_filter_map.rs:8:19
+   |
+LL |     let _ = (0..).filter(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap());
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `filter_map(|a| to_opt(a))`
+   |
+   = note: `-D clippy::manual-filter-map` implied by `-D warnings`
+
+error: `filter(..).map(..)` can be simplified as `filter_map(..)`
+  --> $DIR/manual_filter_map.rs:11:19
+   |
+LL |     let _ = (0..).filter(|&n| to_opt(n).is_some()).map(|a| to_opt(a).expect("hi"));
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `filter_map(|a| to_opt(a))`
+
+error: `filter(..).map(..)` can be simplified as `filter_map(..)`
+  --> $DIR/manual_filter_map.rs:14:19
+   |
+LL |     let _ = (0..).filter(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1));
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `filter_map(|a| to_res(a).ok())`
+
+error: aborting due to 3 previous errors
+
diff --git a/src/tools/clippy/tests/ui/manual_find_map.fixed b/src/tools/clippy/tests/ui/manual_find_map.fixed
new file mode 100644
index 00000000000..95e97c4fd1f
--- /dev/null
+++ b/src/tools/clippy/tests/ui/manual_find_map.fixed
@@ -0,0 +1,37 @@
+// run-rustfix
+#![allow(dead_code)]
+#![warn(clippy::manual_find_map)]
+#![allow(clippy::redundant_closure)] // FIXME suggestion may have redundant closure
+
+fn main() {
+    // is_some(), unwrap()
+    let _ = (0..).find_map(|a| to_opt(a));
+
+    // ref pattern, expect()
+    let _ = (0..).find_map(|a| to_opt(a));
+
+    // is_ok(), unwrap_or()
+    let _ = (0..).find_map(|a| to_res(a).ok());
+}
+
+fn no_lint() {
+    // no shared code
+    let _ = (0..).filter(|n| *n > 1).map(|n| n + 1);
+
+    // very close but different since filter() provides a reference
+    let _ = (0..).find(|n| to_opt(n).is_some()).map(|a| to_opt(a).unwrap());
+
+    // similar but different
+    let _ = (0..).find(|n| to_opt(n).is_some()).map(|n| to_res(n).unwrap());
+    let _ = (0..)
+        .find(|n| to_opt(n).map(|n| n + 1).is_some())
+        .map(|a| to_opt(a).unwrap());
+}
+
+fn to_opt<T>(_: T) -> Option<T> {
+    unimplemented!()
+}
+
+fn to_res<T>(_: T) -> Result<T, ()> {
+    unimplemented!()
+}
diff --git a/src/tools/clippy/tests/ui/manual_find_map.rs b/src/tools/clippy/tests/ui/manual_find_map.rs
new file mode 100644
index 00000000000..cd3c82e3b25
--- /dev/null
+++ b/src/tools/clippy/tests/ui/manual_find_map.rs
@@ -0,0 +1,37 @@
+// run-rustfix
+#![allow(dead_code)]
+#![warn(clippy::manual_find_map)]
+#![allow(clippy::redundant_closure)] // FIXME suggestion may have redundant closure
+
+fn main() {
+    // is_some(), unwrap()
+    let _ = (0..).find(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap());
+
+    // ref pattern, expect()
+    let _ = (0..).find(|&n| to_opt(n).is_some()).map(|a| to_opt(a).expect("hi"));
+
+    // is_ok(), unwrap_or()
+    let _ = (0..).find(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1));
+}
+
+fn no_lint() {
+    // no shared code
+    let _ = (0..).filter(|n| *n > 1).map(|n| n + 1);
+
+    // very close but different since filter() provides a reference
+    let _ = (0..).find(|n| to_opt(n).is_some()).map(|a| to_opt(a).unwrap());
+
+    // similar but different
+    let _ = (0..).find(|n| to_opt(n).is_some()).map(|n| to_res(n).unwrap());
+    let _ = (0..)
+        .find(|n| to_opt(n).map(|n| n + 1).is_some())
+        .map(|a| to_opt(a).unwrap());
+}
+
+fn to_opt<T>(_: T) -> Option<T> {
+    unimplemented!()
+}
+
+fn to_res<T>(_: T) -> Result<T, ()> {
+    unimplemented!()
+}
diff --git a/src/tools/clippy/tests/ui/manual_find_map.stderr b/src/tools/clippy/tests/ui/manual_find_map.stderr
new file mode 100644
index 00000000000..9e7f798df45
--- /dev/null
+++ b/src/tools/clippy/tests/ui/manual_find_map.stderr
@@ -0,0 +1,22 @@
+error: `find(..).map(..)` can be simplified as `find_map(..)`
+  --> $DIR/manual_find_map.rs:8:19
+   |
+LL |     let _ = (0..).find(|n| to_opt(*n).is_some()).map(|a| to_opt(a).unwrap());
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|a| to_opt(a))`
+   |
+   = note: `-D clippy::manual-find-map` implied by `-D warnings`
+
+error: `find(..).map(..)` can be simplified as `find_map(..)`
+  --> $DIR/manual_find_map.rs:11:19
+   |
+LL |     let _ = (0..).find(|&n| to_opt(n).is_some()).map(|a| to_opt(a).expect("hi"));
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|a| to_opt(a))`
+
+error: `find(..).map(..)` can be simplified as `find_map(..)`
+  --> $DIR/manual_find_map.rs:14:19
+   |
+LL |     let _ = (0..).find(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1));
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|a| to_res(a).ok())`
+
+error: aborting due to 3 previous errors
+
diff --git a/src/tools/clippy/tests/ui/match_expr_like_matches_macro.fixed b/src/tools/clippy/tests/ui/match_expr_like_matches_macro.fixed
index 84981a52597..319299862a7 100644
--- a/src/tools/clippy/tests/ui/match_expr_like_matches_macro.fixed
+++ b/src/tools/clippy/tests/ui/match_expr_like_matches_macro.fixed
@@ -99,4 +99,51 @@ fn main() {
             _ => false,
         };
     }
+
+    {
+        // should print "z" in suggestion (#6503)
+        let z = &Some(3);
+        let _z = matches!(z, Some(3));
+    }
+
+    {
+        // this could also print "z" in suggestion..?
+        let z = Some(3);
+        let _z = matches!(&z, Some(3));
+    }
+
+    {
+        enum AnEnum {
+            X,
+            Y,
+        }
+
+        fn foo(_x: AnEnum) {}
+
+        fn main() {
+            let z = AnEnum::X;
+            // we can't remove the reference here!
+            let _ = matches!(&z, AnEnum::X);
+            foo(z);
+        }
+    }
+
+    {
+        struct S(i32);
+
+        fn fun(_val: Option<S>) {}
+        let val = Some(S(42));
+        // we need the reference here because later val is consumed by fun()
+        let _res = matches!(&val, &Some(ref _a));
+        fun(val);
+    }
+
+    {
+        struct S(i32);
+
+        fn fun(_val: Option<S>) {}
+        let val = Some(S(42));
+        let _res = matches!(&val, &Some(ref _a));
+        fun(val);
+    }
 }
diff --git a/src/tools/clippy/tests/ui/match_expr_like_matches_macro.rs b/src/tools/clippy/tests/ui/match_expr_like_matches_macro.rs
index 94c7c3cadac..2ef6cf42387 100644
--- a/src/tools/clippy/tests/ui/match_expr_like_matches_macro.rs
+++ b/src/tools/clippy/tests/ui/match_expr_like_matches_macro.rs
@@ -119,4 +119,66 @@ fn main() {
             _ => false,
         };
     }
+
+    {
+        // should print "z" in suggestion (#6503)
+        let z = &Some(3);
+        let _z = match &z {
+            Some(3) => true,
+            _ => false,
+        };
+    }
+
+    {
+        // this could also print "z" in suggestion..?
+        let z = Some(3);
+        let _z = match &z {
+            Some(3) => true,
+            _ => false,
+        };
+    }
+
+    {
+        enum AnEnum {
+            X,
+            Y,
+        }
+
+        fn foo(_x: AnEnum) {}
+
+        fn main() {
+            let z = AnEnum::X;
+            // we can't remove the reference here!
+            let _ = match &z {
+                AnEnum::X => true,
+                _ => false,
+            };
+            foo(z);
+        }
+    }
+
+    {
+        struct S(i32);
+
+        fn fun(_val: Option<S>) {}
+        let val = Some(S(42));
+        // we need the reference here because later val is consumed by fun()
+        let _res = match &val {
+            &Some(ref _a) => true,
+            _ => false,
+        };
+        fun(val);
+    }
+
+    {
+        struct S(i32);
+
+        fn fun(_val: Option<S>) {}
+        let val = Some(S(42));
+        let _res = match &val {
+            &Some(ref _a) => true,
+            _ => false,
+        };
+        fun(val);
+    }
 }
diff --git a/src/tools/clippy/tests/ui/match_expr_like_matches_macro.stderr b/src/tools/clippy/tests/ui/match_expr_like_matches_macro.stderr
index c52e41c7889..f27b4e9cb20 100644
--- a/src/tools/clippy/tests/ui/match_expr_like_matches_macro.stderr
+++ b/src/tools/clippy/tests/ui/match_expr_like_matches_macro.stderr
@@ -70,5 +70,88 @@ LL | |             _ => true,
 LL | |         };
    | |_________^ help: try this: `!matches!(x, E::B(_) | E::C)`
 
-error: aborting due to 7 previous errors
+error: match expression looks like `matches!` macro
+  --> $DIR/match_expr_like_matches_macro.rs:126:18
+   |
+LL |           let _z = match &z {
+   |  __________________^
+LL | |             Some(3) => true,
+LL | |             _ => false,
+LL | |         };
+   | |_________^ help: try this: `matches!(z, Some(3))`
+
+error: match expression looks like `matches!` macro
+  --> $DIR/match_expr_like_matches_macro.rs:135:18
+   |
+LL |           let _z = match &z {
+   |  __________________^
+LL | |             Some(3) => true,
+LL | |             _ => false,
+LL | |         };
+   | |_________^ help: try this: `matches!(&z, Some(3))`
+
+error: match expression looks like `matches!` macro
+  --> $DIR/match_expr_like_matches_macro.rs:152:21
+   |
+LL |               let _ = match &z {
+   |  _____________________^
+LL | |                 AnEnum::X => true,
+LL | |                 _ => false,
+LL | |             };
+   | |_____________^ help: try this: `matches!(&z, AnEnum::X)`
+
+error: match expression looks like `matches!` macro
+  --> $DIR/match_expr_like_matches_macro.rs:166:20
+   |
+LL |           let _res = match &val {
+   |  ____________________^
+LL | |             &Some(ref _a) => true,
+LL | |             _ => false,
+LL | |         };
+   | |_________^ help: try this: `matches!(&val, &Some(ref _a))`
+
+error: you don't need to add `&` to both the expression and the patterns
+  --> $DIR/match_expr_like_matches_macro.rs:166:20
+   |
+LL |           let _res = match &val {
+   |  ____________________^
+LL | |             &Some(ref _a) => true,
+LL | |             _ => false,
+LL | |         };
+   | |_________^
+   |
+   = note: `-D clippy::match-ref-pats` implied by `-D warnings`
+help: try
+   |
+LL |         let _res = match val {
+LL |             Some(ref _a) => true,
+   |
+
+error: match expression looks like `matches!` macro
+  --> $DIR/match_expr_like_matches_macro.rs:178:20
+   |
+LL |           let _res = match &val {
+   |  ____________________^
+LL | |             &Some(ref _a) => true,
+LL | |             _ => false,
+LL | |         };
+   | |_________^ help: try this: `matches!(&val, &Some(ref _a))`
+
+error: you don't need to add `&` to both the expression and the patterns
+  --> $DIR/match_expr_like_matches_macro.rs:178:20
+   |
+LL |           let _res = match &val {
+   |  ____________________^
+LL | |             &Some(ref _a) => true,
+LL | |             _ => false,
+LL | |         };
+   | |_________^
+   |
+help: try
+   |
+LL |         let _res = match val {
+LL |             Some(ref _a) => true,
+   |
+
+error: aborting due to 14 previous errors
 
diff --git a/src/tools/clippy/tests/ui/needless_question_mark.fixed b/src/tools/clippy/tests/ui/needless_question_mark.fixed
index 70218f3f041..71fb3565224 100644
--- a/src/tools/clippy/tests/ui/needless_question_mark.fixed
+++ b/src/tools/clippy/tests/ui/needless_question_mark.fixed
@@ -1,7 +1,13 @@
 // run-rustfix
 
 #![warn(clippy::needless_question_mark)]
-#![allow(clippy::needless_return, clippy::unnecessary_unwrap, dead_code, unused_must_use)]
+#![allow(
+    clippy::needless_return,
+    clippy::unnecessary_unwrap,
+    clippy::upper_case_acronyms,
+    dead_code,
+    unused_must_use
+)]
 #![feature(custom_inner_attributes)]
 
 struct TO {
diff --git a/src/tools/clippy/tests/ui/needless_question_mark.rs b/src/tools/clippy/tests/ui/needless_question_mark.rs
index 60ac2c8d72e..e31f6f48fa7 100644
--- a/src/tools/clippy/tests/ui/needless_question_mark.rs
+++ b/src/tools/clippy/tests/ui/needless_question_mark.rs
@@ -1,7 +1,13 @@
 // run-rustfix
 
 #![warn(clippy::needless_question_mark)]
-#![allow(clippy::needless_return, clippy::unnecessary_unwrap, dead_code, unused_must_use)]
+#![allow(
+    clippy::needless_return,
+    clippy::unnecessary_unwrap,
+    clippy::upper_case_acronyms,
+    dead_code,
+    unused_must_use
+)]
 #![feature(custom_inner_attributes)]
 
 struct TO {
diff --git a/src/tools/clippy/tests/ui/needless_question_mark.stderr b/src/tools/clippy/tests/ui/needless_question_mark.stderr
index b4eb21882ec..567bc518a3f 100644
--- a/src/tools/clippy/tests/ui/needless_question_mark.stderr
+++ b/src/tools/clippy/tests/ui/needless_question_mark.stderr
@@ -1,5 +1,5 @@
 error: Question mark operator is useless here
-  --> $DIR/needless_question_mark.rs:17:12
+  --> $DIR/needless_question_mark.rs:23:12
    |
 LL |     return Some(to.magic?);
    |            ^^^^^^^^^^^^^^^ help: try: `to.magic`
@@ -7,79 +7,79 @@ LL |     return Some(to.magic?);
    = note: `-D clippy::needless-question-mark` implied by `-D warnings`
 
 error: Question mark operator is useless here
-  --> $DIR/needless_question_mark.rs:25:12
+  --> $DIR/needless_question_mark.rs:31:12
    |
 LL |     return Some(to.magic?)
    |            ^^^^^^^^^^^^^^^ help: try: `to.magic`
 
 error: Question mark operator is useless here
-  --> $DIR/needless_question_mark.rs:30:5
+  --> $DIR/needless_question_mark.rs:36:5
    |
 LL |     Some(to.magic?)
    |     ^^^^^^^^^^^^^^^ help: try: `to.magic`
 
 error: Question mark operator is useless here
-  --> $DIR/needless_question_mark.rs:35:21
+  --> $DIR/needless_question_mark.rs:41:21
    |
 LL |     to.and_then(|t| Some(t.magic?))
    |                     ^^^^^^^^^^^^^^ help: try: `t.magic`
 
 error: Question mark operator is useless here
-  --> $DIR/needless_question_mark.rs:44:9
+  --> $DIR/needless_question_mark.rs:50:9
    |
 LL |         Some(t.magic?)
    |         ^^^^^^^^^^^^^^ help: try: `t.magic`
 
 error: Question mark operator is useless here
-  --> $DIR/needless_question_mark.rs:49:12
+  --> $DIR/needless_question_mark.rs:55:12
    |
 LL |     return Ok(tr.magic?);
    |            ^^^^^^^^^^^^^ help: try: `tr.magic`
 
 error: Question mark operator is useless here
-  --> $DIR/needless_question_mark.rs:56:12
+  --> $DIR/needless_question_mark.rs:62:12
    |
 LL |     return Ok(tr.magic?)
    |            ^^^^^^^^^^^^^ help: try: `tr.magic`
 
 error: Question mark operator is useless here
-  --> $DIR/needless_question_mark.rs:60:5
+  --> $DIR/needless_question_mark.rs:66:5
    |
 LL |     Ok(tr.magic?)
    |     ^^^^^^^^^^^^^ help: try: `tr.magic`
 
 error: Question mark operator is useless here
-  --> $DIR/needless_question_mark.rs:64:21
+  --> $DIR/needless_question_mark.rs:70:21
    |
 LL |     tr.and_then(|t| Ok(t.magic?))
    |                     ^^^^^^^^^^^^ help: try: `t.magic`
 
 error: Question mark operator is useless here
-  --> $DIR/needless_question_mark.rs:72:9
+  --> $DIR/needless_question_mark.rs:78:9
    |
 LL |         Ok(t.magic?)
    |         ^^^^^^^^^^^^ help: try: `t.magic`
 
 error: Question mark operator is useless here
-  --> $DIR/needless_question_mark.rs:79:16
+  --> $DIR/needless_question_mark.rs:85:16
    |
 LL |         return Ok(t.magic?);
    |                ^^^^^^^^^^^^ help: try: `t.magic`
 
 error: Question mark operator is useless here
-  --> $DIR/needless_question_mark.rs:132:9
+  --> $DIR/needless_question_mark.rs:138:9
    |
 LL |         Ok(to.magic?) // should be triggered
    |         ^^^^^^^^^^^^^ help: try: `to.magic`
 
 error: Question mark operator is useless here
-  --> $DIR/needless_question_mark.rs:148:9
+  --> $DIR/needless_question_mark.rs:154:9
    |
 LL |         Some(to.magic?) // should be triggered
    |         ^^^^^^^^^^^^^^^ help: try: `to.magic`
 
 error: Question mark operator is useless here
-  --> $DIR/needless_question_mark.rs:156:9
+  --> $DIR/needless_question_mark.rs:162:9
    |
 LL |         Ok(to.magic?) // should be triggered
    |         ^^^^^^^^^^^^^ help: try: `to.magic`
diff --git a/src/tools/clippy/tests/ui/needless_return.fixed b/src/tools/clippy/tests/ui/needless_return.fixed
index 86bfc5b4bb2..990475fcb58 100644
--- a/src/tools/clippy/tests/ui/needless_return.fixed
+++ b/src/tools/clippy/tests/ui/needless_return.fixed
@@ -101,6 +101,25 @@ fn test_return_in_macro() {
     needed_return!(0);
 }
 
+mod issue6501 {
+    fn foo(bar: Result<(), ()>) {
+        bar.unwrap_or_else(|_| {})
+    }
+
+    fn test_closure() {
+        let _ = || {
+            
+        };
+        let _ = || {};
+    }
+
+    struct Foo;
+    #[allow(clippy::unnecessary_lazy_evaluations)]
+    fn bar(res: Result<Foo, u8>) -> Foo {
+        res.unwrap_or_else(|_| Foo)
+    }
+}
+
 fn main() {
     let _ = test_end_of_fn();
     let _ = test_no_semicolon();
diff --git a/src/tools/clippy/tests/ui/needless_return.rs b/src/tools/clippy/tests/ui/needless_return.rs
index 51061370dfe..dec3d84a020 100644
--- a/src/tools/clippy/tests/ui/needless_return.rs
+++ b/src/tools/clippy/tests/ui/needless_return.rs
@@ -101,6 +101,25 @@ fn test_return_in_macro() {
     needed_return!(0);
 }
 
+mod issue6501 {
+    fn foo(bar: Result<(), ()>) {
+        bar.unwrap_or_else(|_| return)
+    }
+
+    fn test_closure() {
+        let _ = || {
+            return;
+        };
+        let _ = || return;
+    }
+
+    struct Foo;
+    #[allow(clippy::unnecessary_lazy_evaluations)]
+    fn bar(res: Result<Foo, u8>) -> Foo {
+        res.unwrap_or_else(|_| return Foo)
+    }
+}
+
 fn main() {
     let _ = test_end_of_fn();
     let _ = test_no_semicolon();
diff --git a/src/tools/clippy/tests/ui/needless_return.stderr b/src/tools/clippy/tests/ui/needless_return.stderr
index f73c833a801..ae31d607541 100644
--- a/src/tools/clippy/tests/ui/needless_return.stderr
+++ b/src/tools/clippy/tests/ui/needless_return.stderr
@@ -84,5 +84,29 @@ error: unneeded `return` statement
 LL |         return String::new();
    |         ^^^^^^^^^^^^^^^^^^^^^ help: remove `return`: `String::new()`
 
-error: aborting due to 14 previous errors
+error: unneeded `return` statement
+  --> $DIR/needless_return.rs:106:32
+   |
+LL |         bar.unwrap_or_else(|_| return)
+   |                                ^^^^^^ help: replace `return` with an empty block: `{}`
+
+error: unneeded `return` statement
+  --> $DIR/needless_return.rs:111:13
+   |
+LL |             return;
+   |             ^^^^^^^ help: remove `return`
+
+error: unneeded `return` statement
+  --> $DIR/needless_return.rs:113:20
+   |
+LL |         let _ = || return;
+   |                    ^^^^^^ help: replace `return` with an empty block: `{}`
+
+error: unneeded `return` statement
+  --> $DIR/needless_return.rs:119:32
+   |
+LL |         res.unwrap_or_else(|_| return Foo)
+   |                                ^^^^^^^^^^ help: remove `return`: `Foo`
+
+error: aborting due to 18 previous errors
 
diff --git a/src/tools/clippy/tests/ui/print_literal.rs b/src/tools/clippy/tests/ui/print_literal.rs
index 40ed18e9302..8665a3bb28a 100644
--- a/src/tools/clippy/tests/ui/print_literal.rs
+++ b/src/tools/clippy/tests/ui/print_literal.rs
@@ -17,14 +17,14 @@ fn main() {
     println!("{bar:8} {foo:>8}", foo = "hello", bar = "world");
     println!("{number:>width$}", number = 1, width = 6);
     println!("{number:>0width$}", number = 1, width = 6);
+    println!("{} of {:b} people know binary, the other half doesn't", 1, 2);
+    println!("10 / 4 is {}", 2.5);
+    println!("2 + 1 = {}", 3);
 
     // these should throw warnings
-    println!("{} of {:b} people know binary, the other half doesn't", 1, 2);
     print!("Hello {}", "world");
     println!("Hello {} {}", world, "world");
     println!("Hello {}", "world");
-    println!("10 / 4 is {}", 2.5);
-    println!("2 + 1 = {}", 3);
 
     // positional args don't change the fact
     // that we're using a literal -- this should
diff --git a/src/tools/clippy/tests/ui/print_literal.stderr b/src/tools/clippy/tests/ui/print_literal.stderr
index fc502e9f71d..e284aece236 100644
--- a/src/tools/clippy/tests/ui/print_literal.stderr
+++ b/src/tools/clippy/tests/ui/print_literal.stderr
@@ -1,42 +1,24 @@
 error: literal with an empty format string
-  --> $DIR/print_literal.rs:22:71
-   |
-LL |     println!("{} of {:b} people know binary, the other half doesn't", 1, 2);
-   |                                                                       ^
-   |
-   = note: `-D clippy::print-literal` implied by `-D warnings`
-
-error: literal with an empty format string
-  --> $DIR/print_literal.rs:23:24
+  --> $DIR/print_literal.rs:25:24
    |
 LL |     print!("Hello {}", "world");
    |                        ^^^^^^^
+   |
+   = note: `-D clippy::print-literal` implied by `-D warnings`
 
 error: literal with an empty format string
-  --> $DIR/print_literal.rs:24:36
+  --> $DIR/print_literal.rs:26:36
    |
 LL |     println!("Hello {} {}", world, "world");
    |                                    ^^^^^^^
 
 error: literal with an empty format string
-  --> $DIR/print_literal.rs:25:26
+  --> $DIR/print_literal.rs:27:26
    |
 LL |     println!("Hello {}", "world");
    |                          ^^^^^^^
 
 error: literal with an empty format string
-  --> $DIR/print_literal.rs:26:30
-   |
-LL |     println!("10 / 4 is {}", 2.5);
-   |                              ^^^
-
-error: literal with an empty format string
-  --> $DIR/print_literal.rs:27:28
-   |
-LL |     println!("2 + 1 = {}", 3);
-   |                            ^
-
-error: literal with an empty format string
   --> $DIR/print_literal.rs:32:25
    |
 LL |     println!("{0} {1}", "hello", "world");
@@ -84,5 +66,5 @@ error: literal with an empty format string
 LL |     println!("{bar} {foo}", foo = "hello", bar = "world");
    |                                                  ^^^^^^^
 
-error: aborting due to 14 previous errors
+error: aborting due to 11 previous errors
 
diff --git a/src/tools/clippy/tests/ui/redundant_slicing.rs b/src/tools/clippy/tests/ui/redundant_slicing.rs
new file mode 100644
index 00000000000..922b8b4ce57
--- /dev/null
+++ b/src/tools/clippy/tests/ui/redundant_slicing.rs
@@ -0,0 +1,11 @@
+#![allow(unused)]
+#![warn(clippy::redundant_slicing)]
+
+fn main() {
+    let x: &[u32] = &[0];
+    let err = &x[..];
+
+    let v = vec![0];
+    let ok = &v[..];
+    let err = &(&v[..])[..];
+}
diff --git a/src/tools/clippy/tests/ui/redundant_slicing.stderr b/src/tools/clippy/tests/ui/redundant_slicing.stderr
new file mode 100644
index 00000000000..9efd6484ad0
--- /dev/null
+++ b/src/tools/clippy/tests/ui/redundant_slicing.stderr
@@ -0,0 +1,16 @@
+error: redundant slicing of the whole range
+  --> $DIR/redundant_slicing.rs:6:15
+   |
+LL |     let err = &x[..];
+   |               ^^^^^^ help: use the original slice instead: `x`
+   |
+   = note: `-D clippy::redundant-slicing` implied by `-D warnings`
+
+error: redundant slicing of the whole range
+  --> $DIR/redundant_slicing.rs:10:15
+   |
+LL |     let err = &(&v[..])[..];
+   |               ^^^^^^^^^^^^^ help: use the original slice instead: `(&v[..])`
+
+error: aborting due to 2 previous errors
+
diff --git a/src/tools/clippy/tests/ui/similar_names.rs b/src/tools/clippy/tests/ui/similar_names.rs
index 6796b15289e..5981980988b 100644
--- a/src/tools/clippy/tests/ui/similar_names.rs
+++ b/src/tools/clippy/tests/ui/similar_names.rs
@@ -101,3 +101,8 @@ pub(crate) struct DirSizes {
     pub(crate) numb_reg_cache_entries: u64,
     pub(crate) numb_reg_src_checkouts: u64,
 }
+
+fn ignore_underscore_prefix() {
+    let hello: ();
+    let _hello: ();
+}
diff --git a/src/tools/clippy/tests/ui/single_match.rs b/src/tools/clippy/tests/ui/single_match.rs
index 1c55af5dfb6..ca884b41c45 100644
--- a/src/tools/clippy/tests/ui/single_match.rs
+++ b/src/tools/clippy/tests/ui/single_match.rs
@@ -81,6 +81,62 @@ fn single_match_know_enum() {
     }
 }
 
+// issue #173
+fn if_suggestion() {
+    let x = "test";
+    match x {
+        "test" => println!(),
+        _ => (),
+    }
+
+    #[derive(PartialEq, Eq)]
+    enum Foo {
+        A,
+        B,
+        C(u32),
+    }
+
+    let x = Foo::A;
+    match x {
+        Foo::A => println!(),
+        _ => (),
+    }
+
+    const FOO_C: Foo = Foo::C(0);
+    match x {
+        FOO_C => println!(),
+        _ => (),
+    }
+
+    match &&x {
+        Foo::A => println!(),
+        _ => (),
+    }
+
+    let x = &x;
+    match &x {
+        Foo::A => println!(),
+        _ => (),
+    }
+
+    enum Bar {
+        A,
+        B,
+    }
+    impl PartialEq for Bar {
+        fn eq(&self, rhs: &Self) -> bool {
+            matches!((self, rhs), (Self::A, Self::A) | (Self::B, Self::B))
+        }
+    }
+    impl Eq for Bar {}
+
+    let x = Bar::A;
+    match x {
+        Bar::A => println!(),
+        _ => (),
+    }
+}
+
 macro_rules! single_match {
     ($num:literal) => {
         match $num {
diff --git a/src/tools/clippy/tests/ui/single_match.stderr b/src/tools/clippy/tests/ui/single_match.stderr
index f69554d75f9..7ea6955b740 100644
--- a/src/tools/clippy/tests/ui/single_match.stderr
+++ b/src/tools/clippy/tests/ui/single_match.stderr
@@ -1,4 +1,4 @@
-error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
+error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> $DIR/single_match.rs:8:5
    |
 LL | /     match x {
@@ -17,7 +17,7 @@ LL |         println!("{:?}", y);
 LL |     };
    |
 
-error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
+error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> $DIR/single_match.rs:16:5
    |
 LL | /     match x {
@@ -29,7 +29,7 @@ LL | |         _ => (),
 LL | |     }
    | |_____^ help: try this: `if let Some(y) = x { println!("{:?}", y) }`
 
-error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
+error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> $DIR/single_match.rs:25:5
    |
 LL | /     match z {
@@ -38,7 +38,7 @@ LL | |         _ => {},
 LL | |     };
    | |_____^ help: try this: `if let (2..=3, 7..=9) = z { dummy() }`
 
-error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
+error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> $DIR/single_match.rs:54:5
    |
 LL | /     match x {
@@ -47,7 +47,7 @@ LL | |         None => (),
 LL | |     };
    | |_____^ help: try this: `if let Some(y) = x { dummy() }`
 
-error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
+error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> $DIR/single_match.rs:59:5
    |
 LL | /     match y {
@@ -56,7 +56,7 @@ LL | |         Err(..) => (),
 LL | |     };
    | |_____^ help: try this: `if let Ok(y) = y { dummy() }`
 
-error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
+error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> $DIR/single_match.rs:66:5
    |
 LL | /     match c {
@@ -65,5 +65,59 @@ LL | |         Cow::Owned(..) => (),
 LL | |     };
    | |_____^ help: try this: `if let Cow::Borrowed(..) = c { dummy() }`
 
-error: aborting due to 6 previous errors
+error: you seem to be trying to use `match` for an equality check. Consider using `if`
+  --> $DIR/single_match.rs:87:5
+   |
+LL | /     match x {
+LL | |         "test" => println!(),
+LL | |         _ => (),
+LL | |     }
+   | |_____^ help: try this: `if x == "test" { println!() }`
+
+error: you seem to be trying to use `match` for an equality check. Consider using `if`
+  --> $DIR/single_match.rs:100:5
+   |
+LL | /     match x {
+LL | |         Foo::A => println!(),
+LL | |         _ => (),
+LL | |     }
+   | |_____^ help: try this: `if x == Foo::A { println!() }`
+
+error: you seem to be trying to use `match` for an equality check. Consider using `if`
+  --> $DIR/single_match.rs:106:5
+   |
+LL | /     match x {
+LL | |         FOO_C => println!(),
+LL | |         _ => (),
+LL | |     }
+   | |_____^ help: try this: `if x == FOO_C { println!() }`
+
+error: you seem to be trying to use `match` for an equality check. Consider using `if`
+  --> $DIR/single_match.rs:111:5
+   |
+LL | /     match &&x {
+LL | |         Foo::A => println!(),
+LL | |         _ => (),
+LL | |     }
+   | |_____^ help: try this: `if x == Foo::A { println!() }`
+
+error: you seem to be trying to use `match` for an equality check. Consider using `if`
+  --> $DIR/single_match.rs:117:5
+   |
+LL | /     match &x {
+LL | |         Foo::A => println!(),
+LL | |         _ => (),
+LL | |     }
+   | |_____^ help: try this: `if x == &Foo::A { println!() }`
+
+error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
+  --> $DIR/single_match.rs:134:5
+   |
+LL | /     match x {
+LL | |         Bar::A => println!(),
+LL | |         _ => (),
+LL | |     }
+   | |_____^ help: try this: `if let Bar::A = x { println!() }`
+
+error: aborting due to 12 previous errors
 
diff --git a/src/tools/clippy/tests/ui/single_match_else.stderr b/src/tools/clippy/tests/ui/single_match_else.stderr
index 3a07c2ec542..20be4fa226c 100644
--- a/src/tools/clippy/tests/ui/single_match_else.stderr
+++ b/src/tools/clippy/tests/ui/single_match_else.stderr
@@ -1,4 +1,4 @@
-error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
+error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> $DIR/single_match_else.rs:14:5
    |
 LL | /     match ExprNode::Butterflies {
@@ -19,7 +19,7 @@ LL |         None
 LL |     }
    |
 
-error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
+error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> $DIR/single_match_else.rs:70:5
    |
 LL | /     match Some(1) {
@@ -39,7 +39,7 @@ LL |         return
 LL |     }
    |
 
-error: you seem to be trying to use match for destructuring a single pattern. Consider using `if let`
+error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> $DIR/single_match_else.rs:79:5
    |
 LL | /     match Some(1) {
diff --git a/src/tools/clippy/tests/ui/size_of_in_element_count/expressions.rs b/src/tools/clippy/tests/ui/size_of_in_element_count/expressions.rs
new file mode 100644
index 00000000000..2594e8fa6ad
--- /dev/null
+++ b/src/tools/clippy/tests/ui/size_of_in_element_count/expressions.rs
@@ -0,0 +1,37 @@
+#![warn(clippy::size_of_in_element_count)]
+#![allow(clippy::ptr_offset_with_cast)]
+
+use std::mem::{size_of, size_of_val};
+use std::ptr::{copy, copy_nonoverlapping, write_bytes};
+
+fn main() {
+    const SIZE: usize = 128;
+    const HALF_SIZE: usize = SIZE / 2;
+    const DOUBLE_SIZE: usize = SIZE * 2;
+    let mut x = [2u8; SIZE];
+    let mut y = [2u8; SIZE];
+
+    // Count expression involving multiplication of size_of (Should trigger the lint)
+    unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE) };
+
+    // Count expression involving nested multiplications of size_of (Should trigger the lint)
+    unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * size_of_val(&x[0]) * 2) };
+
+    // Count expression involving divisions of size_of (Should trigger the lint)
+    unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::<u8>() / 2) };
+
+    // Count expression involving divisions by size_of (Should not trigger the lint)
+    unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE / size_of::<u8>()) };
+
+    // Count expression involving divisions by multiple size_of (Should not trigger the lint)
+    unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE / (2 * size_of::<u8>())) };
+
+    // Count expression involving recursive divisions by size_of (Should trigger the lint)
+    unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE / (2 / size_of::<u8>())) };
+
+    // No size_of calls (Should not trigger the lint)
+    unsafe { copy(x.as_ptr(), y.as_mut_ptr(), SIZE) };
+
+    // Different types for pointee and size_of (Should not trigger the lint)
+    unsafe { y.as_mut_ptr().write_bytes(0u8, size_of::<u16>() / 2 * SIZE) };
+}
diff --git a/src/tools/clippy/tests/ui/size_of_in_element_count/expressions.stderr b/src/tools/clippy/tests/ui/size_of_in_element_count/expressions.stderr
new file mode 100644
index 00000000000..0f0dff57f51
--- /dev/null
+++ b/src/tools/clippy/tests/ui/size_of_in_element_count/expressions.stderr
@@ -0,0 +1,35 @@
+error: found a count of bytes instead of a count of elements of `T`
+  --> $DIR/expressions.rs:15:62
+   |
+LL |     unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE) };
+   |                                                              ^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: `-D clippy::size-of-in-element-count` implied by `-D warnings`
+   = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
+
+error: found a count of bytes instead of a count of elements of `T`
+  --> $DIR/expressions.rs:18:62
+   |
+LL |     unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * size_of_val(&x[0]) * 2) };
+   |                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
+
+error: found a count of bytes instead of a count of elements of `T`
+  --> $DIR/expressions.rs:21:47
+   |
+LL |     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::<u8>() / 2) };
+   |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
+
+error: found a count of bytes instead of a count of elements of `T`
+  --> $DIR/expressions.rs:30:47
+   |
+LL |     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE / (2 / size_of::<u8>())) };
+   |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
+
+error: aborting due to 4 previous errors
+
diff --git a/src/tools/clippy/tests/ui/size_of_in_element_count.rs b/src/tools/clippy/tests/ui/size_of_in_element_count/functions.rs
index b13e390705a..09d08ac37dc 100644
--- a/src/tools/clippy/tests/ui/size_of_in_element_count.rs
+++ b/src/tools/clippy/tests/ui/size_of_in_element_count/functions.rs
@@ -43,19 +43,4 @@ fn main() {
     y.as_mut_ptr().wrapping_add(size_of::<u8>());
     unsafe { y.as_ptr().offset(size_of::<u8>() as isize) };
     y.as_mut_ptr().wrapping_offset(size_of::<u8>() as isize);
-
-    // Count expression involving multiplication of size_of (Should trigger the lint)
-    unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE) };
-
-    // Count expression involving nested multiplications of size_of (Should trigger the lint)
-    unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * size_of_val(&x[0]) * 2) };
-
-    // Count expression involving divisions of size_of (Should trigger the lint)
-    unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::<u8>() / 2) };
-
-    // No size_of calls (Should not trigger the lint)
-    unsafe { copy(x.as_ptr(), y.as_mut_ptr(), SIZE) };
-
-    // Different types for pointee and size_of (Should not trigger the lint)
-    unsafe { y.as_mut_ptr().write_bytes(0u8, size_of::<u16>() / 2 * SIZE) };
 }
diff --git a/src/tools/clippy/tests/ui/size_of_in_element_count.stderr b/src/tools/clippy/tests/ui/size_of_in_element_count/functions.stderr
index 8cf3612abda..c1e824167b7 100644
--- a/src/tools/clippy/tests/ui/size_of_in_element_count.stderr
+++ b/src/tools/clippy/tests/ui/size_of_in_element_count/functions.stderr
@@ -1,5 +1,5 @@
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:18:68
+  --> $DIR/functions.rs:18:68
    |
 LL |     unsafe { copy_nonoverlapping::<u8>(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>()) };
    |                                                                    ^^^^^^^^^^^^^^^
@@ -8,7 +8,7 @@ LL |     unsafe { copy_nonoverlapping::<u8>(x.as_ptr(), y.as_mut_ptr(), size_of:
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:19:62
+  --> $DIR/functions.rs:19:62
    |
 LL |     unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) };
    |                                                              ^^^^^^^^^^^^^^^^^^
@@ -16,7 +16,7 @@ LL |     unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:21:49
+  --> $DIR/functions.rs:21:49
    |
 LL |     unsafe { x.as_ptr().copy_to(y.as_mut_ptr(), size_of::<u8>()) };
    |                                                 ^^^^^^^^^^^^^^^
@@ -24,7 +24,7 @@ LL |     unsafe { x.as_ptr().copy_to(y.as_mut_ptr(), size_of::<u8>()) };
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:22:64
+  --> $DIR/functions.rs:22:64
    |
 LL |     unsafe { x.as_ptr().copy_to_nonoverlapping(y.as_mut_ptr(), size_of::<u8>()) };
    |                                                                ^^^^^^^^^^^^^^^
@@ -32,7 +32,7 @@ LL |     unsafe { x.as_ptr().copy_to_nonoverlapping(y.as_mut_ptr(), size_of::<u8
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:23:51
+  --> $DIR/functions.rs:23:51
    |
 LL |     unsafe { y.as_mut_ptr().copy_from(x.as_ptr(), size_of::<u8>()) };
    |                                                   ^^^^^^^^^^^^^^^
@@ -40,7 +40,7 @@ LL |     unsafe { y.as_mut_ptr().copy_from(x.as_ptr(), size_of::<u8>()) };
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:24:66
+  --> $DIR/functions.rs:24:66
    |
 LL |     unsafe { y.as_mut_ptr().copy_from_nonoverlapping(x.as_ptr(), size_of::<u8>()) };
    |                                                                  ^^^^^^^^^^^^^^^
@@ -48,7 +48,7 @@ LL |     unsafe { y.as_mut_ptr().copy_from_nonoverlapping(x.as_ptr(), size_of::<
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:26:47
+  --> $DIR/functions.rs:26:47
    |
 LL |     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>()) };
    |                                               ^^^^^^^^^^^^^^^
@@ -56,7 +56,7 @@ LL |     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>()) };
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:27:47
+  --> $DIR/functions.rs:27:47
    |
 LL |     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) };
    |                                               ^^^^^^^^^^^^^^^^^^
@@ -64,7 +64,7 @@ LL |     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), size_of_val(&x[0])) };
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:29:46
+  --> $DIR/functions.rs:29:46
    |
 LL |     unsafe { y.as_mut_ptr().write_bytes(0u8, size_of::<u8>() * SIZE) };
    |                                              ^^^^^^^^^^^^^^^^^^^^^^
@@ -72,7 +72,7 @@ LL |     unsafe { y.as_mut_ptr().write_bytes(0u8, size_of::<u8>() * SIZE) };
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:30:47
+  --> $DIR/functions.rs:30:47
    |
 LL |     unsafe { write_bytes(y.as_mut_ptr(), 0u8, size_of::<u8>() * SIZE) };
    |                                               ^^^^^^^^^^^^^^^^^^^^^^
@@ -80,7 +80,7 @@ LL |     unsafe { write_bytes(y.as_mut_ptr(), 0u8, size_of::<u8>() * SIZE) };
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:32:66
+  --> $DIR/functions.rs:32:66
    |
 LL |     unsafe { swap_nonoverlapping(y.as_mut_ptr(), x.as_mut_ptr(), size_of::<u8>() * SIZE) };
    |                                                                  ^^^^^^^^^^^^^^^^^^^^^^
@@ -88,7 +88,7 @@ LL |     unsafe { swap_nonoverlapping(y.as_mut_ptr(), x.as_mut_ptr(), size_of::<
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:34:46
+  --> $DIR/functions.rs:34:46
    |
 LL |     slice_from_raw_parts_mut(y.as_mut_ptr(), size_of::<u8>() * SIZE);
    |                                              ^^^^^^^^^^^^^^^^^^^^^^
@@ -96,7 +96,7 @@ LL |     slice_from_raw_parts_mut(y.as_mut_ptr(), size_of::<u8>() * SIZE);
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:35:38
+  --> $DIR/functions.rs:35:38
    |
 LL |     slice_from_raw_parts(y.as_ptr(), size_of::<u8>() * SIZE);
    |                                      ^^^^^^^^^^^^^^^^^^^^^^
@@ -104,7 +104,7 @@ LL |     slice_from_raw_parts(y.as_ptr(), size_of::<u8>() * SIZE);
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:37:49
+  --> $DIR/functions.rs:37:49
    |
 LL |     unsafe { from_raw_parts_mut(y.as_mut_ptr(), size_of::<u8>() * SIZE) };
    |                                                 ^^^^^^^^^^^^^^^^^^^^^^
@@ -112,7 +112,7 @@ LL |     unsafe { from_raw_parts_mut(y.as_mut_ptr(), size_of::<u8>() * SIZE) };
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:38:41
+  --> $DIR/functions.rs:38:41
    |
 LL |     unsafe { from_raw_parts(y.as_ptr(), size_of::<u8>() * SIZE) };
    |                                         ^^^^^^^^^^^^^^^^^^^^^^
@@ -120,7 +120,7 @@ LL |     unsafe { from_raw_parts(y.as_ptr(), size_of::<u8>() * SIZE) };
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:40:33
+  --> $DIR/functions.rs:40:33
    |
 LL |     unsafe { y.as_mut_ptr().sub(size_of::<u8>()) };
    |                                 ^^^^^^^^^^^^^^^
@@ -128,7 +128,7 @@ LL |     unsafe { y.as_mut_ptr().sub(size_of::<u8>()) };
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:41:29
+  --> $DIR/functions.rs:41:29
    |
 LL |     y.as_ptr().wrapping_sub(size_of::<u8>());
    |                             ^^^^^^^^^^^^^^^
@@ -136,7 +136,7 @@ LL |     y.as_ptr().wrapping_sub(size_of::<u8>());
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:42:29
+  --> $DIR/functions.rs:42:29
    |
 LL |     unsafe { y.as_ptr().add(size_of::<u8>()) };
    |                             ^^^^^^^^^^^^^^^
@@ -144,7 +144,7 @@ LL |     unsafe { y.as_ptr().add(size_of::<u8>()) };
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:43:33
+  --> $DIR/functions.rs:43:33
    |
 LL |     y.as_mut_ptr().wrapping_add(size_of::<u8>());
    |                                 ^^^^^^^^^^^^^^^
@@ -152,7 +152,7 @@ LL |     y.as_mut_ptr().wrapping_add(size_of::<u8>());
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:44:32
+  --> $DIR/functions.rs:44:32
    |
 LL |     unsafe { y.as_ptr().offset(size_of::<u8>() as isize) };
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -160,36 +160,12 @@ LL |     unsafe { y.as_ptr().offset(size_of::<u8>() as isize) };
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
 error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:45:36
+  --> $DIR/functions.rs:45:36
    |
 LL |     y.as_mut_ptr().wrapping_offset(size_of::<u8>() as isize);
    |                                    ^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
 
-error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:48:62
-   |
-LL |     unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), size_of::<u8>() * SIZE) };
-   |                                                              ^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
-
-error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:51:62
-   |
-LL |     unsafe { copy_nonoverlapping(x.as_ptr(), y.as_mut_ptr(), HALF_SIZE * size_of_val(&x[0]) * 2) };
-   |                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
-
-error: found a count of bytes instead of a count of elements of `T`
-  --> $DIR/size_of_in_element_count.rs:54:47
-   |
-LL |     unsafe { copy(x.as_ptr(), y.as_mut_ptr(), DOUBLE_SIZE * size_of::<u8>() / 2) };
-   |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = help: use a count of elements instead of a count of bytes, it already gets multiplied by the size of the type
-
-error: aborting due to 24 previous errors
+error: aborting due to 21 previous errors
 
diff --git a/src/tools/clippy/tests/ui/stable_sort_primitive.stderr b/src/tools/clippy/tests/ui/stable_sort_primitive.stderr
index 780389f32bc..b8d22ed2504 100644
--- a/src/tools/clippy/tests/ui/stable_sort_primitive.stderr
+++ b/src/tools/clippy/tests/ui/stable_sort_primitive.stderr
@@ -1,46 +1,59 @@
-error: used sort instead of sort_unstable to sort primitive type `i32`
+error: used `sort` on primitive type `i32`
   --> $DIR/stable_sort_primitive.rs:7:5
    |
 LL |     vec.sort();
    |     ^^^^^^^^^^ help: try: `vec.sort_unstable()`
    |
    = note: `-D clippy::stable-sort-primitive` implied by `-D warnings`
+   = note: an unstable sort would perform faster without any observable difference for this data type
 
-error: used sort instead of sort_unstable to sort primitive type `bool`
+error: used `sort` on primitive type `bool`
   --> $DIR/stable_sort_primitive.rs:9:5
    |
 LL |     vec.sort();
    |     ^^^^^^^^^^ help: try: `vec.sort_unstable()`
+   |
+   = note: an unstable sort would perform faster without any observable difference for this data type
 
-error: used sort instead of sort_unstable to sort primitive type `char`
+error: used `sort` on primitive type `char`
   --> $DIR/stable_sort_primitive.rs:11:5
    |
 LL |     vec.sort();
    |     ^^^^^^^^^^ help: try: `vec.sort_unstable()`
+   |
+   = note: an unstable sort would perform faster without any observable difference for this data type
 
-error: used sort instead of sort_unstable to sort primitive type `str`
+error: used `sort` on primitive type `str`
   --> $DIR/stable_sort_primitive.rs:13:5
    |
 LL |     vec.sort();
    |     ^^^^^^^^^^ help: try: `vec.sort_unstable()`
+   |
+   = note: an unstable sort would perform faster without any observable difference for this data type
 
-error: used sort instead of sort_unstable to sort primitive type `tuple`
+error: used `sort` on primitive type `tuple`
   --> $DIR/stable_sort_primitive.rs:15:5
    |
 LL |     vec.sort();
    |     ^^^^^^^^^^ help: try: `vec.sort_unstable()`
+   |
+   = note: an unstable sort would perform faster without any observable difference for this data type
 
-error: used sort instead of sort_unstable to sort primitive type `array`
+error: used `sort` on primitive type `array`
   --> $DIR/stable_sort_primitive.rs:17:5
    |
 LL |     vec.sort();
    |     ^^^^^^^^^^ help: try: `vec.sort_unstable()`
+   |
+   = note: an unstable sort would perform faster without any observable difference for this data type
 
-error: used sort instead of sort_unstable to sort primitive type `i32`
+error: used `sort` on primitive type `i32`
   --> $DIR/stable_sort_primitive.rs:19:5
    |
 LL |     arr.sort();
    |     ^^^^^^^^^^ help: try: `arr.sort_unstable()`
+   |
+   = note: an unstable sort would perform faster without any observable difference for this data type
 
 error: aborting due to 7 previous errors
 
diff --git a/src/tools/clippy/tests/ui/suspicious_operation_groupings.rs b/src/tools/clippy/tests/ui/suspicious_operation_groupings.rs
index dd6f4ec7bd9..2f8c7cec50f 100644
--- a/src/tools/clippy/tests/ui/suspicious_operation_groupings.rs
+++ b/src/tools/clippy/tests/ui/suspicious_operation_groupings.rs
@@ -27,7 +27,7 @@ fn buggy_ab_cmp(s1: &S, s2: &S) -> bool {
     s1.a < s2.a && s1.a < s2.b
 }
 
-struct SAOnly {
+struct SaOnly {
     a: i32,
 }
 
@@ -37,13 +37,13 @@ impl S {
     }
 }
 
-fn do_not_give_bad_suggestions_for_this_unusual_expr(s1: &S, s2: &SAOnly) -> bool {
+fn do_not_give_bad_suggestions_for_this_unusual_expr(s1: &S, s2: &SaOnly) -> bool {
     // This is superficially similar to `buggy_ab_cmp`, but we should not suggest
     // `s2.b` since that is invalid.
     s1.a < s2.a && s1.a() < s1.b
 }
 
-fn do_not_give_bad_suggestions_for_this_macro_expr(s1: &S, s2: &SAOnly) -> bool {
+fn do_not_give_bad_suggestions_for_this_macro_expr(s1: &S, s2: &SaOnly) -> bool {
     macro_rules! s1 {
         () => {
             S {
@@ -60,7 +60,7 @@ fn do_not_give_bad_suggestions_for_this_macro_expr(s1: &S, s2: &SAOnly) -> bool
     s1.a < s2.a && s1!().a < s1.b
 }
 
-fn do_not_give_bad_suggestions_for_this_incorrect_expr(s1: &S, s2: &SAOnly) -> bool {
+fn do_not_give_bad_suggestions_for_this_incorrect_expr(s1: &S, s2: &SaOnly) -> bool {
     // There's two `s1.b`, but we should not suggest `s2.b` since that is invalid
     s1.a < s2.a && s1.b < s1.b
 }
diff --git a/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.rs b/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.rs
index 26b03bdc740..9e213aab68c 100644
--- a/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.rs
+++ b/src/tools/clippy/tests/ui/transmute_ptr_to_ptr.rs
@@ -53,10 +53,10 @@ fn transmute_ptr_to_ptr() {
 
 // dereferencing raw pointers in const contexts, should not lint as it's unstable (issue 5959)
 const _: &() = {
-    struct ZST;
-    let zst = &ZST;
+    struct Zst;
+    let zst = &Zst;
 
-    unsafe { std::mem::transmute::<&'static ZST, &'static ()>(zst) }
+    unsafe { std::mem::transmute::<&'static Zst, &'static ()>(zst) }
 };
 
 fn main() {}
diff --git a/src/tools/clippy/tests/ui/unnecessary_ref.fixed b/src/tools/clippy/tests/ui/unnecessary_ref.fixed
index f7b94118d4e..d927bae976f 100644
--- a/src/tools/clippy/tests/ui/unnecessary_ref.fixed
+++ b/src/tools/clippy/tests/ui/unnecessary_ref.fixed
@@ -1,7 +1,7 @@
 // run-rustfix
 
 #![feature(stmt_expr_attributes)]
-#![allow(unused_variables)]
+#![allow(unused_variables, dead_code)]
 
 struct Outer {
     inner: u32,
@@ -12,3 +12,12 @@ fn main() {
     let outer = Outer { inner: 0 };
     let inner = outer.inner;
 }
+
+struct Apple;
+impl Apple {
+    fn hello(&self) {}
+}
+struct Package(pub *const Apple);
+fn foobar(package: *const Package) {
+    unsafe { &*(*package).0 }.hello();
+}
diff --git a/src/tools/clippy/tests/ui/unnecessary_ref.rs b/src/tools/clippy/tests/ui/unnecessary_ref.rs
index 4e585b9b96b..86bfb76ec26 100644
--- a/src/tools/clippy/tests/ui/unnecessary_ref.rs
+++ b/src/tools/clippy/tests/ui/unnecessary_ref.rs
@@ -1,7 +1,7 @@
 // run-rustfix
 
 #![feature(stmt_expr_attributes)]
-#![allow(unused_variables)]
+#![allow(unused_variables, dead_code)]
 
 struct Outer {
     inner: u32,
@@ -12,3 +12,12 @@ fn main() {
     let outer = Outer { inner: 0 };
     let inner = (&outer).inner;
 }
+
+struct Apple;
+impl Apple {
+    fn hello(&self) {}
+}
+struct Package(pub *const Apple);
+fn foobar(package: *const Package) {
+    unsafe { &*(&*package).0 }.hello();
+}
diff --git a/src/tools/clippy/tests/ui/unnecessary_ref.stderr b/src/tools/clippy/tests/ui/unnecessary_ref.stderr
index d0a0f219097..436f4bcf738 100644
--- a/src/tools/clippy/tests/ui/unnecessary_ref.stderr
+++ b/src/tools/clippy/tests/ui/unnecessary_ref.stderr
@@ -10,5 +10,13 @@ note: the lint level is defined here
 LL | #[deny(clippy::ref_in_deref)]
    |        ^^^^^^^^^^^^^^^^^^^^
 
-error: aborting due to previous error
+error: creating a reference that is immediately dereferenced
+  --> $DIR/unnecessary_ref.rs:22:16
+   |
+LL |     unsafe { &*(&*package).0 }.hello();
+   |                ^^^^^^^^^^^ help: try this: `(*package)`
+   |
+   = note: `-D clippy::ref-in-deref` implied by `-D warnings`
+
+error: aborting due to 2 previous errors
 
diff --git a/src/tools/clippy/tests/ui/unnested_or_patterns.fixed b/src/tools/clippy/tests/ui/unnested_or_patterns.fixed
index b39e891094f..13a036cd800 100644
--- a/src/tools/clippy/tests/ui/unnested_or_patterns.fixed
+++ b/src/tools/clippy/tests/ui/unnested_or_patterns.fixed
@@ -3,7 +3,7 @@
 #![feature(or_patterns)]
 #![feature(box_patterns)]
 #![warn(clippy::unnested_or_patterns)]
-#![allow(clippy::cognitive_complexity, clippy::match_ref_pats)]
+#![allow(clippy::cognitive_complexity, clippy::match_ref_pats, clippy::upper_case_acronyms)]
 #![allow(unreachable_patterns, irrefutable_let_patterns, unused_variables)]
 
 fn main() {
diff --git a/src/tools/clippy/tests/ui/unnested_or_patterns.rs b/src/tools/clippy/tests/ui/unnested_or_patterns.rs
index 096f5a71150..4a10cc702c4 100644
--- a/src/tools/clippy/tests/ui/unnested_or_patterns.rs
+++ b/src/tools/clippy/tests/ui/unnested_or_patterns.rs
@@ -3,7 +3,7 @@
 #![feature(or_patterns)]
 #![feature(box_patterns)]
 #![warn(clippy::unnested_or_patterns)]
-#![allow(clippy::cognitive_complexity, clippy::match_ref_pats)]
+#![allow(clippy::cognitive_complexity, clippy::match_ref_pats, clippy::upper_case_acronyms)]
 #![allow(unreachable_patterns, irrefutable_let_patterns, unused_variables)]
 
 fn main() {
diff --git a/src/tools/clippy/tests/ui/upper_case_acronyms.rs b/src/tools/clippy/tests/ui/upper_case_acronyms.rs
new file mode 100644
index 00000000000..af0b5776348
--- /dev/null
+++ b/src/tools/clippy/tests/ui/upper_case_acronyms.rs
@@ -0,0 +1,21 @@
+#![warn(clippy::upper_case_acronyms)]
+
+struct HTTPResponse; // linted
+
+struct CString; // not linted
+
+enum Flags {
+    NS, // linted
+    CWR,
+    ECE,
+    URG,
+    ACK,
+    PSH,
+    RST,
+    SYN,
+    FIN,
+}
+
+struct GCCLLVMSomething; // linted, beware that lint suggests `GccllvmSomething` instead of `GccLlvmSomething`
+
+fn main() {}
diff --git a/src/tools/clippy/tests/ui/upper_case_acronyms.stderr b/src/tools/clippy/tests/ui/upper_case_acronyms.stderr
new file mode 100644
index 00000000000..2065fe10bb1
--- /dev/null
+++ b/src/tools/clippy/tests/ui/upper_case_acronyms.stderr
@@ -0,0 +1,70 @@
+error: name `HTTPResponse` contains a capitalized acronym
+  --> $DIR/upper_case_acronyms.rs:3:8
+   |
+LL | struct HTTPResponse; // linted
+   |        ^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `HttpResponse`
+   |
+   = note: `-D clippy::upper-case-acronyms` implied by `-D warnings`
+
+error: name `NS` contains a capitalized acronym
+  --> $DIR/upper_case_acronyms.rs:8:5
+   |
+LL |     NS, // linted
+   |     ^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ns`
+
+error: name `CWR` contains a capitalized acronym
+  --> $DIR/upper_case_acronyms.rs:9:5
+   |
+LL |     CWR,
+   |     ^^^ help: consider making the acronym lowercase, except the initial letter: `Cwr`
+
+error: name `ECE` contains a capitalized acronym
+  --> $DIR/upper_case_acronyms.rs:10:5
+   |
+LL |     ECE,
+   |     ^^^ help: consider making the acronym lowercase, except the initial letter: `Ece`
+
+error: name `URG` contains a capitalized acronym
+  --> $DIR/upper_case_acronyms.rs:11:5
+   |
+LL |     URG,
+   |     ^^^ help: consider making the acronym lowercase, except the initial letter: `Urg`
+
+error: name `ACK` contains a capitalized acronym
+  --> $DIR/upper_case_acronyms.rs:12:5
+   |
+LL |     ACK,
+   |     ^^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ack`
+
+error: name `PSH` contains a capitalized acronym
+  --> $DIR/upper_case_acronyms.rs:13:5
+   |
+LL |     PSH,
+   |     ^^^ help: consider making the acronym lowercase, except the initial letter: `Psh`
+
+error: name `RST` contains a capitalized acronym
+  --> $DIR/upper_case_acronyms.rs:14:5
+   |
+LL |     RST,
+   |     ^^^ help: consider making the acronym lowercase, except the initial letter: `Rst`
+
+error: name `SYN` contains a capitalized acronym
+  --> $DIR/upper_case_acronyms.rs:15:5
+   |
+LL |     SYN,
+   |     ^^^ help: consider making the acronym lowercase, except the initial letter: `Syn`
+
+error: name `FIN` contains a capitalized acronym
+  --> $DIR/upper_case_acronyms.rs:16:5
+   |
+LL |     FIN,
+   |     ^^^ help: consider making the acronym lowercase, except the initial letter: `Fin`
+
+error: name `GCCLLVMSomething` contains a capitalized acronym
+  --> $DIR/upper_case_acronyms.rs:19:8
+   |
+LL | struct GCCLLVMSomething; // linted, beware that lint suggests `GccllvmSomething` instead of `GccLlvmSomething`
+   |        ^^^^^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `GccllvmSomething`
+
+error: aborting due to 11 previous errors
+
diff --git a/src/tools/clippy/tests/ui/use_self.fixed b/src/tools/clippy/tests/ui/use_self.fixed
index d6a890014e6..bb2012441d9 100644
--- a/src/tools/clippy/tests/ui/use_self.fixed
+++ b/src/tools/clippy/tests/ui/use_self.fixed
@@ -3,7 +3,7 @@
 
 #![warn(clippy::use_self)]
 #![allow(dead_code)]
-#![allow(clippy::should_implement_trait)]
+#![allow(clippy::should_implement_trait, clippy::upper_case_acronyms)]
 
 fn main() {}
 
diff --git a/src/tools/clippy/tests/ui/use_self.rs b/src/tools/clippy/tests/ui/use_self.rs
index b04d9ce75b2..ddfd2beba31 100644
--- a/src/tools/clippy/tests/ui/use_self.rs
+++ b/src/tools/clippy/tests/ui/use_self.rs
@@ -3,7 +3,7 @@
 
 #![warn(clippy::use_self)]
 #![allow(dead_code)]
-#![allow(clippy::should_implement_trait)]
+#![allow(clippy::should_implement_trait, clippy::upper_case_acronyms)]
 
 fn main() {}
 
diff --git a/src/tools/clippy/tests/ui/write_literal.rs b/src/tools/clippy/tests/ui/write_literal.rs
index d8205c5eb67..0a127858def 100644
--- a/src/tools/clippy/tests/ui/write_literal.rs
+++ b/src/tools/clippy/tests/ui/write_literal.rs
@@ -22,14 +22,14 @@ fn main() {
     writeln!(&mut v, "{bar:8} {foo:>8}", foo = "hello", bar = "world");
     writeln!(&mut v, "{number:>width$}", number = 1, width = 6);
     writeln!(&mut v, "{number:>0width$}", number = 1, width = 6);
+    writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2);
+    writeln!(&mut v, "10 / 4 is {}", 2.5);
+    writeln!(&mut v, "2 + 1 = {}", 3);
 
     // these should throw warnings
-    writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2);
     write!(&mut v, "Hello {}", "world");
     writeln!(&mut v, "Hello {} {}", world, "world");
     writeln!(&mut v, "Hello {}", "world");
-    writeln!(&mut v, "10 / 4 is {}", 2.5);
-    writeln!(&mut v, "2 + 1 = {}", 3);
 
     // positional args don't change the fact
     // that we're using a literal -- this should
diff --git a/src/tools/clippy/tests/ui/write_literal.stderr b/src/tools/clippy/tests/ui/write_literal.stderr
index 54a787fe555..e54d89ecf29 100644
--- a/src/tools/clippy/tests/ui/write_literal.stderr
+++ b/src/tools/clippy/tests/ui/write_literal.stderr
@@ -1,42 +1,24 @@
 error: literal with an empty format string
-  --> $DIR/write_literal.rs:27:79
-   |
-LL |     writeln!(&mut v, "{} of {:b} people know binary, the other half doesn't", 1, 2);
-   |                                                                               ^
-   |
-   = note: `-D clippy::write-literal` implied by `-D warnings`
-
-error: literal with an empty format string
-  --> $DIR/write_literal.rs:28:32
+  --> $DIR/write_literal.rs:30:32
    |
 LL |     write!(&mut v, "Hello {}", "world");
    |                                ^^^^^^^
+   |
+   = note: `-D clippy::write-literal` implied by `-D warnings`
 
 error: literal with an empty format string
-  --> $DIR/write_literal.rs:29:44
+  --> $DIR/write_literal.rs:31:44
    |
 LL |     writeln!(&mut v, "Hello {} {}", world, "world");
    |                                            ^^^^^^^
 
 error: literal with an empty format string
-  --> $DIR/write_literal.rs:30:34
+  --> $DIR/write_literal.rs:32:34
    |
 LL |     writeln!(&mut v, "Hello {}", "world");
    |                                  ^^^^^^^
 
 error: literal with an empty format string
-  --> $DIR/write_literal.rs:31:38
-   |
-LL |     writeln!(&mut v, "10 / 4 is {}", 2.5);
-   |                                      ^^^
-
-error: literal with an empty format string
-  --> $DIR/write_literal.rs:32:36
-   |
-LL |     writeln!(&mut v, "2 + 1 = {}", 3);
-   |                                    ^
-
-error: literal with an empty format string
   --> $DIR/write_literal.rs:37:33
    |
 LL |     writeln!(&mut v, "{0} {1}", "hello", "world");
@@ -84,5 +66,5 @@ error: literal with an empty format string
 LL |     writeln!(&mut v, "{bar} {foo}", foo = "hello", bar = "world");
    |                                                          ^^^^^^^
 
-error: aborting due to 14 previous errors
+error: aborting due to 11 previous errors