File tree 3 files changed +8
-2
lines changed
3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -6,13 +6,16 @@ pub fn main() {
6
6
let x = Some(5);
7
7
// the easiest cases
8
8
let _ = x;
9
+ //~^ bind_instead_of_map
9
10
let _ = x.map(|o| o + 1);
11
+ //~^ bind_instead_of_map
10
12
// and an easy counter-example
11
13
let _ = x.and_then(|o| if o < 32 { Some(o) } else { None });
12
14
13
15
// Different type
14
16
let x: Result<u32, &str> = Ok(1);
15
17
let _ = x;
18
+ //~^ bind_instead_of_map
16
19
}
17
20
18
21
pub fn foo() -> Option<String> {
Original file line number Diff line number Diff line change @@ -6,13 +6,16 @@ pub fn main() {
6
6
let x = Some ( 5 ) ;
7
7
// the easiest cases
8
8
let _ = x. and_then ( Some ) ;
9
+ //~^ bind_instead_of_map
9
10
let _ = x. and_then ( |o| Some ( o + 1 ) ) ;
11
+ //~^ bind_instead_of_map
10
12
// and an easy counter-example
11
13
let _ = x. and_then ( |o| if o < 32 { Some ( o) } else { None } ) ;
12
14
13
15
// Different type
14
16
let x: Result < u32 , & str > = Ok ( 1 ) ;
15
17
let _ = x. and_then ( Ok ) ;
18
+ //~^ bind_instead_of_map
16
19
}
17
20
18
21
pub fn foo ( ) -> Option < String > {
Original file line number Diff line number Diff line change @@ -11,13 +11,13 @@ LL | #![deny(clippy::bind_instead_of_map)]
11
11
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
12
12
13
13
error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
14
- --> tests/ui/bind_instead_of_map.rs:9 :13
14
+ --> tests/ui/bind_instead_of_map.rs:10 :13
15
15
|
16
16
LL | let _ = x.and_then(|o| Some(o + 1));
17
17
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.map(|o| o + 1)`
18
18
19
19
error: using `Result.and_then(Ok)`, which is a no-op
20
- --> tests/ui/bind_instead_of_map.rs:15 :13
20
+ --> tests/ui/bind_instead_of_map.rs:17 :13
21
21
|
22
22
LL | let _ = x.and_then(Ok);
23
23
| ^^^^^^^^^^^^^^ help: use the expression directly: `x`
You can’t perform that action at this time.
0 commit comments