File: lint_map_unit_fn.stderr

package info (click to toggle)
rustc-web 1.70.0%2Bdfsg1-7~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,517,036 kB
  • sloc: xml: 147,962; javascript: 10,210; sh: 8,590; python: 8,220; ansic: 5,901; cpp: 4,635; makefile: 4,006; asm: 2,856
file content (66 lines) | stat: -rw-r--r-- 2,903 bytes parent folder | download | duplicates (7)
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
error: `Iterator::map` call that discard the iterator's values
  --> $DIR/lint_map_unit_fn.rs:9:18
   |
LL | fn foo(items: &mut Vec<u8>) {
   | --------------------------- this function returns `()`, which is likely not what you wanted
...
LL |     x.iter_mut().map(foo);
   |                  ^^^^---^
   |                  |   |
   |                  |   called `Iterator::map` with callable that returns `()`
   |                  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
   |
   = 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
note: the lint level is defined here
  --> $DIR/lint_map_unit_fn.rs:1:9
   |
LL | #![deny(map_unit_fn)]
   |         ^^^^^^^^^^^
help: you might have meant to use `Iterator::for_each`
   |
LL |     x.iter_mut().for_each(foo);
   |                  ~~~~~~~~

error: `Iterator::map` call that discard the iterator's values
  --> $DIR/lint_map_unit_fn.rs:11:18
   |
LL |         x.iter_mut().map(|items| {
   |                      ^   -------
   |                      |   |
   |  ____________________|___this function returns `()`, which is likely not what you wanted
   | |  __________________|
   | | |
LL | | |
LL | | |         items.sort();
LL | | |     });
   | | |     -^ 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
   | | |_____||
   | |_______|
   |         called `Iterator::map` with callable that returns `()`
   |
   = 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
help: you might have meant to use `Iterator::for_each`
   |
LL |     x.iter_mut().for_each(|items| {
   |                  ~~~~~~~~

error: `Iterator::map` call that discard the iterator's values
  --> $DIR/lint_map_unit_fn.rs:18:18
   |
LL |     let f = |items: &mut Vec<u8>| {
   |             --------------------- this function returns `()`, which is likely not what you wanted
...
LL |     x.iter_mut().map(f);
   |                  ^^^^-^
   |                  |   |
   |                  |   called `Iterator::map` with callable that returns `()`
   |                  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
   |
   = 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
help: you might have meant to use `Iterator::for_each`
   |
LL |     x.iter_mut().for_each(f);
   |                  ~~~~~~~~

error: aborting due to 3 previous errors