summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/map_flatten_fixable.stderr
blob: c91c73846b69fb475a8d2d35064c8352b4aca6e9 (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
error: called `map(..).flatten()` on `Iterator`
  --> $DIR/map_flatten_fixable.rs:18:47
   |
LL |     let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().collect();
   |                                               ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `-D clippy::map-flatten` implied by `-D warnings`
help: try replacing `map` with `filter_map`, and remove the `.flatten()`
   |
LL |     let _: Vec<_> = vec![5_i8; 6].into_iter().filter_map(option_id).collect();
   |                                               ~~~~~~~~~~~~~~~~~~~~~

error: called `map(..).flatten()` on `Iterator`
  --> $DIR/map_flatten_fixable.rs:19:47
   |
LL |     let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_ref).flatten().collect();
   |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: try replacing `map` with `filter_map`, and remove the `.flatten()`
   |
LL |     let _: Vec<_> = vec![5_i8; 6].into_iter().filter_map(option_id_ref).collect();
   |                                               ~~~~~~~~~~~~~~~~~~~~~~~~~

error: called `map(..).flatten()` on `Iterator`
  --> $DIR/map_flatten_fixable.rs:20:47
   |
LL |     let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_closure).flatten().collect();
   |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: try replacing `map` with `filter_map`, and remove the `.flatten()`
   |
LL |     let _: Vec<_> = vec![5_i8; 6].into_iter().filter_map(option_id_closure).collect();
   |                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error: called `map(..).flatten()` on `Iterator`
  --> $DIR/map_flatten_fixable.rs:21:47
   |
LL |     let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| x.checked_add(1)).flatten().collect();
   |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: try replacing `map` with `filter_map`, and remove the `.flatten()`
   |
LL |     let _: Vec<_> = vec![5_i8; 6].into_iter().filter_map(|x| x.checked_add(1)).collect();
   |                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error: called `map(..).flatten()` on `Iterator`
  --> $DIR/map_flatten_fixable.rs:24:47
   |
LL |     let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect();
   |                                               ^^^^^^^^^^^^^^^^^^^^^^^
   |
help: try replacing `map` with `flat_map`, and remove the `.flatten()`
   |
LL |     let _: Vec<_> = vec![5_i8; 6].into_iter().flat_map(|x| 0..x).collect();
   |                                               ~~~~~~~~~~~~~~~~~~

error: called `map(..).flatten()` on `Option`
  --> $DIR/map_flatten_fixable.rs:27:40
   |
LL |     let _: Option<_> = (Some(Some(1))).map(|x| x).flatten();
   |                                        ^^^^^^^^^^^^^^^^^^^^
   |
help: try replacing `map` with `and_then`, and remove the `.flatten()`
   |
LL |     let _: Option<_> = (Some(Some(1))).and_then(|x| x);
   |                                        ~~~~~~~~~~~~~~~

error: called `map(..).flatten()` on `Result`
  --> $DIR/map_flatten_fixable.rs:30:42
   |
LL |     let _: Result<_, &str> = (Ok(Ok(1))).map(|x| x).flatten();
   |                                          ^^^^^^^^^^^^^^^^^^^^
   |
help: try replacing `map` with `and_then`, and remove the `.flatten()`
   |
LL |     let _: Result<_, &str> = (Ok(Ok(1))).and_then(|x| x);
   |                                          ~~~~~~~~~~~~~~~

error: aborting due to 7 previous errors