You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/ui/lint/lint_map_unit_fn.stderr
+42-1
Original file line number
Diff line number
Diff line change
@@ -21,5 +21,46 @@ help: you might have meant to use `Iterator::for_each`
21
21
LL | x.iter_mut().for_each(foo);
22
22
| ~~~~~~~~
23
23
24
-
error: aborting due to previous error
24
+
error: `Iterator::map` call that discard the iterator's values
25
+
--> $DIR/lint_map_unit_fn.rs:11:18
26
+
|
27
+
LL | x.iter_mut().map(|items| {
28
+
| ^ -------
29
+
| | |
30
+
| ____________________|___this function returns `()`, which is likely not what you wanted
31
+
| | __________________|
32
+
| | |
33
+
LL | | |
34
+
LL | | | items.sort();
35
+
LL | | | });
36
+
| | | -^ after this call to map, the resulting iterator is `impl Iterator<Item = ()>`, which means the only information carried by the iterator is the number of items
37
+
| | |_____||
38
+
| |_______|
39
+
| called `Iterator::map` with callable that returns `()`
40
+
|
41
+
= note: `Iterator::map`, like many of the methods on `Iterator`, gets executed lazily, meaning that its effects won't be visible until it is iterated
42
+
help: you might have meant to use `Iterator::for_each`
43
+
|
44
+
LL | x.iter_mut().for_each(|items| {
45
+
| ~~~~~~~~
46
+
47
+
error: `Iterator::map` call that discard the iterator's values
48
+
--> $DIR/lint_map_unit_fn.rs:18:18
49
+
|
50
+
LL | let f = |items: &mut Vec<u8>| {
51
+
| --------------------- this function returns `()`, which is likely not what you wanted
52
+
...
53
+
LL | x.iter_mut().map(f);
54
+
| ^^^^-^
55
+
| | |
56
+
| | called `Iterator::map` with callable that returns `()`
57
+
| after this call to map, the resulting iterator is `impl Iterator<Item = ()>`, which means the only information carried by the iterator is the number of items
58
+
|
59
+
= note: `Iterator::map`, like many of the methods on `Iterator`, gets executed lazily, meaning that its effects won't be visible until it is iterated
60
+
help: you might have meant to use `Iterator::for_each`
0 commit comments