]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/map_unwrap_or.stderr
Merge branch 'master' into hooks
[rust.git] / src / tools / clippy / tests / ui / map_unwrap_or.stderr
1 error: called `map(f).unwrap_or(a)` on an `Option` value. This can be done more directly by calling `map_or(a, f)` instead
2   --> $DIR/map_unwrap_or.rs:17:13
3    |
4 LL |       let _ = opt.map(|x| x + 1)
5    |  _____________^
6 LL | |         // Should lint even though this call is on a separate line.
7 LL | |         .unwrap_or(0);
8    | |_____________________^
9    |
10    = note: `-D clippy::map-unwrap-or` implied by `-D warnings`
11 help: use `map_or(a, f)` instead
12    |
13 LL |     let _ = opt.map_or(0, |x| x + 1);
14    |                 ^^^^^^ ^^          --
15
16 error: called `map(f).unwrap_or(a)` on an `Option` value. This can be done more directly by calling `map_or(a, f)` instead
17   --> $DIR/map_unwrap_or.rs:21:13
18    |
19 LL |       let _ = opt.map(|x| {
20    |  _____________^
21 LL | |         x + 1
22 LL | |     }
23 LL | |     ).unwrap_or(0);
24    | |__________________^
25    |
26 help: use `map_or(a, f)` instead
27    |
28 LL |     let _ = opt.map_or(0, |x| {
29 LL |         x + 1
30 LL |     }
31 LL |     );
32    |
33
34 error: called `map(f).unwrap_or(a)` on an `Option` value. This can be done more directly by calling `map_or(a, f)` instead
35   --> $DIR/map_unwrap_or.rs:25:13
36    |
37 LL |       let _ = opt.map(|x| x + 1)
38    |  _____________^
39 LL | |         .unwrap_or({
40 LL | |             0
41 LL | |         });
42    | |__________^
43    |
44 help: use `map_or(a, f)` instead
45    |
46 LL |     let _ = opt.map_or({
47 LL |             0
48 LL |         }, |x| x + 1);
49    |
50
51 error: called `map(f).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(f)` instead
52   --> $DIR/map_unwrap_or.rs:30:13
53    |
54 LL |     let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
55    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
56    |
57 help: use `and_then(f)` instead
58    |
59 LL |     let _ = opt.and_then(|x| Some(x + 1));
60    |                 ^^^^^^^^                --
61
62 error: called `map(f).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(f)` instead
63   --> $DIR/map_unwrap_or.rs:32:13
64    |
65 LL |       let _ = opt.map(|x| {
66    |  _____________^
67 LL | |         Some(x + 1)
68 LL | |     }
69 LL | |     ).unwrap_or(None);
70    | |_____________________^
71    |
72 help: use `and_then(f)` instead
73    |
74 LL |     let _ = opt.and_then(|x| {
75 LL |         Some(x + 1)
76 LL |     }
77 LL |     );
78    |
79
80 error: called `map(f).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(f)` instead
81   --> $DIR/map_unwrap_or.rs:36:13
82    |
83 LL |       let _ = opt
84    |  _____________^
85 LL | |         .map(|x| Some(x + 1))
86 LL | |         .unwrap_or(None);
87    | |________________________^
88    |
89 help: use `and_then(f)` instead
90    |
91 LL |         .and_then(|x| Some(x + 1));
92    |          ^^^^^^^^                --
93
94 error: called `map(f).unwrap_or(a)` on an `Option` value. This can be done more directly by calling `map_or(a, f)` instead
95   --> $DIR/map_unwrap_or.rs:47:13
96    |
97 LL |     let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
98    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99    |
100 help: use `map_or(a, f)` instead
101    |
102 LL |     let _ = Some("prefix").map_or(id, |p| format!("{}.", p));
103    |                            ^^^^^^ ^^^                      --
104
105 error: called `map(f).unwrap_or_else(g)` on an `Option` value. This can be done more directly by calling `map_or_else(g, f)` instead
106   --> $DIR/map_unwrap_or.rs:51:13
107    |
108 LL |       let _ = opt.map(|x| x + 1)
109    |  _____________^
110 LL | |         // Should lint even though this call is on a separate line.
111 LL | |         .unwrap_or_else(|| 0);
112    | |_____________________________^
113    |
114    = note: replace `map(|x| x + 1).unwrap_or_else(|| 0)` with `map_or_else(|| 0, |x| x + 1)`
115
116 error: called `map(f).unwrap_or_else(g)` on an `Option` value. This can be done more directly by calling `map_or_else(g, f)` instead
117   --> $DIR/map_unwrap_or.rs:55:13
118    |
119 LL |       let _ = opt.map(|x| {
120    |  _____________^
121 LL | |         x + 1
122 LL | |     }
123 LL | |     ).unwrap_or_else(|| 0);
124    | |__________________________^
125
126 error: called `map(f).unwrap_or_else(g)` on an `Option` value. This can be done more directly by calling `map_or_else(g, f)` instead
127   --> $DIR/map_unwrap_or.rs:59:13
128    |
129 LL |       let _ = opt.map(|x| x + 1)
130    |  _____________^
131 LL | |         .unwrap_or_else(||
132 LL | |             0
133 LL | |         );
134    | |_________^
135
136 error: called `map(f).unwrap_or_else(g)` on a `Result` value. This can be done more directly by calling `.map_or_else(g, f)` instead
137   --> $DIR/map_unwrap_or.rs:88:13
138    |
139 LL |     let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0); // should lint even though this call is on a separate line
140    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
141    |
142    = note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `map_or_else(|e| 0, |x| x + 1)`
143
144 error: called `map(f).unwrap_or_else(g)` on a `Result` value. This can be done more directly by calling `.map_or_else(g, f)` instead
145   --> $DIR/map_unwrap_or.rs:90:13
146    |
147 LL |     let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0);
148    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
149    |
150    = note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `map_or_else(|e| 0, |x| x + 1)`
151
152 error: called `map(f).unwrap_or_else(g)` on a `Result` value. This can be done more directly by calling `.map_or_else(g, f)` instead
153   --> $DIR/map_unwrap_or.rs:91:13
154    |
155 LL |     let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0);
156    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
157    |
158    = note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `map_or_else(|e| 0, |x| x + 1)`
159
160 error: aborting due to 13 previous errors
161