summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/bind_instead_of_map_multipart.stderr
blob: 0152a93feee4274b4a27a61deadb19da8ffe21a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
  --> $DIR/bind_instead_of_map_multipart.rs:6:13
   |
LL |     let _ = Some("42").and_then(|s| if s.len() < 42 { Some(0) } else { Some(s.len()) });
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: the lint level is defined here
  --> $DIR/bind_instead_of_map_multipart.rs:2:9
   |
LL | #![deny(clippy::bind_instead_of_map)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: try this
   |
LL |     let _ = Some("42").map(|s| if s.len() < 42 { 0 } else { s.len() });
   |                        ~~~                       ~          ~~~~~~~

error: using `Result.and_then(|x| Ok(y))`, which is more succinctly expressed as `map(|x| y)`
  --> $DIR/bind_instead_of_map_multipart.rs:9:13
   |
LL |     let _ = Ok::<_, ()>("42").and_then(|s| if s.len() < 42 { Ok(0) } else { Ok(s.len()) });
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: try this
   |
LL |     let _ = Ok::<_, ()>("42").map(|s| if s.len() < 42 { 0 } else { s.len() });
   |                               ~~~                       ~          ~~~~~~~

error: using `Result.or_else(|x| Err(y))`, which is more succinctly expressed as `map_err(|x| y)`
  --> $DIR/bind_instead_of_map_multipart.rs:12:13
   |
LL |     let _ = Err::<(), _>("42").or_else(|s| if s.len() < 42 { Err(s.len() + 20) } else { Err(s.len()) });
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: try this
   |
LL |     let _ = Err::<(), _>("42").map_err(|s| if s.len() < 42 { s.len() + 20 } else { s.len() });
   |                                ~~~~~~~                       ~~~~~~~~~~~~          ~~~~~~~

error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
  --> $DIR/bind_instead_of_map_multipart.rs:20:5
   |
LL | /     Some("42").and_then(|s| {
LL | |         if {
LL | |             if s == "43" {
LL | |                 return Some(43);
...  |
LL | |         }
LL | |     });
   | |______^
   |
help: try this
   |
LL ~     Some("42").map(|s| {
LL |         if {
LL |             if s == "43" {
LL ~                 return 43;
LL |             }
LL |             s == "42"
LL |         } {
LL ~             return 45;
LL |         }
LL |         match s.len() {
LL ~             10 => 2,
LL |             20 => {
 ...
LL |                         if foo() {
LL ~                             return 20;
LL |                         }
LL |                         println!("foo");
LL ~                         3
LL |                     };
LL |                 }
LL ~                 20
LL |             },
LL ~             40 => 30,
LL ~             _ => 1,
   |

error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
  --> $DIR/bind_instead_of_map_multipart.rs:61:13
   |
LL |     let _ = Some("").and_then(|s| if s.len() == 20 { Some(m!()) } else { Some(Some(20)) });
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: try this
   |
LL |     let _ = Some("").map(|s| if s.len() == 20 { m!() } else { Some(20) });
   |                      ~~~                        ~~~~          ~~~~~~~~

error: aborting due to 5 previous errors