@@ -2,172 +2,255 @@ error: called `map(f)` on an `Option` value where `f` is a function that returns
22 --> tests/ui/option_map_unit_fn_fixable.rs:36:5
33 |
44LL | x.field.map(do_nothing);
5- | ^^^^^^^^^^^^^^^^^^^^^^^-
6- | |
7- | help: try: `if let Some(x_field) = x.field { do_nothing(x_field) }`
5+ | ^^^^^^^^^^^^^^^^^^^^^^^
86 |
97 = note: `-D clippy::option-map-unit-fn` implied by `-D warnings`
108 = help: to override `-D warnings` add `#[allow(clippy::option_map_unit_fn)]`
9+ help: use `if let` instead
10+ |
11+ LL - x.field.map(do_nothing);
12+ LL + if let Some(x_field) = x.field { do_nothing(x_field) }
13+ |
1114
1215error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()`
1316 --> tests/ui/option_map_unit_fn_fixable.rs:39:5
1417 |
1518LL | x.field.map(do_nothing);
16- | ^^^^^^^^^^^^^^^^^^^^^^^-
17- | |
18- | help: try: `if let Some(x_field) = x.field { do_nothing(x_field) }`
19+ | ^^^^^^^^^^^^^^^^^^^^^^^
20+ |
21+ help: use `if let` instead
22+ |
23+ LL - x.field.map(do_nothing);
24+ LL + if let Some(x_field) = x.field { do_nothing(x_field) }
25+ |
1926
2027error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()`
2128 --> tests/ui/option_map_unit_fn_fixable.rs:42:5
2229 |
2330LL | x.field.map(diverge);
24- | ^^^^^^^^^^^^^^^^^^^^-
25- | |
26- | help: try: `if let Some(x_field) = x.field { diverge(x_field) }`
31+ | ^^^^^^^^^^^^^^^^^^^^
32+ |
33+ help: use `if let` instead
34+ |
35+ LL - x.field.map(diverge);
36+ LL + if let Some(x_field) = x.field { diverge(x_field) }
37+ |
2738
2839error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
2940 --> tests/ui/option_map_unit_fn_fixable.rs:49:5
3041 |
3142LL | x.field.map(|value| x.do_option_nothing(value + captured));
32- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
33- | |
34- | help: try: `if let Some(value) = x.field { x.do_option_nothing(value + captured) }`
43+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44+ |
45+ help: use `if let` instead
46+ |
47+ LL - x.field.map(|value| x.do_option_nothing(value + captured));
48+ LL + if let Some(value) = x.field { x.do_option_nothing(value + captured) }
49+ |
3550
3651error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
3752 --> tests/ui/option_map_unit_fn_fixable.rs:52:5
3853 |
3954LL | x.field.map(|value| { x.do_option_plus_one(value + captured); });
40- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
41- | |
42- | help: try: `if let Some(value) = x.field { x.do_option_plus_one(value + captured); }`
55+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
56+ |
57+ help: use `if let` instead
58+ |
59+ LL - x.field.map(|value| { x.do_option_plus_one(value + captured); });
60+ LL + if let Some(value) = x.field { x.do_option_plus_one(value + captured); }
61+ |
4362
4463error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
4564 --> tests/ui/option_map_unit_fn_fixable.rs:56:5
4665 |
4766LL | x.field.map(|value| do_nothing(value + captured));
48- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
49- | |
50- | help: try: `if let Some(value) = x.field { do_nothing(value + captured) }`
67+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
68+ |
69+ help: use `if let` instead
70+ |
71+ LL - x.field.map(|value| do_nothing(value + captured));
72+ LL + if let Some(value) = x.field { do_nothing(value + captured) }
73+ |
5174
5275error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
5376 --> tests/ui/option_map_unit_fn_fixable.rs:59:5
5477 |
5578LL | x.field.map(|value| { do_nothing(value + captured) });
56- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
57- | |
58- | help: try: `if let Some(value) = x.field { do_nothing(value + captured) }`
79+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
80+ |
81+ help: use `if let` instead
82+ |
83+ LL - x.field.map(|value| { do_nothing(value + captured) });
84+ LL + if let Some(value) = x.field { do_nothing(value + captured) }
85+ |
5986
6087error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
6188 --> tests/ui/option_map_unit_fn_fixable.rs:62:5
6289 |
6390LL | x.field.map(|value| { do_nothing(value + captured); });
64- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
65- | |
66- | help: try: `if let Some(value) = x.field { do_nothing(value + captured); }`
91+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
92+ |
93+ help: use `if let` instead
94+ |
95+ LL - x.field.map(|value| { do_nothing(value + captured); });
96+ LL + if let Some(value) = x.field { do_nothing(value + captured); }
97+ |
6798
6899error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
69100 --> tests/ui/option_map_unit_fn_fixable.rs:65:5
70101 |
71102LL | x.field.map(|value| { { do_nothing(value + captured); } });
72- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
73- | |
74- | help: try: `if let Some(value) = x.field { do_nothing(value + captured); }`
103+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
104+ |
105+ help: use `if let` instead
106+ |
107+ LL - x.field.map(|value| { { do_nothing(value + captured); } });
108+ LL + if let Some(value) = x.field { do_nothing(value + captured); }
109+ |
75110
76111error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
77112 --> tests/ui/option_map_unit_fn_fixable.rs:69:5
78113 |
79114LL | x.field.map(|value| diverge(value + captured));
80- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
81- | |
82- | help: try: `if let Some(value) = x.field { diverge(value + captured) }`
115+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
116+ |
117+ help: use `if let` instead
118+ |
119+ LL - x.field.map(|value| diverge(value + captured));
120+ LL + if let Some(value) = x.field { diverge(value + captured) }
121+ |
83122
84123error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
85124 --> tests/ui/option_map_unit_fn_fixable.rs:72:5
86125 |
87126LL | x.field.map(|value| { diverge(value + captured) });
88- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
89- | |
90- | help: try: `if let Some(value) = x.field { diverge(value + captured) }`
127+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
128+ |
129+ help: use `if let` instead
130+ |
131+ LL - x.field.map(|value| { diverge(value + captured) });
132+ LL + if let Some(value) = x.field { diverge(value + captured) }
133+ |
91134
92135error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
93136 --> tests/ui/option_map_unit_fn_fixable.rs:75:5
94137 |
95138LL | x.field.map(|value| { diverge(value + captured); });
96- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
97- | |
98- | help: try: `if let Some(value) = x.field { diverge(value + captured); }`
139+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
140+ |
141+ help: use `if let` instead
142+ |
143+ LL - x.field.map(|value| { diverge(value + captured); });
144+ LL + if let Some(value) = x.field { diverge(value + captured); }
145+ |
99146
100147error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
101148 --> tests/ui/option_map_unit_fn_fixable.rs:78:5
102149 |
103150LL | x.field.map(|value| { { diverge(value + captured); } });
104- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
105- | |
106- | help: try: `if let Some(value) = x.field { diverge(value + captured); }`
151+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
152+ |
153+ help: use `if let` instead
154+ |
155+ LL - x.field.map(|value| { { diverge(value + captured); } });
156+ LL + if let Some(value) = x.field { diverge(value + captured); }
157+ |
107158
108159error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
109160 --> tests/ui/option_map_unit_fn_fixable.rs:84:5
110161 |
111162LL | x.field.map(|value| { let y = plus_one(value + captured); });
112- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
113- | |
114- | help: try: `if let Some(value) = x.field { let y = plus_one(value + captured); }`
163+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
164+ |
165+ help: use `if let` instead
166+ |
167+ LL - x.field.map(|value| { let y = plus_one(value + captured); });
168+ LL + if let Some(value) = x.field { let y = plus_one(value + captured); }
169+ |
115170
116171error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
117172 --> tests/ui/option_map_unit_fn_fixable.rs:87:5
118173 |
119174LL | x.field.map(|value| { plus_one(value + captured); });
120- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
121- | |
122- | help: try: `if let Some(value) = x.field { plus_one(value + captured); }`
175+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
176+ |
177+ help: use `if let` instead
178+ |
179+ LL - x.field.map(|value| { plus_one(value + captured); });
180+ LL + if let Some(value) = x.field { plus_one(value + captured); }
181+ |
123182
124183error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
125184 --> tests/ui/option_map_unit_fn_fixable.rs:90:5
126185 |
127186LL | x.field.map(|value| { { plus_one(value + captured); } });
128- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
129- | |
130- | help: try: `if let Some(value) = x.field { plus_one(value + captured); }`
187+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
188+ |
189+ help: use `if let` instead
190+ |
191+ LL - x.field.map(|value| { { plus_one(value + captured); } });
192+ LL + if let Some(value) = x.field { plus_one(value + captured); }
193+ |
131194
132195error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
133196 --> tests/ui/option_map_unit_fn_fixable.rs:94:5
134197 |
135198LL | x.field.map(|ref value| { do_nothing(value + captured) });
136- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
137- | |
138- | help: try: `if let Some(ref value) = x.field { do_nothing(value + captured) }`
199+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
200+ |
201+ help: use `if let` instead
202+ |
203+ LL - x.field.map(|ref value| { do_nothing(value + captured) });
204+ LL + if let Some(ref value) = x.field { do_nothing(value + captured) }
205+ |
139206
140207error: called `map(f)` on an `Option` value where `f` is a function that returns the unit type `()`
141208 --> tests/ui/option_map_unit_fn_fixable.rs:97:5
142209 |
143210LL | option().map(do_nothing);
144- | ^^^^^^^^^^^^^^^^^^^^^^^^-
145- | |
146- | help: try: `if let Some(a) = option() { do_nothing(a) }`
211+ | ^^^^^^^^^^^^^^^^^^^^^^^^
212+ |
213+ help: use `if let` instead
214+ |
215+ LL - option().map(do_nothing);
216+ LL + if let Some(a) = option() { do_nothing(a) }
217+ |
147218
148219error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
149220 --> tests/ui/option_map_unit_fn_fixable.rs:100:5
150221 |
151222LL | option().map(|value| println!("{value:?}"));
152- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
153- | |
154- | help: try: `if let Some(value) = option() { println!("{value:?}") }`
223+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
224+ |
225+ help: use `if let` instead
226+ |
227+ LL - option().map(|value| println!("{value:?}"));
228+ LL + if let Some(value) = option() { println!("{value:?}") }
229+ |
155230
156231error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
157232 --> tests/ui/option_map_unit_fn_fixable.rs:107:5
158233 |
159234LL | x.map(|x| unsafe { f(x) });
160- | ^^^^^^^^^^^^^^^^^^^^^^^^^^-
161- | |
162- | help: try: `if let Some(x) = x { unsafe { f(x) } }`
235+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
236+ |
237+ help: use `if let` instead
238+ |
239+ LL - x.map(|x| unsafe { f(x) });
240+ LL + if let Some(x) = x { unsafe { f(x) } }
241+ |
163242
164243error: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
165244 --> tests/ui/option_map_unit_fn_fixable.rs:109:5
166245 |
167246LL | x.map(|x| unsafe { { f(x) } });
168- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
169- | |
170- | help: try: `if let Some(x) = x { unsafe { f(x) } }`
247+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
248+ |
249+ help: use `if let` instead
250+ |
251+ LL - x.map(|x| unsafe { { f(x) } });
252+ LL + if let Some(x) = x { unsafe { f(x) } }
253+ |
171254
172255error: aborting due to 21 previous errors
173256
0 commit comments