mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
tests: fix more cases where rustfmt would have hurt the tests
This commit is contained in:
parent
f1d5194e3d
commit
625ca772b5
6 changed files with 279 additions and 452 deletions
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::all)]
|
#![warn(clippy::all)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(unused_assignments)]
|
#![allow(unused_assignments)]
|
||||||
|
|
|
@ -1,87 +1,87 @@
|
||||||
error: this looks like an `else if` but the `else` is missing
|
error: this looks like an `else if` but the `else` is missing
|
||||||
--> $DIR/formatting.rs:25:6
|
--> $DIR/formatting.rs:21:6
|
||||||
|
|
|
|
||||||
25 | } if foo() {
|
21 | } if foo() {
|
||||||
| ^
|
| ^
|
||||||
|
|
|
|
||||||
= note: `-D clippy::suspicious-else-formatting` implied by `-D warnings`
|
= note: `-D clippy::suspicious-else-formatting` implied by `-D warnings`
|
||||||
= note: to remove this lint, add the missing `else` or add a new line before the second `if`
|
= note: to remove this lint, add the missing `else` or add a new line before the second `if`
|
||||||
|
|
||||||
error: this looks like an `else if` but the `else` is missing
|
error: this looks like an `else if` but the `else` is missing
|
||||||
--> $DIR/formatting.rs:32:10
|
--> $DIR/formatting.rs:28:10
|
||||||
|
|
|
|
||||||
32 | } if foo() {
|
28 | } if foo() {
|
||||||
| ^
|
| ^
|
||||||
|
|
|
|
||||||
= note: to remove this lint, add the missing `else` or add a new line before the second `if`
|
= note: to remove this lint, add the missing `else` or add a new line before the second `if`
|
||||||
|
|
||||||
error: this looks like an `else if` but the `else` is missing
|
error: this looks like an `else if` but the `else` is missing
|
||||||
--> $DIR/formatting.rs:40:10
|
--> $DIR/formatting.rs:36:10
|
||||||
|
|
|
|
||||||
40 | } if foo() {
|
36 | } if foo() {
|
||||||
| ^
|
| ^
|
||||||
|
|
|
|
||||||
= note: to remove this lint, add the missing `else` or add a new line before the second `if`
|
= note: to remove this lint, add the missing `else` or add a new line before the second `if`
|
||||||
|
|
||||||
error: this is an `else if` but the formatting might hide it
|
error: this is an `else if` but the formatting might hide it
|
||||||
--> $DIR/formatting.rs:49:6
|
--> $DIR/formatting.rs:45:6
|
||||||
|
|
|
|
||||||
49 | } else
|
45 | } else
|
||||||
| ______^
|
| ______^
|
||||||
50 | | if foo() { // the span of the above error should continue here
|
46 | | if foo() { // the span of the above error should continue here
|
||||||
| |____^
|
| |____^
|
||||||
|
|
|
|
||||||
= note: to remove this lint, remove the `else` or remove the new line between `else` and `if`
|
= note: to remove this lint, remove the `else` or remove the new line between `else` and `if`
|
||||||
|
|
||||||
error: this is an `else if` but the formatting might hide it
|
error: this is an `else if` but the formatting might hide it
|
||||||
--> $DIR/formatting.rs:54:6
|
--> $DIR/formatting.rs:50:6
|
||||||
|
|
|
|
||||||
54 | }
|
50 | }
|
||||||
| ______^
|
| ______^
|
||||||
55 | | else
|
51 | | else
|
||||||
56 | | if foo() { // the span of the above error should continue here
|
52 | | if foo() { // the span of the above error should continue here
|
||||||
| |____^
|
| |____^
|
||||||
|
|
|
|
||||||
= note: to remove this lint, remove the `else` or remove the new line between `else` and `if`
|
= note: to remove this lint, remove the `else` or remove the new line between `else` and `if`
|
||||||
|
|
||||||
error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)`
|
error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)`
|
||||||
--> $DIR/formatting.rs:81:6
|
--> $DIR/formatting.rs:77:6
|
||||||
|
|
|
|
||||||
81 | a =- 35;
|
77 | a =- 35;
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
= note: `-D clippy::suspicious-assignment-formatting` implied by `-D warnings`
|
= note: `-D clippy::suspicious-assignment-formatting` implied by `-D warnings`
|
||||||
= note: to remove this lint, use either `-=` or `= -`
|
= note: to remove this lint, use either `-=` or `= -`
|
||||||
|
|
||||||
error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)`
|
error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)`
|
||||||
--> $DIR/formatting.rs:82:6
|
--> $DIR/formatting.rs:78:6
|
||||||
|
|
|
|
||||||
82 | a =* &191;
|
78 | a =* &191;
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
= note: to remove this lint, use either `*=` or `= *`
|
= note: to remove this lint, use either `*=` or `= *`
|
||||||
|
|
||||||
error: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)`
|
error: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)`
|
||||||
--> $DIR/formatting.rs:85:6
|
--> $DIR/formatting.rs:81:6
|
||||||
|
|
|
|
||||||
85 | b =! false;
|
81 | b =! false;
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
= note: to remove this lint, use either `!=` or `= !`
|
= note: to remove this lint, use either `!=` or `= !`
|
||||||
|
|
||||||
|
error: possibly missing a comma here
|
||||||
|
--> $DIR/formatting.rs:90:19
|
||||||
|
|
|
||||||
|
90 | -1, -2, -3 // <= no comma here
|
||||||
|
| ^
|
||||||
|
|
|
||||||
|
= note: `-D clippy::possible-missing-comma` implied by `-D warnings`
|
||||||
|
= note: to remove this lint, add a comma or write the expr in a single line
|
||||||
|
|
||||||
error: possibly missing a comma here
|
error: possibly missing a comma here
|
||||||
--> $DIR/formatting.rs:94:19
|
--> $DIR/formatting.rs:94:19
|
||||||
|
|
|
|
||||||
94 | -1, -2, -3 // <= no comma here
|
94 | -1, -2, -3 // <= no comma here
|
||||||
| ^
|
|
||||||
|
|
|
||||||
= note: `-D clippy::possible-missing-comma` implied by `-D warnings`
|
|
||||||
= note: to remove this lint, add a comma or write the expr in a single line
|
|
||||||
|
|
||||||
error: possibly missing a comma here
|
|
||||||
--> $DIR/formatting.rs:98:19
|
|
||||||
|
|
|
||||||
98 | -1, -2, -3 // <= no comma here
|
|
||||||
| ^
|
| ^
|
||||||
|
|
|
|
||||||
= note: to remove this lint, add a comma or write the expr in a single line
|
= note: to remove this lint, add a comma or write the expr in a single line
|
||||||
|
|
|
@ -31,12 +31,12 @@ impl HasOption {
|
||||||
value + 1
|
value + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[rustfmt::skip]
|
||||||
fn option_map_unit_fn() {
|
fn option_map_unit_fn() {
|
||||||
let x = HasOption { field: Some(10) };
|
let x = HasOption { field: Some(10) };
|
||||||
|
|
||||||
x.field.map(plus_one);
|
x.field.map(plus_one);
|
||||||
let _: Option<()> = x.field.map(do_nothing);
|
let _ : Option<()> = x.field.map(do_nothing);
|
||||||
|
|
||||||
x.field.map(do_nothing);
|
x.field.map(do_nothing);
|
||||||
|
|
||||||
|
@ -45,68 +45,47 @@ fn option_map_unit_fn() {
|
||||||
x.field.map(diverge);
|
x.field.map(diverge);
|
||||||
|
|
||||||
let captured = 10;
|
let captured = 10;
|
||||||
if let Some(value) = x.field {
|
if let Some(value) = x.field { do_nothing(value + captured) };
|
||||||
do_nothing(value + captured)
|
let _ : Option<()> = x.field.map(|value| 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_nothing(value + captured));
|
||||||
|
|
||||||
x.field.map(|value| {
|
x.field.map(|value| { x.do_option_plus_one(value + captured); });
|
||||||
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| {
|
x.field.map(|value| { do_nothing(value + captured); });
|
||||||
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| {
|
x.field.map(|value| { diverge(value + captured); });
|
||||||
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| plus_one(value + captured));
|
x.field.map(|value| { plus_one(value + captured) });
|
||||||
x.field.map(|value| {
|
x.field.map(|value| { let y = plus_one(value + captured); });
|
||||||
let y = plus_one(value + captured);
|
|
||||||
});
|
|
||||||
|
|
||||||
x.field.map(|value| {
|
x.field.map(|value| { plus_one(value + captured); });
|
||||||
plus_one(value + captured);
|
|
||||||
});
|
|
||||||
|
|
||||||
x.field.map(|value| {
|
x.field.map(|value| { { plus_one(value + captured); } });
|
||||||
plus_one(value + captured);
|
|
||||||
});
|
|
||||||
|
|
||||||
x.field.map(|ref value| do_nothing(value + captured));
|
|
||||||
|
|
||||||
x.field.map(|value| {
|
x.field.map(|ref value| { do_nothing(value + captured) });
|
||||||
do_nothing(value);
|
|
||||||
do_nothing(value)
|
|
||||||
});
|
|
||||||
|
|
||||||
x.field.map(|value| {
|
|
||||||
if value > 0 {
|
x.field.map(|value| { do_nothing(value); do_nothing(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
|
// Suggestion for the let block should be `{ ... }` as it's too difficult to build a
|
||||||
// proper suggestion for these cases
|
// proper suggestion for these cases
|
||||||
|
@ -114,13 +93,9 @@ fn option_map_unit_fn() {
|
||||||
do_nothing(value);
|
do_nothing(value);
|
||||||
do_nothing(value)
|
do_nothing(value)
|
||||||
});
|
});
|
||||||
x.field.map(|value| {
|
x.field.map(|value| { do_nothing(value); do_nothing(value); });
|
||||||
do_nothing(value);
|
|
||||||
do_nothing(value);
|
|
||||||
});
|
|
||||||
|
|
||||||
// The following should suggest `if let Some(_X) ...` as it's difficult to generate a proper let
|
// The following should suggest `if let Some(_X) ...` as it's difficult to generate a proper let variable name for them
|
||||||
// variable name for them
|
|
||||||
Some(42).map(diverge);
|
Some(42).map(diverge);
|
||||||
"12".parse::<i32>().ok().map(diverge);
|
"12".parse::<i32>().ok().map(diverge);
|
||||||
Some(plus_one(1)).map(do_nothing);
|
Some(plus_one(1)).map(do_nothing);
|
||||||
|
|
|
@ -25,243 +25,183 @@ error: called `map(f)` on an Option value where `f` is a unit function
|
||||||
| help: try this: `if let Some(x_field) = x.field { 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
|
error: called `map(f)` on an Option value where `f` is a unit closure
|
||||||
--> $DIR/option_map_unit_fn.rs:53:5
|
--> $DIR/option_map_unit_fn.rs:51:5
|
||||||
|
|
|
|
||||||
53 | x.field.map(|value| x.do_option_nothing(value + captured));
|
51 | 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) }`
|
| 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
|
error: called `map(f)` on an Option value where `f` is a unit closure
|
||||||
--> $DIR/option_map_unit_fn.rs:55:5
|
--> $DIR/option_map_unit_fn.rs:53:5
|
||||||
|
|
|
|
||||||
55 | x.field.map(|value| {
|
53 | 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); }`
|
||||||
56 | || x.do_option_plus_one(value + captured);
|
|
||||||
57 | || });
|
|
||||||
| ||______^- 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
|
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:56:5
|
||||||
|
|
|
|
||||||
59 | x.field.map(|value| do_nothing(value + captured));
|
56 | x.field.map(|value| do_nothing(value + captured));
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Some(value) = x.field { 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
|
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:58:5
|
||||||
|
|
|
|
||||||
61 | x.field.map(|value| do_nothing(value + captured));
|
58 | x.field.map(|value| { do_nothing(value + captured) });
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Some(value) = x.field { 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
|
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:60:5
|
||||||
|
|
|
|
||||||
63 | x.field.map(|value| {
|
60 | x.field.map(|value| { do_nothing(value + captured); });
|
||||||
| _____^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |_____|
|
| |
|
||||||
| ||
|
| help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }`
|
||||||
64 | || do_nothing(value + captured);
|
|
||||||
65 | || });
|
error: called `map(f)` on an Option value where `f` is a unit closure
|
||||||
| ||______^- help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }`
|
--> $DIR/option_map_unit_fn.rs:62:5
|
||||||
| |_______|
|
|
|
||||||
|
|
62 | 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:65:5
|
||||||
|
|
|
||||||
|
65 | 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
|
error: called `map(f)` on an Option value where `f` is a unit closure
|
||||||
--> $DIR/option_map_unit_fn.rs:67:5
|
--> $DIR/option_map_unit_fn.rs:67:5
|
||||||
|
|
|
|
||||||
67 | x.field.map(|value| {
|
67 | x.field.map(|value| { diverge(value + captured) });
|
||||||
| _____^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |_____|
|
| |
|
||||||
| ||
|
| help: try this: `if let Some(value) = x.field { diverge(value + captured) }`
|
||||||
68 | || do_nothing(value + captured);
|
|
||||||
69 | || });
|
error: called `map(f)` on an Option value where `f` is a unit closure
|
||||||
| ||______^- help: try this: `if let Some(value) = x.field { do_nothing(value + captured); }`
|
--> $DIR/option_map_unit_fn.rs:69:5
|
||||||
| |_______|
|
|
|
||||||
|
|
69 | 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
|
error: called `map(f)` on an Option value where `f` is a unit closure
|
||||||
--> $DIR/option_map_unit_fn.rs:71:5
|
--> $DIR/option_map_unit_fn.rs:71:5
|
||||||
|
|
|
|
||||||
71 | x.field.map(|value| diverge(value + captured));
|
71 | x.field.map(|value| { { diverge(value + captured); } });
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Some(value) = x.field { 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
|
error: called `map(f)` on an Option value where `f` is a unit closure
|
||||||
--> $DIR/option_map_unit_fn.rs:73:5
|
--> $DIR/option_map_unit_fn.rs:76:5
|
||||||
|
|
|
|
||||||
73 | x.field.map(|value| diverge(value + captured));
|
76 | x.field.map(|value| { let y = plus_one(value + captured); });
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Some(value) = x.field { diverge(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
|
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:78:5
|
||||||
|
|
|
|
||||||
75 | x.field.map(|value| {
|
78 | x.field.map(|value| { plus_one(value + captured); });
|
||||||
| _____^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |_____|
|
| |
|
||||||
| ||
|
| help: try this: `if let Some(value) = x.field { plus_one(value + captured); }`
|
||||||
76 | || diverge(value + captured);
|
|
||||||
77 | || });
|
|
||||||
| ||______^- 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
|
error: called `map(f)` on an Option value where `f` is a unit closure
|
||||||
--> $DIR/option_map_unit_fn.rs:79:5
|
--> $DIR/option_map_unit_fn.rs:80:5
|
||||||
|
|
|
|
||||||
79 | x.field.map(|value| {
|
80 | x.field.map(|value| { { plus_one(value + captured); } });
|
||||||
| _____^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |_____|
|
| |
|
||||||
| ||
|
| help: try this: `if let Some(value) = x.field { plus_one(value + captured); }`
|
||||||
80 | || diverge(value + captured);
|
|
||||||
81 | || });
|
|
||||||
| ||______^- 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
|
error: called `map(f)` on an Option value where `f` is a unit closure
|
||||||
--> $DIR/option_map_unit_fn.rs:85:5
|
--> $DIR/option_map_unit_fn.rs:83:5
|
||||||
|
|
|
|
||||||
85 | x.field.map(|value| {
|
83 | x.field.map(|ref value| { do_nothing(value + captured) });
|
||||||
| _____^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |_____|
|
|
||||||
| ||
|
|
||||||
86 | || let y = plus_one(value + captured);
|
|
||||||
87 | || });
|
|
||||||
| ||______^- 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:89:5
|
|
||||||
|
|
|
||||||
89 | x.field.map(|value| {
|
|
||||||
| _____^
|
|
||||||
| |_____|
|
|
||||||
| ||
|
|
||||||
90 | || plus_one(value + captured);
|
|
||||||
91 | || });
|
|
||||||
| ||______^- 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:93:5
|
|
||||||
|
|
|
||||||
93 | x.field.map(|value| {
|
|
||||||
| _____^
|
|
||||||
| |_____|
|
|
||||||
| ||
|
|
||||||
94 | || plus_one(value + captured);
|
|
||||||
95 | || });
|
|
||||||
| ||______^- 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:97:5
|
|
||||||
|
|
|
||||||
97 | x.field.map(|ref value| do_nothing(value + captured));
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Some(ref value) = x.field { 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
|
error: called `map(f)` on an Option value where `f` is a unit closure
|
||||||
--> $DIR/option_map_unit_fn.rs:99:5
|
--> $DIR/option_map_unit_fn.rs:86:5
|
||||||
|
|
|
|
||||||
99 | x.field.map(|value| {
|
86 | x.field.map(|value| { do_nothing(value); do_nothing(value) });
|
||||||
| _____^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |_____|
|
| |
|
||||||
| ||
|
| help: try this: `if let Some(value) = x.field { ... }`
|
||||||
100 | || do_nothing(value);
|
|
||||||
101 | || do_nothing(value)
|
|
||||||
102 | || });
|
|
||||||
| ||______^- help: try this: `if let Some(value) = x.field { ... }`
|
|
||||||
| |_______|
|
|
||||||
|
|
|
||||||
|
|
||||||
error: called `map(f)` on an Option value where `f` is a unit closure
|
error: called `map(f)` on an Option value where `f` is a unit closure
|
||||||
--> $DIR/option_map_unit_fn.rs:104:5
|
--> $DIR/option_map_unit_fn.rs:88:5
|
||||||
|
|
|
|
||||||
104 | x.field.map(|value| {
|
88 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) });
|
||||||
| _____^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |_____|
|
| |
|
||||||
| ||
|
| help: try this: `if let Some(value) = x.field { ... }`
|
||||||
105 | || if value > 0 {
|
|
||||||
106 | || do_nothing(value);
|
|
||||||
107 | || do_nothing(value)
|
|
||||||
108 | || }
|
|
||||||
109 | || });
|
|
||||||
| ||______^- help: try this: `if let Some(value) = x.field { ... }`
|
|
||||||
| |_______|
|
|
||||||
|
|
|
||||||
|
|
||||||
error: called `map(f)` on an Option value where `f` is a unit closure
|
error: called `map(f)` on an Option value where `f` is a unit closure
|
||||||
--> $DIR/option_map_unit_fn.rs:113:5
|
--> $DIR/option_map_unit_fn.rs:92:5
|
||||||
|
|
|
|
||||||
113 | x.field.map(|value| {
|
92 | x.field.map(|value| {
|
||||||
| _____^
|
| _____^
|
||||||
| |_____|
|
| |_____|
|
||||||
| ||
|
| ||
|
||||||
114 | || do_nothing(value);
|
93 | || do_nothing(value);
|
||||||
115 | || do_nothing(value)
|
94 | || do_nothing(value)
|
||||||
116 | || });
|
95 | || });
|
||||||
| ||______^- help: try this: `if let Some(value) = x.field { ... }`
|
| ||______^- help: try this: `if let Some(value) = x.field { ... }`
|
||||||
| |_______|
|
| |_______|
|
||||||
|
|
|
|
||||||
|
|
||||||
error: called `map(f)` on an Option value where `f` is a unit closure
|
error: called `map(f)` on an Option value where `f` is a unit closure
|
||||||
--> $DIR/option_map_unit_fn.rs:117:5
|
--> $DIR/option_map_unit_fn.rs:96:5
|
||||||
|
|
|
|
||||||
117 | x.field.map(|value| {
|
96 | x.field.map(|value| { do_nothing(value); do_nothing(value); });
|
||||||
| _____^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |_____|
|
| |
|
||||||
| ||
|
| help: try this: `if let Some(value) = x.field { ... }`
|
||||||
118 | || do_nothing(value);
|
|
||||||
119 | || do_nothing(value);
|
|
||||||
120 | || });
|
|
||||||
| ||______^- help: try this: `if let Some(value) = x.field { ... }`
|
|
||||||
| |_______|
|
|
||||||
|
|
|
||||||
|
|
||||||
error: called `map(f)` on an Option value where `f` is a unit function
|
error: called `map(f)` on an Option value where `f` is a unit function
|
||||||
--> $DIR/option_map_unit_fn.rs:124:5
|
--> $DIR/option_map_unit_fn.rs:99:5
|
||||||
|
|
|
|
||||||
124 | Some(42).map(diverge);
|
99 | Some(42).map(diverge);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Some(_) = Some(42) { diverge(...) }`
|
| help: try this: `if let Some(_) = Some(42) { diverge(...) }`
|
||||||
|
|
||||||
error: called `map(f)` on an Option value where `f` is a unit function
|
error: called `map(f)` on an Option value where `f` is a unit function
|
||||||
--> $DIR/option_map_unit_fn.rs:125:5
|
--> $DIR/option_map_unit_fn.rs:100:5
|
||||||
|
|
|
|
||||||
125 | "12".parse::<i32>().ok().map(diverge);
|
100 | "12".parse::<i32>().ok().map(diverge);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Some(_) = "12".parse::<i32>().ok() { 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
|
error: called `map(f)` on an Option value where `f` is a unit function
|
||||||
--> $DIR/option_map_unit_fn.rs:126:5
|
--> $DIR/option_map_unit_fn.rs:101:5
|
||||||
|
|
|
|
||||||
126 | Some(plus_one(1)).map(do_nothing);
|
101 | Some(plus_one(1)).map(do_nothing);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Some(_) = Some(plus_one(1)) { 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
|
error: called `map(f)` on an Option value where `f` is a unit function
|
||||||
--> $DIR/option_map_unit_fn.rs:130:5
|
--> $DIR/option_map_unit_fn.rs:105:5
|
||||||
|
|
|
|
||||||
130 | y.map(do_nothing);
|
105 | y.map(do_nothing);
|
||||||
| ^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Some(_y) = y { do_nothing(...) }`
|
| help: try this: `if let Some(_y) = y { do_nothing(...) }`
|
||||||
|
|
|
@ -33,6 +33,7 @@ impl HasResult {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
fn result_map_unit_fn() {
|
fn result_map_unit_fn() {
|
||||||
let x = HasResult { field: Ok(10) };
|
let x = HasResult { field: Ok(10) };
|
||||||
|
|
||||||
|
@ -46,68 +47,47 @@ fn result_map_unit_fn() {
|
||||||
x.field.map(diverge);
|
x.field.map(diverge);
|
||||||
|
|
||||||
let captured = 10;
|
let captured = 10;
|
||||||
if let Ok(value) = x.field {
|
if let Ok(value) = x.field { do_nothing(value + captured) };
|
||||||
do_nothing(value + captured)
|
|
||||||
};
|
|
||||||
let _: Result<(), usize> = x.field.map(|value| 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_nothing(value + captured));
|
||||||
|
|
||||||
x.field.map(|value| {
|
x.field.map(|value| { x.do_result_plus_one(value + captured); });
|
||||||
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| {
|
x.field.map(|value| { do_nothing(value + captured); });
|
||||||
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| {
|
x.field.map(|value| { diverge(value + captured); });
|
||||||
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| plus_one(value + captured));
|
x.field.map(|value| { plus_one(value + captured) });
|
||||||
x.field.map(|value| {
|
x.field.map(|value| { let y = plus_one(value + captured); });
|
||||||
let y = plus_one(value + captured);
|
|
||||||
});
|
|
||||||
|
|
||||||
x.field.map(|value| {
|
x.field.map(|value| { plus_one(value + captured); });
|
||||||
plus_one(value + captured);
|
|
||||||
});
|
|
||||||
|
|
||||||
x.field.map(|value| {
|
x.field.map(|value| { { plus_one(value + captured); } });
|
||||||
plus_one(value + captured);
|
|
||||||
});
|
|
||||||
|
|
||||||
x.field.map(|ref value| do_nothing(value + captured));
|
|
||||||
|
|
||||||
x.field.map(|value| {
|
x.field.map(|ref value| { do_nothing(value + captured) });
|
||||||
do_nothing(value);
|
|
||||||
do_nothing(value)
|
|
||||||
});
|
|
||||||
|
|
||||||
x.field.map(|value| {
|
|
||||||
if value > 0 {
|
x.field.map(|value| { do_nothing(value); do_nothing(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
|
// Suggestion for the let block should be `{ ... }` as it's too difficult to build a
|
||||||
// proper suggestion for these cases
|
// proper suggestion for these cases
|
||||||
|
@ -115,13 +95,9 @@ fn result_map_unit_fn() {
|
||||||
do_nothing(value);
|
do_nothing(value);
|
||||||
do_nothing(value)
|
do_nothing(value)
|
||||||
});
|
});
|
||||||
x.field.map(|value| {
|
x.field.map(|value| { do_nothing(value); do_nothing(value); });
|
||||||
do_nothing(value);
|
|
||||||
do_nothing(value);
|
|
||||||
});
|
|
||||||
|
|
||||||
// The following should suggest `if let Ok(_X) ...` as it's difficult to generate a proper let
|
// The following should suggest `if let Ok(_X) ...` as it's difficult to generate a proper let variable name for them
|
||||||
// variable name for them
|
|
||||||
let res: Result<!, usize> = Ok(42).map(diverge);
|
let res: Result<!, usize> = Ok(42).map(diverge);
|
||||||
"12".parse::<i32>().map(diverge);
|
"12".parse::<i32>().map(diverge);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
error: called `map(f)` on an Result value where `f` is a unit function
|
error: called `map(f)` on an Result value where `f` is a unit function
|
||||||
--> $DIR/result_map_unit_fn.rs:42:5
|
--> $DIR/result_map_unit_fn.rs:43:5
|
||||||
|
|
|
|
||||||
42 | x.field.map(do_nothing);
|
43 | x.field.map(do_nothing);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }`
|
| help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }`
|
||||||
|
@ -9,151 +9,148 @@ error: called `map(f)` on an Result value where `f` is a unit function
|
||||||
= note: `-D clippy::result-map-unit-fn` implied by `-D warnings`
|
= 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
|
error: called `map(f)` on an Result value where `f` is a unit function
|
||||||
--> $DIR/result_map_unit_fn.rs:44:5
|
--> $DIR/result_map_unit_fn.rs:45:5
|
||||||
|
|
|
|
||||||
44 | x.field.map(do_nothing);
|
45 | x.field.map(do_nothing);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Ok(x_field) = x.field { 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
|
error: called `map(f)` on an Result value where `f` is a unit function
|
||||||
--> $DIR/result_map_unit_fn.rs:46:5
|
--> $DIR/result_map_unit_fn.rs:47:5
|
||||||
|
|
|
|
||||||
46 | x.field.map(diverge);
|
47 | x.field.map(diverge);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Ok(x_field) = x.field { 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
|
error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
--> $DIR/result_map_unit_fn.rs:54:5
|
--> $DIR/result_map_unit_fn.rs:53:5
|
||||||
|
|
|
|
||||||
54 | x.field.map(|value| x.do_result_nothing(value + captured));
|
53 | 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) }`
|
| 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
|
error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
--> $DIR/result_map_unit_fn.rs:56:5
|
--> $DIR/result_map_unit_fn.rs:55:5
|
||||||
|
|
|
|
||||||
56 | x.field.map(|value| {
|
55 | 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); }`
|
||||||
57 | || x.do_result_plus_one(value + captured);
|
|
||||||
58 | || });
|
error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
| ||______^- help: try this: `if let Ok(value) = x.field { x.do_result_plus_one(value + captured); }`
|
--> $DIR/result_map_unit_fn.rs:58:5
|
||||||
| |_______|
|
|
|
||||||
|
|
58 | 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
|
error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
--> $DIR/result_map_unit_fn.rs:60:5
|
--> $DIR/result_map_unit_fn.rs:60:5
|
||||||
|
|
|
|
||||||
60 | x.field.map(|value| do_nothing(value + captured));
|
60 | x.field.map(|value| { do_nothing(value + captured) });
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Ok(value) = x.field { 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
|
error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
--> $DIR/result_map_unit_fn.rs:62:5
|
--> $DIR/result_map_unit_fn.rs:62:5
|
||||||
|
|
|
|
||||||
62 | x.field.map(|value| do_nothing(value + captured));
|
62 | x.field.map(|value| { do_nothing(value + captured); });
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Ok(value) = x.field { 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
|
error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
--> $DIR/result_map_unit_fn.rs:64:5
|
--> $DIR/result_map_unit_fn.rs:64:5
|
||||||
|
|
|
|
||||||
64 | x.field.map(|value| {
|
64 | x.field.map(|value| { { do_nothing(value + captured); } });
|
||||||
| _____^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |_____|
|
| |
|
||||||
| ||
|
| help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }`
|
||||||
65 | || do_nothing(value + captured);
|
|
||||||
66 | || });
|
|
||||||
| ||______^- 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
|
error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
--> $DIR/result_map_unit_fn.rs:68:5
|
--> $DIR/result_map_unit_fn.rs:67:5
|
||||||
|
|
|
|
||||||
68 | x.field.map(|value| {
|
67 | x.field.map(|value| diverge(value + captured));
|
||||||
| _____^
|
|
||||||
| |_____|
|
|
||||||
| ||
|
|
||||||
69 | || do_nothing(value + captured);
|
|
||||||
70 | || });
|
|
||||||
| ||______^- 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:72:5
|
|
||||||
|
|
|
||||||
72 | x.field.map(|value| diverge(value + captured));
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Ok(value) = x.field { 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
|
error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
--> $DIR/result_map_unit_fn.rs:74:5
|
--> $DIR/result_map_unit_fn.rs:69:5
|
||||||
|
|
|
|
||||||
74 | x.field.map(|value| diverge(value + captured));
|
69 | x.field.map(|value| { diverge(value + captured) });
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Ok(value) = x.field { 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
|
error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
--> $DIR/result_map_unit_fn.rs:76:5
|
--> $DIR/result_map_unit_fn.rs:71:5
|
||||||
|
|
|
|
||||||
76 | x.field.map(|value| {
|
71 | x.field.map(|value| { diverge(value + captured); });
|
||||||
| _____^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |_____|
|
| |
|
||||||
| ||
|
| help: try this: `if let Ok(value) = x.field { diverge(value + captured); }`
|
||||||
77 | || diverge(value + captured);
|
|
||||||
78 | || });
|
error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
| ||______^- help: try this: `if let Ok(value) = x.field { diverge(value + captured); }`
|
--> $DIR/result_map_unit_fn.rs:73:5
|
||||||
| |_______|
|
|
|
||||||
|
|
73 | 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:78:5
|
||||||
|
|
|
||||||
|
78 | 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
|
error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
--> $DIR/result_map_unit_fn.rs:80:5
|
--> $DIR/result_map_unit_fn.rs:80:5
|
||||||
|
|
|
|
||||||
80 | x.field.map(|value| {
|
80 | x.field.map(|value| { plus_one(value + captured); });
|
||||||
| _____^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |_____|
|
| |
|
||||||
| ||
|
| help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }`
|
||||||
81 | || diverge(value + captured);
|
|
||||||
82 | || });
|
|
||||||
| ||______^- 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
|
error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
--> $DIR/result_map_unit_fn.rs:86:5
|
--> $DIR/result_map_unit_fn.rs:82:5
|
||||||
|
|
|
|
||||||
86 | x.field.map(|value| {
|
82 | x.field.map(|value| { { plus_one(value + captured); } });
|
||||||
| _____^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |_____|
|
| |
|
||||||
| ||
|
| help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }`
|
||||||
87 | || let y = plus_one(value + captured);
|
|
||||||
88 | || });
|
error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
| ||______^- help: try this: `if let Ok(value) = x.field { let y = plus_one(value + captured); }`
|
--> $DIR/result_map_unit_fn.rs:85:5
|
||||||
| |_______|
|
|
|
||||||
|
|
85 | 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:88:5
|
||||||
|
|
|
||||||
|
88 | 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
|
error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
--> $DIR/result_map_unit_fn.rs:90:5
|
--> $DIR/result_map_unit_fn.rs:90:5
|
||||||
|
|
|
|
||||||
90 | x.field.map(|value| {
|
90 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) });
|
||||||
| _____^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |_____|
|
| |
|
||||||
| ||
|
| help: try this: `if let Ok(value) = x.field { ... }`
|
||||||
91 | || plus_one(value + captured);
|
|
||||||
92 | || });
|
|
||||||
| ||______^- 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
|
error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
--> $DIR/result_map_unit_fn.rs:94:5
|
--> $DIR/result_map_unit_fn.rs:94:5
|
||||||
|
@ -162,90 +159,33 @@ error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
| _____^
|
| _____^
|
||||||
| |_____|
|
| |_____|
|
||||||
| ||
|
| ||
|
||||||
95 | || plus_one(value + captured);
|
95 | || do_nothing(value);
|
||||||
96 | || });
|
96 | || do_nothing(value)
|
||||||
| ||______^- help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }`
|
97 | || });
|
||||||
|
| ||______^- help: try this: `if let Ok(value) = x.field { ... }`
|
||||||
| |_______|
|
| |_______|
|
||||||
|
|
|
|
||||||
|
|
||||||
error: called `map(f)` on an Result value where `f` is a unit closure
|
error: called `map(f)` on an Result value where `f` is a unit closure
|
||||||
--> $DIR/result_map_unit_fn.rs:98:5
|
--> $DIR/result_map_unit_fn.rs:98:5
|
||||||
|
|
|
|
||||||
98 | x.field.map(|ref value| do_nothing(value + captured));
|
98 | x.field.map(|value| { do_nothing(value); do_nothing(value); });
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Ok(ref value) = x.field { do_nothing(value + captured) }`
|
| 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:100:5
|
|
||||||
|
|
|
||||||
100 | x.field.map(|value| {
|
|
||||||
| _____^
|
|
||||||
| |_____|
|
|
||||||
| ||
|
|
||||||
101 | || do_nothing(value);
|
|
||||||
102 | || do_nothing(value)
|
|
||||||
103 | || });
|
|
||||||
| ||______^- 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:105:5
|
|
||||||
|
|
|
||||||
105 | x.field.map(|value| {
|
|
||||||
| _____^
|
|
||||||
| |_____|
|
|
||||||
| ||
|
|
||||||
106 | || if value > 0 {
|
|
||||||
107 | || do_nothing(value);
|
|
||||||
108 | || do_nothing(value)
|
|
||||||
109 | || }
|
|
||||||
110 | || });
|
|
||||||
| ||______^- 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:114:5
|
|
||||||
|
|
|
||||||
114 | x.field.map(|value| {
|
|
||||||
| _____^
|
|
||||||
| |_____|
|
|
||||||
| ||
|
|
||||||
115 | || do_nothing(value);
|
|
||||||
116 | || do_nothing(value)
|
|
||||||
117 | || });
|
|
||||||
| ||______^- 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:118:5
|
|
||||||
|
|
|
||||||
118 | x.field.map(|value| {
|
|
||||||
| _____^
|
|
||||||
| |_____|
|
|
||||||
| ||
|
|
||||||
119 | || do_nothing(value);
|
|
||||||
120 | || do_nothing(value);
|
|
||||||
121 | || });
|
|
||||||
| ||______^- help: try this: `if let Ok(value) = x.field { ... }`
|
|
||||||
| |_______|
|
|
||||||
|
|
|
||||||
|
|
||||||
error: called `map(f)` on an Result value where `f` is a unit function
|
error: called `map(f)` on an Result value where `f` is a unit function
|
||||||
--> $DIR/result_map_unit_fn.rs:126:5
|
--> $DIR/result_map_unit_fn.rs:102:5
|
||||||
|
|
|
|
||||||
126 | "12".parse::<i32>().map(diverge);
|
102 | "12".parse::<i32>().map(diverge);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Ok(_) = "12".parse::<i32>() { 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
|
error: called `map(f)` on an Result value where `f` is a unit function
|
||||||
--> $DIR/result_map_unit_fn.rs:132:5
|
--> $DIR/result_map_unit_fn.rs:108:5
|
||||||
|
|
|
|
||||||
132 | y.map(do_nothing);
|
108 | y.map(do_nothing);
|
||||||
| ^^^^^^^^^^^^^^^^^-
|
| ^^^^^^^^^^^^^^^^^-
|
||||||
| |
|
| |
|
||||||
| help: try this: `if let Ok(_y) = y { do_nothing(...) }`
|
| help: try this: `if let Ok(_y) = y { do_nothing(...) }`
|
||||||
|
|
Loading…
Reference in a new issue