about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/manual_map_option.fixed13
-rw-r--r--tests/ui/manual_map_option.rs11
-rw-r--r--tests/ui/manual_map_option.stderr26
3 files changed, 34 insertions, 16 deletions
diff --git a/tests/ui/manual_map_option.fixed b/tests/ui/manual_map_option.fixed
index 6cb9a37b230..19350906758 100644
--- a/tests/ui/manual_map_option.fixed
+++ b/tests/ui/manual_map_option.fixed
@@ -32,9 +32,18 @@ fn main() {
 
     Some(0).map(|x| x + x);
 
-    Some(String::new()).as_mut().map(|x| x.push_str(""));
+    #[warn(clippy::option_map_unit_fn)]
+    match &mut Some(String::new()) {
+        Some(x) => Some(x.push_str("")),
+        None => None,
+    };
 
-    Some(String::new()).as_ref().map(|x| &**x);
+    #[allow(clippy::option_map_unit_fn)]
+    {
+        Some(String::new()).as_mut().map(|x| x.push_str(""));
+    }
+
+    Some(String::new()).as_ref().map(|x| x.len());
 
     Some(String::new()).as_ref().map(|x| x.is_empty());
 
diff --git a/tests/ui/manual_map_option.rs b/tests/ui/manual_map_option.rs
index b9753060b99..8b8187db0a9 100644
--- a/tests/ui/manual_map_option.rs
+++ b/tests/ui/manual_map_option.rs
@@ -66,13 +66,22 @@ fn main() {
         &&_ => None,
     };
 
+    #[warn(clippy::option_map_unit_fn)]
     match &mut Some(String::new()) {
         Some(x) => Some(x.push_str("")),
         None => None,
     };
 
+    #[allow(clippy::option_map_unit_fn)]
+    {
+        match &mut Some(String::new()) {
+            Some(x) => Some(x.push_str("")),
+            None => None,
+        };
+    }
+
     match &mut Some(String::new()) {
-        Some(ref x) => Some(&**x),
+        Some(ref x) => Some(x.len()),
         None => None,
     };
 
diff --git a/tests/ui/manual_map_option.stderr b/tests/ui/manual_map_option.stderr
index f8e1bda83b2..210a30d05d4 100644
--- a/tests/ui/manual_map_option.stderr
+++ b/tests/ui/manual_map_option.stderr
@@ -101,25 +101,25 @@ LL | |     };
    | |_____^ help: try this: `Some(0).map(|x| x + x)`
 
 error: manual implementation of `Option::map`
-  --> $DIR/manual_map_option.rs:69:5
+  --> $DIR/manual_map_option.rs:77:9
    |
-LL | /     match &mut Some(String::new()) {
-LL | |         Some(x) => Some(x.push_str("")),
-LL | |         None => None,
-LL | |     };
-   | |_____^ help: try this: `Some(String::new()).as_mut().map(|x| x.push_str(""))`
+LL | /         match &mut Some(String::new()) {
+LL | |             Some(x) => Some(x.push_str("")),
+LL | |             None => None,
+LL | |         };
+   | |_________^ help: try this: `Some(String::new()).as_mut().map(|x| x.push_str(""))`
 
 error: manual implementation of `Option::map`
-  --> $DIR/manual_map_option.rs:74:5
+  --> $DIR/manual_map_option.rs:83:5
    |
 LL | /     match &mut Some(String::new()) {
-LL | |         Some(ref x) => Some(&**x),
+LL | |         Some(ref x) => Some(x.len()),
 LL | |         None => None,
 LL | |     };
-   | |_____^ help: try this: `Some(String::new()).as_ref().map(|x| &**x)`
+   | |_____^ help: try this: `Some(String::new()).as_ref().map(|x| x.len())`
 
 error: manual implementation of `Option::map`
-  --> $DIR/manual_map_option.rs:79:5
+  --> $DIR/manual_map_option.rs:88:5
    |
 LL | /     match &mut &Some(String::new()) {
 LL | |         Some(x) => Some(x.is_empty()),
@@ -128,7 +128,7 @@ LL | |     };
    | |_____^ help: try this: `Some(String::new()).as_ref().map(|x| x.is_empty())`
 
 error: manual implementation of `Option::map`
-  --> $DIR/manual_map_option.rs:84:5
+  --> $DIR/manual_map_option.rs:93:5
    |
 LL | /     match Some((0, 1, 2)) {
 LL | |         Some((x, y, z)) => Some(x + y + z),
@@ -137,7 +137,7 @@ LL | |     };
    | |_____^ help: try this: `Some((0, 1, 2)).map(|(x, y, z)| x + y + z)`
 
 error: manual implementation of `Option::map`
-  --> $DIR/manual_map_option.rs:89:5
+  --> $DIR/manual_map_option.rs:98:5
    |
 LL | /     match Some([1, 2, 3]) {
 LL | |         Some([first, ..]) => Some(first),
@@ -146,7 +146,7 @@ LL | |     };
    | |_____^ help: try this: `Some([1, 2, 3]).map(|[first, ..]| first)`
 
 error: manual implementation of `Option::map`
-  --> $DIR/manual_map_option.rs:94:5
+  --> $DIR/manual_map_option.rs:103:5
    |
 LL | /     match &Some((String::new(), "test")) {
 LL | |         Some((x, y)) => Some((y, x)),