diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 87781e4e5f7..afad923a35a 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -145,7 +145,7 @@ pub mod lifetimes; pub mod literal_representation; pub mod loops; pub mod map_clone; -pub mod option_map_unit_fn; +pub mod map_unit_fn; pub mod matches; pub mod mem_forget; pub mod methods; @@ -406,7 +406,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { reg.register_late_lint_pass(box question_mark::QuestionMarkPass); reg.register_late_lint_pass(box suspicious_trait_impl::SuspiciousImpl); reg.register_late_lint_pass(box redundant_field_names::RedundantFieldNames); - reg.register_late_lint_pass(box option_map_unit_fn::Pass); + reg.register_late_lint_pass(box map_unit_fn::Pass); reg.register_lint_group("clippy_restriction", vec![ @@ -443,7 +443,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { if_not_else::IF_NOT_ELSE, infinite_iter::MAYBE_INFINITE_ITER, items_after_statements::ITEMS_AFTER_STATEMENTS, - option_map_unit_fn::OPTION_MAP_UNIT_FN, + map_unit_fn::OPTION_MAP_UNIT_FN, matches::SINGLE_MATCH_ELSE, methods::FILTER_MAP, methods::OPTION_MAP_UNWRAP_OR, diff --git a/clippy_lints/src/option_map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs similarity index 98% rename from clippy_lints/src/option_map_unit_fn.rs rename to clippy_lints/src/map_unit_fn.rs index abbeaabbdb2..97ff1141986 100644 --- a/clippy_lints/src/option_map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -19,7 +19,7 @@ pub struct Pass; /// **Example:** /// /// ```rust -/// let x : Option<&str> = do_stuff(); +/// let x: Option<&str> = do_stuff(); /// x.map(log_err_msg); /// x.map(|msg| log_err_msg(format_msg(msg))) /// ``` @@ -27,7 +27,7 @@ pub struct Pass; /// The correct use would be: /// /// ```rust -/// let x : Option<&str> = do_stuff(); +/// let x: Option<&str> = do_stuff(); /// if let Some(msg) = x { /// log_err_msg(msg) /// } diff --git a/tests/ui/map_unit_fn.stderr b/tests/ui/map_unit_fn.stderr new file mode 100644 index 00000000000..c4ee0ce9238 --- /dev/null +++ b/tests/ui/map_unit_fn.stderr @@ -0,0 +1,210 @@ +error: called `map(f)` on an Option value where `f` is a unit function + --> $DIR/map_unit_fn.rs:33:5 + | +33 | x.field.map(do_nothing); + | ^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(x_field) = x.field { do_nothing(...) }` + | + = note: `-D option-map-unit-fn` implied by `-D warnings` + +error: called `map(f)` on an Option value where `f` is a unit function + --> $DIR/map_unit_fn.rs:35:5 + | +35 | 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/map_unit_fn.rs:37:5 + | +37 | 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/map_unit_fn.rs:43:5 + | +43 | 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/map_unit_fn.rs:45:5 + | +45 | 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/map_unit_fn.rs:48:5 + | +48 | 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/map_unit_fn.rs:50:5 + | +50 | 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/map_unit_fn.rs:52:5 + | +52 | 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/map_unit_fn.rs:54:5 + | +54 | 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/map_unit_fn.rs:57:5 + | +57 | 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/map_unit_fn.rs:59:5 + | +59 | 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/map_unit_fn.rs:61:5 + | +61 | 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/map_unit_fn.rs:63:5 + | +63 | 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/map_unit_fn.rs:68:5 + | +68 | 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/map_unit_fn.rs:70:5 + | +70 | 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/map_unit_fn.rs:72:5 + | +72 | 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/map_unit_fn.rs:75:5 + | +75 | 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/map_unit_fn.rs:78:5 + | +78 | 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/map_unit_fn.rs:80:5 + | +80 | 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/map_unit_fn.rs:84:5 + | +84 | x.field.map(|value| { + | _____^ + | |_____| + | || +85 | || do_nothing(value); +86 | || do_nothing(value) +87 | || }); + | ||______^- help: try this: `if let Some(value) = x.field { ... }` + | |_______| + | + +error: called `map(f)` on an Option value where `f` is a unit closure + --> $DIR/map_unit_fn.rs:88:5 + | +88 | 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/map_unit_fn.rs:91:5 + | +91 | 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/map_unit_fn.rs:92:5 + | +92 | "12".parse::().ok().map(diverge); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | | + | help: try this: `if let Some(_) = "12".parse::().ok() { diverge(...) }` + +error: called `map(f)` on an Option value where `f` is a unit function + --> $DIR/map_unit_fn.rs:93:5 + | +93 | 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/map_unit_fn.rs:97:5 + | +97 | 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.rs b/tests/ui/option_map_unit_fn.rs index d9cfc62a51f..06531e29032 100644 --- a/tests/ui/option_map_unit_fn.rs +++ b/tests/ui/option_map_unit_fn.rs @@ -23,8 +23,7 @@ impl HasOption { } } -#[cfg_attr(rustfmt, rustfmt_skip)] -fn main() { +fn option_map_unit_fn() { let x = HasOption { field: Some(10) }; x.field.map(plus_one); @@ -96,3 +95,6 @@ fn main() { 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 index bd19fe05329..3ca57a65b3f 100644 --- a/tests/ui/option_map_unit_fn.stderr +++ b/tests/ui/option_map_unit_fn.stderr @@ -1,7 +1,7 @@ error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:33:5 + --> $DIR/option_map_unit_fn.rs:32:5 | -33 | x.field.map(do_nothing); +32 | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(x_field) = x.field { do_nothing(...) }` @@ -9,199 +9,199 @@ error: called `map(f)` on an Option value where `f` is a unit function = note: `-D 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:35:5 + --> $DIR/option_map_unit_fn.rs:34:5 | -35 | x.field.map(do_nothing); +34 | 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:37:5 + --> $DIR/option_map_unit_fn.rs:36:5 | -37 | x.field.map(diverge); +36 | 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:43:5 + --> $DIR/option_map_unit_fn.rs:42:5 | -43 | x.field.map(|value| x.do_option_nothing(value + captured)); +42 | 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:45:5 + --> $DIR/option_map_unit_fn.rs:44:5 | -45 | x.field.map(|value| { x.do_option_plus_one(value + captured); }); +44 | 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:48:5 + --> $DIR/option_map_unit_fn.rs:47:5 | -48 | x.field.map(|value| do_nothing(value + captured)); +47 | 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:50:5 + --> $DIR/option_map_unit_fn.rs:49:5 | -50 | x.field.map(|value| { do_nothing(value + captured) }); +49 | 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:52:5 + --> $DIR/option_map_unit_fn.rs:51:5 | -52 | x.field.map(|value| { do_nothing(value + captured); }); +51 | 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:54:5 + --> $DIR/option_map_unit_fn.rs:53:5 | -54 | x.field.map(|value| { { do_nothing(value + captured); } }); +53 | 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:57:5 + --> $DIR/option_map_unit_fn.rs:56:5 | -57 | x.field.map(|value| diverge(value + captured)); +56 | 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:59:5 + --> $DIR/option_map_unit_fn.rs:58:5 | -59 | x.field.map(|value| { diverge(value + captured) }); +58 | 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:61:5 + --> $DIR/option_map_unit_fn.rs:60:5 | -61 | x.field.map(|value| { diverge(value + captured); }); +60 | 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:63:5 + --> $DIR/option_map_unit_fn.rs:62:5 | -63 | x.field.map(|value| { { diverge(value + captured); } }); +62 | 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:68:5 + --> $DIR/option_map_unit_fn.rs:67:5 | -68 | x.field.map(|value| { let y = plus_one(value + captured); }); +67 | 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:70:5 + --> $DIR/option_map_unit_fn.rs:69:5 | -70 | x.field.map(|value| { plus_one(value + captured); }); +69 | 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:72:5 + --> $DIR/option_map_unit_fn.rs:71:5 | -72 | x.field.map(|value| { { plus_one(value + captured); } }); +71 | 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:75:5 + --> $DIR/option_map_unit_fn.rs:74:5 | -75 | x.field.map(|ref value| { do_nothing(value + captured) }); +74 | 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:78:5 + --> $DIR/option_map_unit_fn.rs:77:5 | -78 | x.field.map(|value| { do_nothing(value); do_nothing(value) }); +77 | 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:80:5 + --> $DIR/option_map_unit_fn.rs:79:5 | -80 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); +79 | 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:84:5 + --> $DIR/option_map_unit_fn.rs:83:5 | -84 | x.field.map(|value| { +83 | x.field.map(|value| { | _____^ | |_____| | || -85 | || do_nothing(value); -86 | || do_nothing(value) -87 | || }); +84 | || do_nothing(value); +85 | || do_nothing(value) +86 | || }); | ||______^- 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:88:5 + --> $DIR/option_map_unit_fn.rs:87:5 | -88 | x.field.map(|value| { do_nothing(value); do_nothing(value); }); +87 | 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:91:5 + --> $DIR/option_map_unit_fn.rs:90:5 | -91 | Some(42).map(diverge); +90 | 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:92:5 + --> $DIR/option_map_unit_fn.rs:91:5 | -92 | "12".parse::().ok().map(diverge); +91 | "12".parse::().ok().map(diverge); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_) = "12".parse::().ok() { diverge(...) }` error: called `map(f)` on an Option value where `f` is a unit function - --> $DIR/option_map_unit_fn.rs:93:5 + --> $DIR/option_map_unit_fn.rs:92:5 | -93 | Some(plus_one(1)).map(do_nothing); +92 | 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:97:5 + --> $DIR/option_map_unit_fn.rs:96:5 | -97 | y.map(do_nothing); +96 | y.map(do_nothing); | ^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Some(_y) = y { do_nothing(...) }`