]> git.lizzy.rs Git - rust.git/commitdiff
map_unit_fn: rename tests to fixable
authorManish Goregaokar <manishsmail@gmail.com>
Wed, 25 Sep 2019 15:39:45 +0000 (08:39 -0700)
committerManish Goregaokar <manishsmail@gmail.com>
Wed, 25 Sep 2019 21:45:18 +0000 (14:45 -0700)
tests/ui/option_map_unit_fn.rs [deleted file]
tests/ui/option_map_unit_fn.stderr [deleted file]
tests/ui/option_map_unit_fn_fixable.rs [new file with mode: 0644]
tests/ui/option_map_unit_fn_fixable.stderr [new file with mode: 0644]
tests/ui/result_map_unit_fn.rs [deleted file]
tests/ui/result_map_unit_fn.stderr [deleted file]
tests/ui/result_map_unit_fn_fixable.rs [new file with mode: 0644]
tests/ui/result_map_unit_fn_fixable.stderr [new file with mode: 0644]

diff --git a/tests/ui/option_map_unit_fn.rs b/tests/ui/option_map_unit_fn.rs
deleted file mode 100644 (file)
index 1d2a3a1..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-#![warn(clippy::option_map_unit_fn)]
-#![allow(unused)]
-
-fn do_nothing<T>(_: T) {}
-
-fn diverge<T>(_: T) -> ! {
-    panic!()
-}
-
-fn plus_one(value: usize) -> usize {
-    value + 1
-}
-
-struct HasOption {
-    field: Option<usize>,
-}
-
-impl HasOption {
-    fn do_option_nothing(self: &Self, value: usize) {}
-
-    fn do_option_plus_one(self: &Self, value: usize) -> usize {
-        value + 1
-    }
-}
-#[rustfmt::skip]
-fn option_map_unit_fn() {
-    let x = HasOption { field: Some(10) };
-
-    x.field.map(plus_one);
-    let _ : Option<()> = x.field.map(do_nothing);
-
-    x.field.map(do_nothing);
-
-    x.field.map(do_nothing);
-
-    x.field.map(diverge);
-
-    let captured = 10;
-    if let Some(value) = x.field { do_nothing(value + captured) };
-    let _ : Option<()> = x.field.map(|value| do_nothing(value + captured));
-
-    x.field.map(|value| x.do_option_nothing(value + captured));
-
-    x.field.map(|value| { x.do_option_plus_one(value + captured); });
-
-
-    x.field.map(|value| do_nothing(value + captured));
-
-    x.field.map(|value| { do_nothing(value + captured) });
-
-    x.field.map(|value| { do_nothing(value + captured); });
-
-    x.field.map(|value| { { do_nothing(value + captured); } });
-
-
-    x.field.map(|value| diverge(value + captured));
-
-    x.field.map(|value| { diverge(value + captured) });
-
-    x.field.map(|value| { diverge(value + captured); });
-
-    x.field.map(|value| { { diverge(value + captured); } });
-
-
-    x.field.map(|value| plus_one(value + captured));
-    x.field.map(|value| { plus_one(value + captured) });
-    x.field.map(|value| { let y = plus_one(value + captured); });
-
-    x.field.map(|value| { plus_one(value + captured); });
-
-    x.field.map(|value| { { plus_one(value + captured); } });
-
-
-    x.field.map(|ref value| { do_nothing(value + captured) });
-
-
-    x.field.map(|value| { do_nothing(value); do_nothing(value) });
-
-    x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) });
-
-    // Suggestion for the let block should be `{ ... }` as it's too difficult to build a
-    // proper suggestion for these cases
-    x.field.map(|value| {
-        do_nothing(value);
-        do_nothing(value)
-    });
-    x.field.map(|value| { do_nothing(value); do_nothing(value); });
-
-    // The following should suggest `if let Some(_X) ...` as it's difficult to generate a proper let variable name for them
-    Some(42).map(diverge);
-    "12".parse::<i32>().ok().map(diverge);
-    Some(plus_one(1)).map(do_nothing);
-
-    // Should suggest `if let Some(_y) ...` to not override the existing foo variable
-    let y = Some(42);
-    y.map(do_nothing);
-}
-
-fn main() {}
diff --git a/tests/ui/option_map_unit_fn.stderr b/tests/ui/option_map_unit_fn.stderr
deleted file mode 100644 (file)
index 16e355a..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-error: called `map(f)` on an Option value where `f` is a unit function
-  --> $DIR/option_map_unit_fn.rs:32:5
-   |
-LL |     x.field.map(do_nothing);
-   |     ^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(x_field) = x.field { do_nothing(...) }`
-   |
-   = note: `-D clippy::option-map-unit-fn` implied by `-D warnings`
-
-error: called `map(f)` on an Option value where `f` is a unit function
-  --> $DIR/option_map_unit_fn.rs:34:5
-   |
-LL |     x.field.map(do_nothing);
-   |     ^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(x_field) = x.field { do_nothing(...) }`
-
-error: called `map(f)` on an Option value where `f` is a unit function
-  --> $DIR/option_map_unit_fn.rs:36:5
-   |
-LL |     x.field.map(diverge);
-   |     ^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(x_field) = x.field { diverge(...) }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:42:5
-   |
-LL |     x.field.map(|value| x.do_option_nothing(value + captured));
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(value) = x.field { x.do_option_nothing(value + captured) }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:44:5
-   |
-LL |     x.field.map(|value| { x.do_option_plus_one(value + captured); });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(value) = x.field { x.do_option_plus_one(value + captured); }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:47:5
-   |
-LL |     x.field.map(|value| do_nothing(value + captured));
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:49:5
-   |
-LL |     x.field.map(|value| { do_nothing(value + captured) });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:51:5
-   |
-LL |     x.field.map(|value| { do_nothing(value + captured); });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:53:5
-   |
-LL |     x.field.map(|value| { { do_nothing(value + captured); } });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:56:5
-   |
-LL |     x.field.map(|value| diverge(value + captured));
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(value) = x.field { diverge(value + captured) }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:58:5
-   |
-LL |     x.field.map(|value| { diverge(value + captured) });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(value) = x.field { diverge(value + captured) }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:60:5
-   |
-LL |     x.field.map(|value| { diverge(value + captured); });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(value) = x.field { diverge(value + captured); }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:62:5
-   |
-LL |     x.field.map(|value| { { diverge(value + captured); } });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(value) = x.field { diverge(value + captured); }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:67:5
-   |
-LL |     x.field.map(|value| { let y = plus_one(value + captured); });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(value) = x.field { let y = plus_one(value + captured); }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:69:5
-   |
-LL |     x.field.map(|value| { plus_one(value + captured); });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(value) = x.field { plus_one(value + captured); }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:71:5
-   |
-LL |     x.field.map(|value| { { plus_one(value + captured); } });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(value) = x.field { plus_one(value + captured); }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:74:5
-   |
-LL |     x.field.map(|ref value| { do_nothing(value + captured) });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(ref value) = x.field { do_nothing(value + captured) }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:77:5
-   |
-LL |     x.field.map(|value| { do_nothing(value); do_nothing(value) });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(value) = x.field { ... }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:79:5
-   |
-LL |     x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(value) = x.field { ... }`
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:83:5
-   |
-LL |        x.field.map(|value| {
-   |   _____^
-   |  |_____|
-   | ||
-LL | ||         do_nothing(value);
-LL | ||         do_nothing(value)
-LL | ||     });
-   | ||______^- help: try this: `if let Some(value) = x.field { ... }`
-   | |_______|
-   | 
-
-error: called `map(f)` on an Option value where `f` is a unit closure
-  --> $DIR/option_map_unit_fn.rs:87:5
-   |
-LL |     x.field.map(|value| { do_nothing(value); do_nothing(value); });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(value) = x.field { ... }`
-
-error: called `map(f)` on an Option value where `f` is a unit function
-  --> $DIR/option_map_unit_fn.rs:90:5
-   |
-LL |     Some(42).map(diverge);
-   |     ^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(_) = Some(42) { diverge(...) }`
-
-error: called `map(f)` on an Option value where `f` is a unit function
-  --> $DIR/option_map_unit_fn.rs:91:5
-   |
-LL |     "12".parse::<i32>().ok().map(diverge);
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(_) = "12".parse::<i32>().ok() { diverge(...) }`
-
-error: called `map(f)` on an Option value where `f` is a unit function
-  --> $DIR/option_map_unit_fn.rs:92:5
-   |
-LL |     Some(plus_one(1)).map(do_nothing);
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(_) = Some(plus_one(1)) { do_nothing(...) }`
-
-error: called `map(f)` on an Option value where `f` is a unit function
-  --> $DIR/option_map_unit_fn.rs:96:5
-   |
-LL |     y.map(do_nothing);
-   |     ^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Some(_y) = y { do_nothing(...) }`
-
-error: aborting due to 25 previous errors
-
diff --git a/tests/ui/option_map_unit_fn_fixable.rs b/tests/ui/option_map_unit_fn_fixable.rs
new file mode 100644 (file)
index 0000000..1d2a3a1
--- /dev/null
@@ -0,0 +1,99 @@
+#![warn(clippy::option_map_unit_fn)]
+#![allow(unused)]
+
+fn do_nothing<T>(_: T) {}
+
+fn diverge<T>(_: T) -> ! {
+    panic!()
+}
+
+fn plus_one(value: usize) -> usize {
+    value + 1
+}
+
+struct HasOption {
+    field: Option<usize>,
+}
+
+impl HasOption {
+    fn do_option_nothing(self: &Self, value: usize) {}
+
+    fn do_option_plus_one(self: &Self, value: usize) -> usize {
+        value + 1
+    }
+}
+#[rustfmt::skip]
+fn option_map_unit_fn() {
+    let x = HasOption { field: Some(10) };
+
+    x.field.map(plus_one);
+    let _ : Option<()> = x.field.map(do_nothing);
+
+    x.field.map(do_nothing);
+
+    x.field.map(do_nothing);
+
+    x.field.map(diverge);
+
+    let captured = 10;
+    if let Some(value) = x.field { do_nothing(value + captured) };
+    let _ : Option<()> = x.field.map(|value| do_nothing(value + captured));
+
+    x.field.map(|value| x.do_option_nothing(value + captured));
+
+    x.field.map(|value| { x.do_option_plus_one(value + captured); });
+
+
+    x.field.map(|value| do_nothing(value + captured));
+
+    x.field.map(|value| { do_nothing(value + captured) });
+
+    x.field.map(|value| { do_nothing(value + captured); });
+
+    x.field.map(|value| { { do_nothing(value + captured); } });
+
+
+    x.field.map(|value| diverge(value + captured));
+
+    x.field.map(|value| { diverge(value + captured) });
+
+    x.field.map(|value| { diverge(value + captured); });
+
+    x.field.map(|value| { { diverge(value + captured); } });
+
+
+    x.field.map(|value| plus_one(value + captured));
+    x.field.map(|value| { plus_one(value + captured) });
+    x.field.map(|value| { let y = plus_one(value + captured); });
+
+    x.field.map(|value| { plus_one(value + captured); });
+
+    x.field.map(|value| { { plus_one(value + captured); } });
+
+
+    x.field.map(|ref value| { do_nothing(value + captured) });
+
+
+    x.field.map(|value| { do_nothing(value); do_nothing(value) });
+
+    x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) });
+
+    // Suggestion for the let block should be `{ ... }` as it's too difficult to build a
+    // proper suggestion for these cases
+    x.field.map(|value| {
+        do_nothing(value);
+        do_nothing(value)
+    });
+    x.field.map(|value| { do_nothing(value); do_nothing(value); });
+
+    // The following should suggest `if let Some(_X) ...` as it's difficult to generate a proper let variable name for them
+    Some(42).map(diverge);
+    "12".parse::<i32>().ok().map(diverge);
+    Some(plus_one(1)).map(do_nothing);
+
+    // Should suggest `if let Some(_y) ...` to not override the existing foo variable
+    let y = Some(42);
+    y.map(do_nothing);
+}
+
+fn main() {}
diff --git a/tests/ui/option_map_unit_fn_fixable.stderr b/tests/ui/option_map_unit_fn_fixable.stderr
new file mode 100644 (file)
index 0000000..4b61949
--- /dev/null
@@ -0,0 +1,210 @@
+error: called `map(f)` on an Option value where `f` is a unit function
+  --> $DIR/option_map_unit_fn_fixable.rs:32:5
+   |
+LL |     x.field.map(do_nothing);
+   |     ^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(x_field) = x.field { do_nothing(...) }`
+   |
+   = note: `-D clippy::option-map-unit-fn` implied by `-D warnings`
+
+error: called `map(f)` on an Option value where `f` is a unit function
+  --> $DIR/option_map_unit_fn_fixable.rs:34:5
+   |
+LL |     x.field.map(do_nothing);
+   |     ^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(x_field) = x.field { do_nothing(...) }`
+
+error: called `map(f)` on an Option value where `f` is a unit function
+  --> $DIR/option_map_unit_fn_fixable.rs:36:5
+   |
+LL |     x.field.map(diverge);
+   |     ^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(x_field) = x.field { diverge(...) }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:42:5
+   |
+LL |     x.field.map(|value| x.do_option_nothing(value + captured));
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(value) = x.field { x.do_option_nothing(value + captured) }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:44:5
+   |
+LL |     x.field.map(|value| { x.do_option_plus_one(value + captured); });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(value) = x.field { x.do_option_plus_one(value + captured); }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:47:5
+   |
+LL |     x.field.map(|value| do_nothing(value + captured));
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:49:5
+   |
+LL |     x.field.map(|value| { do_nothing(value + captured) });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(value) = x.field { do_nothing(value + captured) }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:51:5
+   |
+LL |     x.field.map(|value| { do_nothing(value + captured); });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:53:5
+   |
+LL |     x.field.map(|value| { { do_nothing(value + captured); } });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:56:5
+   |
+LL |     x.field.map(|value| diverge(value + captured));
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(value) = x.field { diverge(value + captured) }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:58:5
+   |
+LL |     x.field.map(|value| { diverge(value + captured) });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(value) = x.field { diverge(value + captured) }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:60:5
+   |
+LL |     x.field.map(|value| { diverge(value + captured); });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(value) = x.field { diverge(value + captured); }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:62:5
+   |
+LL |     x.field.map(|value| { { diverge(value + captured); } });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(value) = x.field { diverge(value + captured); }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:67:5
+   |
+LL |     x.field.map(|value| { let y = plus_one(value + captured); });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(value) = x.field { let y = plus_one(value + captured); }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:69:5
+   |
+LL |     x.field.map(|value| { plus_one(value + captured); });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(value) = x.field { plus_one(value + captured); }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:71:5
+   |
+LL |     x.field.map(|value| { { plus_one(value + captured); } });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(value) = x.field { plus_one(value + captured); }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:74:5
+   |
+LL |     x.field.map(|ref value| { do_nothing(value + captured) });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(ref value) = x.field { do_nothing(value + captured) }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:77:5
+   |
+LL |     x.field.map(|value| { do_nothing(value); do_nothing(value) });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(value) = x.field { ... }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:79:5
+   |
+LL |     x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(value) = x.field { ... }`
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:83:5
+   |
+LL |        x.field.map(|value| {
+   |   _____^
+   |  |_____|
+   | ||
+LL | ||         do_nothing(value);
+LL | ||         do_nothing(value)
+LL | ||     });
+   | ||______^- help: try this: `if let Some(value) = x.field { ... }`
+   | |_______|
+   | 
+
+error: called `map(f)` on an Option value where `f` is a unit closure
+  --> $DIR/option_map_unit_fn_fixable.rs:87:5
+   |
+LL |     x.field.map(|value| { do_nothing(value); do_nothing(value); });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(value) = x.field { ... }`
+
+error: called `map(f)` on an Option value where `f` is a unit function
+  --> $DIR/option_map_unit_fn_fixable.rs:90:5
+   |
+LL |     Some(42).map(diverge);
+   |     ^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(_) = Some(42) { diverge(...) }`
+
+error: called `map(f)` on an Option value where `f` is a unit function
+  --> $DIR/option_map_unit_fn_fixable.rs:91:5
+   |
+LL |     "12".parse::<i32>().ok().map(diverge);
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(_) = "12".parse::<i32>().ok() { diverge(...) }`
+
+error: called `map(f)` on an Option value where `f` is a unit function
+  --> $DIR/option_map_unit_fn_fixable.rs:92:5
+   |
+LL |     Some(plus_one(1)).map(do_nothing);
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(_) = Some(plus_one(1)) { do_nothing(...) }`
+
+error: called `map(f)` on an Option value where `f` is a unit function
+  --> $DIR/option_map_unit_fn_fixable.rs:96:5
+   |
+LL |     y.map(do_nothing);
+   |     ^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Some(_y) = y { do_nothing(...) }`
+
+error: aborting due to 25 previous errors
+
diff --git a/tests/ui/result_map_unit_fn.rs b/tests/ui/result_map_unit_fn.rs
deleted file mode 100644 (file)
index a8e891d..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-#![feature(never_type)]
-#![warn(clippy::result_map_unit_fn)]
-#![allow(unused)]
-
-fn do_nothing<T>(_: T) {}
-
-fn diverge<T>(_: T) -> ! {
-    panic!()
-}
-
-fn plus_one(value: usize) -> usize {
-    value + 1
-}
-
-struct HasResult {
-    field: Result<usize, usize>,
-}
-
-impl HasResult {
-    fn do_result_nothing(self: &Self, value: usize) {}
-
-    fn do_result_plus_one(self: &Self, value: usize) -> usize {
-        value + 1
-    }
-}
-
-#[rustfmt::skip]
-fn result_map_unit_fn() {
-    let x = HasResult { field: Ok(10) };
-
-    x.field.map(plus_one);
-    let _: Result<(), usize> = x.field.map(do_nothing);
-
-    x.field.map(do_nothing);
-
-    x.field.map(do_nothing);
-
-    x.field.map(diverge);
-
-    let captured = 10;
-    if let Ok(value) = x.field { do_nothing(value + captured) };
-    let _: Result<(), usize> = x.field.map(|value| do_nothing(value + captured));
-
-    x.field.map(|value| x.do_result_nothing(value + captured));
-
-    x.field.map(|value| { x.do_result_plus_one(value + captured); });
-
-
-    x.field.map(|value| do_nothing(value + captured));
-
-    x.field.map(|value| { do_nothing(value + captured) });
-
-    x.field.map(|value| { do_nothing(value + captured); });
-
-    x.field.map(|value| { { do_nothing(value + captured); } });
-
-
-    x.field.map(|value| diverge(value + captured));
-
-    x.field.map(|value| { diverge(value + captured) });
-
-    x.field.map(|value| { diverge(value + captured); });
-
-    x.field.map(|value| { { diverge(value + captured); } });
-
-
-    x.field.map(|value| plus_one(value + captured));
-    x.field.map(|value| { plus_one(value + captured) });
-    x.field.map(|value| { let y = plus_one(value + captured); });
-
-    x.field.map(|value| { plus_one(value + captured); });
-
-    x.field.map(|value| { { plus_one(value + captured); } });
-
-
-    x.field.map(|ref value| { do_nothing(value + captured) });
-
-
-    x.field.map(|value| { do_nothing(value); do_nothing(value) });
-
-    x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) });
-
-    // Suggestion for the let block should be `{ ... }` as it's too difficult to build a
-    // proper suggestion for these cases
-    x.field.map(|value| {
-        do_nothing(value);
-        do_nothing(value)
-    });
-    x.field.map(|value| { do_nothing(value); do_nothing(value); });
-
-    // The following should suggest `if let Ok(_X) ...` as it's difficult to generate a proper let variable name for them
-    let res: Result<!, usize> = Ok(42).map(diverge);
-    "12".parse::<i32>().map(diverge);
-
-    let res: Result<(), usize> = Ok(plus_one(1)).map(do_nothing);
-
-    // Should suggest `if let Ok(_y) ...` to not override the existing foo variable
-    let y: Result<usize, usize> = Ok(42);
-    y.map(do_nothing);
-}
-
-fn main() {}
diff --git a/tests/ui/result_map_unit_fn.stderr b/tests/ui/result_map_unit_fn.stderr
deleted file mode 100644 (file)
index 9f90251..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-error: called `map(f)` on an Result value where `f` is a unit function
-  --> $DIR/result_map_unit_fn.rs:34:5
-   |
-LL |     x.field.map(do_nothing);
-   |     ^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }`
-   |
-   = note: `-D clippy::result-map-unit-fn` implied by `-D warnings`
-
-error: called `map(f)` on an Result value where `f` is a unit function
-  --> $DIR/result_map_unit_fn.rs:36:5
-   |
-LL |     x.field.map(do_nothing);
-   |     ^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }`
-
-error: called `map(f)` on an Result value where `f` is a unit function
-  --> $DIR/result_map_unit_fn.rs:38:5
-   |
-LL |     x.field.map(diverge);
-   |     ^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(x_field) = x.field { diverge(...) }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:44:5
-   |
-LL |     x.field.map(|value| x.do_result_nothing(value + captured));
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(value) = x.field { x.do_result_nothing(value + captured) }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:46:5
-   |
-LL |     x.field.map(|value| { x.do_result_plus_one(value + captured); });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(value) = x.field { x.do_result_plus_one(value + captured); }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:49:5
-   |
-LL |     x.field.map(|value| do_nothing(value + captured));
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:51:5
-   |
-LL |     x.field.map(|value| { do_nothing(value + captured) });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:53:5
-   |
-LL |     x.field.map(|value| { do_nothing(value + captured); });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:55:5
-   |
-LL |     x.field.map(|value| { { do_nothing(value + captured); } });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:58:5
-   |
-LL |     x.field.map(|value| diverge(value + captured));
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(value) = x.field { diverge(value + captured) }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:60:5
-   |
-LL |     x.field.map(|value| { diverge(value + captured) });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(value) = x.field { diverge(value + captured) }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:62:5
-   |
-LL |     x.field.map(|value| { diverge(value + captured); });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(value) = x.field { diverge(value + captured); }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:64:5
-   |
-LL |     x.field.map(|value| { { diverge(value + captured); } });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(value) = x.field { diverge(value + captured); }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:69:5
-   |
-LL |     x.field.map(|value| { let y = plus_one(value + captured); });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(value) = x.field { let y = plus_one(value + captured); }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:71:5
-   |
-LL |     x.field.map(|value| { plus_one(value + captured); });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:73:5
-   |
-LL |     x.field.map(|value| { { plus_one(value + captured); } });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:76:5
-   |
-LL |     x.field.map(|ref value| { do_nothing(value + captured) });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(ref value) = x.field { do_nothing(value + captured) }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:79:5
-   |
-LL |     x.field.map(|value| { do_nothing(value); do_nothing(value) });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(value) = x.field { ... }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:81:5
-   |
-LL |     x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(value) = x.field { ... }`
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:85:5
-   |
-LL |        x.field.map(|value| {
-   |   _____^
-   |  |_____|
-   | ||
-LL | ||         do_nothing(value);
-LL | ||         do_nothing(value)
-LL | ||     });
-   | ||______^- help: try this: `if let Ok(value) = x.field { ... }`
-   | |_______|
-   | 
-
-error: called `map(f)` on an Result value where `f` is a unit closure
-  --> $DIR/result_map_unit_fn.rs:89:5
-   |
-LL |     x.field.map(|value| { do_nothing(value); do_nothing(value); });
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(value) = x.field { ... }`
-
-error: called `map(f)` on an Result value where `f` is a unit function
-  --> $DIR/result_map_unit_fn.rs:93:5
-   |
-LL |     "12".parse::<i32>().map(diverge);
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(_) = "12".parse::<i32>() { diverge(...) }`
-
-error: called `map(f)` on an Result value where `f` is a unit function
-  --> $DIR/result_map_unit_fn.rs:99:5
-   |
-LL |     y.map(do_nothing);
-   |     ^^^^^^^^^^^^^^^^^-
-   |     |
-   |     help: try this: `if let Ok(_y) = y { do_nothing(...) }`
-
-error: aborting due to 23 previous errors
-
diff --git a/tests/ui/result_map_unit_fn_fixable.rs b/tests/ui/result_map_unit_fn_fixable.rs
new file mode 100644 (file)
index 0000000..a8e891d
--- /dev/null
@@ -0,0 +1,102 @@
+#![feature(never_type)]
+#![warn(clippy::result_map_unit_fn)]
+#![allow(unused)]
+
+fn do_nothing<T>(_: T) {}
+
+fn diverge<T>(_: T) -> ! {
+    panic!()
+}
+
+fn plus_one(value: usize) -> usize {
+    value + 1
+}
+
+struct HasResult {
+    field: Result<usize, usize>,
+}
+
+impl HasResult {
+    fn do_result_nothing(self: &Self, value: usize) {}
+
+    fn do_result_plus_one(self: &Self, value: usize) -> usize {
+        value + 1
+    }
+}
+
+#[rustfmt::skip]
+fn result_map_unit_fn() {
+    let x = HasResult { field: Ok(10) };
+
+    x.field.map(plus_one);
+    let _: Result<(), usize> = x.field.map(do_nothing);
+
+    x.field.map(do_nothing);
+
+    x.field.map(do_nothing);
+
+    x.field.map(diverge);
+
+    let captured = 10;
+    if let Ok(value) = x.field { do_nothing(value + captured) };
+    let _: Result<(), usize> = x.field.map(|value| do_nothing(value + captured));
+
+    x.field.map(|value| x.do_result_nothing(value + captured));
+
+    x.field.map(|value| { x.do_result_plus_one(value + captured); });
+
+
+    x.field.map(|value| do_nothing(value + captured));
+
+    x.field.map(|value| { do_nothing(value + captured) });
+
+    x.field.map(|value| { do_nothing(value + captured); });
+
+    x.field.map(|value| { { do_nothing(value + captured); } });
+
+
+    x.field.map(|value| diverge(value + captured));
+
+    x.field.map(|value| { diverge(value + captured) });
+
+    x.field.map(|value| { diverge(value + captured); });
+
+    x.field.map(|value| { { diverge(value + captured); } });
+
+
+    x.field.map(|value| plus_one(value + captured));
+    x.field.map(|value| { plus_one(value + captured) });
+    x.field.map(|value| { let y = plus_one(value + captured); });
+
+    x.field.map(|value| { plus_one(value + captured); });
+
+    x.field.map(|value| { { plus_one(value + captured); } });
+
+
+    x.field.map(|ref value| { do_nothing(value + captured) });
+
+
+    x.field.map(|value| { do_nothing(value); do_nothing(value) });
+
+    x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) });
+
+    // Suggestion for the let block should be `{ ... }` as it's too difficult to build a
+    // proper suggestion for these cases
+    x.field.map(|value| {
+        do_nothing(value);
+        do_nothing(value)
+    });
+    x.field.map(|value| { do_nothing(value); do_nothing(value); });
+
+    // The following should suggest `if let Ok(_X) ...` as it's difficult to generate a proper let variable name for them
+    let res: Result<!, usize> = Ok(42).map(diverge);
+    "12".parse::<i32>().map(diverge);
+
+    let res: Result<(), usize> = Ok(plus_one(1)).map(do_nothing);
+
+    // Should suggest `if let Ok(_y) ...` to not override the existing foo variable
+    let y: Result<usize, usize> = Ok(42);
+    y.map(do_nothing);
+}
+
+fn main() {}
diff --git a/tests/ui/result_map_unit_fn_fixable.stderr b/tests/ui/result_map_unit_fn_fixable.stderr
new file mode 100644 (file)
index 0000000..29d1bd6
--- /dev/null
@@ -0,0 +1,194 @@
+error: called `map(f)` on an Result value where `f` is a unit function
+  --> $DIR/result_map_unit_fn_fixable.rs:34:5
+   |
+LL |     x.field.map(do_nothing);
+   |     ^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }`
+   |
+   = note: `-D clippy::result-map-unit-fn` implied by `-D warnings`
+
+error: called `map(f)` on an Result value where `f` is a unit function
+  --> $DIR/result_map_unit_fn_fixable.rs:36:5
+   |
+LL |     x.field.map(do_nothing);
+   |     ^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }`
+
+error: called `map(f)` on an Result value where `f` is a unit function
+  --> $DIR/result_map_unit_fn_fixable.rs:38:5
+   |
+LL |     x.field.map(diverge);
+   |     ^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(x_field) = x.field { diverge(...) }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:44:5
+   |
+LL |     x.field.map(|value| x.do_result_nothing(value + captured));
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(value) = x.field { x.do_result_nothing(value + captured) }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:46:5
+   |
+LL |     x.field.map(|value| { x.do_result_plus_one(value + captured); });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(value) = x.field { x.do_result_plus_one(value + captured); }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:49:5
+   |
+LL |     x.field.map(|value| do_nothing(value + captured));
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:51:5
+   |
+LL |     x.field.map(|value| { do_nothing(value + captured) });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:53:5
+   |
+LL |     x.field.map(|value| { do_nothing(value + captured); });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:55:5
+   |
+LL |     x.field.map(|value| { { do_nothing(value + captured); } });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:58:5
+   |
+LL |     x.field.map(|value| diverge(value + captured));
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(value) = x.field { diverge(value + captured) }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:60:5
+   |
+LL |     x.field.map(|value| { diverge(value + captured) });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(value) = x.field { diverge(value + captured) }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:62:5
+   |
+LL |     x.field.map(|value| { diverge(value + captured); });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(value) = x.field { diverge(value + captured); }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:64:5
+   |
+LL |     x.field.map(|value| { { diverge(value + captured); } });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(value) = x.field { diverge(value + captured); }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:69:5
+   |
+LL |     x.field.map(|value| { let y = plus_one(value + captured); });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(value) = x.field { let y = plus_one(value + captured); }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:71:5
+   |
+LL |     x.field.map(|value| { plus_one(value + captured); });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:73:5
+   |
+LL |     x.field.map(|value| { { plus_one(value + captured); } });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:76:5
+   |
+LL |     x.field.map(|ref value| { do_nothing(value + captured) });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(ref value) = x.field { do_nothing(value + captured) }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:79:5
+   |
+LL |     x.field.map(|value| { do_nothing(value); do_nothing(value) });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(value) = x.field { ... }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:81:5
+   |
+LL |     x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(value) = x.field { ... }`
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:85:5
+   |
+LL |        x.field.map(|value| {
+   |   _____^
+   |  |_____|
+   | ||
+LL | ||         do_nothing(value);
+LL | ||         do_nothing(value)
+LL | ||     });
+   | ||______^- help: try this: `if let Ok(value) = x.field { ... }`
+   | |_______|
+   | 
+
+error: called `map(f)` on an Result value where `f` is a unit closure
+  --> $DIR/result_map_unit_fn_fixable.rs:89:5
+   |
+LL |     x.field.map(|value| { do_nothing(value); do_nothing(value); });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(value) = x.field { ... }`
+
+error: called `map(f)` on an Result value where `f` is a unit function
+  --> $DIR/result_map_unit_fn_fixable.rs:93:5
+   |
+LL |     "12".parse::<i32>().map(diverge);
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(_) = "12".parse::<i32>() { diverge(...) }`
+
+error: called `map(f)` on an Result value where `f` is a unit function
+  --> $DIR/result_map_unit_fn_fixable.rs:99:5
+   |
+LL |     y.map(do_nothing);
+   |     ^^^^^^^^^^^^^^^^^-
+   |     |
+   |     help: try this: `if let Ok(_y) = y { do_nothing(...) }`
+
+error: aborting due to 23 previous errors
+