]> git.lizzy.rs Git - rust.git/blob - src/test/ui/iterators/invalid-iterator-chain.stderr
Auto merge of #106143 - matthiaskrgr:rollup-3kpy1dc, r=matthiaskrgr
[rust.git] / src / test / ui / iterators / invalid-iterator-chain.stderr
1 error[E0277]: a value of type `Vec<X>` cannot be built from an iterator over elements of type `&X`
2   --> $DIR/invalid-iterator-chain.rs:6:7
3    |
4 LL |     i.collect()
5    |       ^^^^^^^ value of type `Vec<X>` cannot be built from `std::iter::Iterator<Item=&X>`
6    |
7    = help: the trait `FromIterator<&X>` is not implemented for `Vec<X>`
8    = help: the trait `FromIterator<T>` is implemented for `Vec<T>`
9 note: the method call chain might not have had the expected associated types
10   --> $DIR/invalid-iterator-chain.rs:4:26
11    |
12 LL | fn iter_to_vec<'b, X>(i: Iter<'b, X>) -> Vec<X> {
13    |                          ^^^^^^^^^^^ `Iterator::Item` is `&X` here
14 LL |     let i = i.map(|x| x.clone());
15    |               ------------------ `Iterator::Item` remains `&X` here
16 note: required by a bound in `collect`
17   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
18
19 error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
20   --> $DIR/invalid-iterator-chain.rs:15:27
21    |
22 LL |     println!("{}", scores.sum::<i32>());
23    |                           ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
24    |
25    = help: the trait `Sum<()>` is not implemented for `i32`
26    = help: the following other types implement trait `Sum<A>`:
27              <i32 as Sum<&'a i32>>
28              <i32 as Sum>
29 note: the method call chain might not have had the expected associated types
30   --> $DIR/invalid-iterator-chain.rs:12:10
31    |
32 LL |       let scores = vec![(0, 0)]
33    |                    ------------ this expression has type `Vec<({integer}, {integer})>`
34 LL |           .iter()
35    |            ------ `Iterator::Item` is `&({integer}, {integer})` here
36 LL |           .map(|(a, b)| {
37    |  __________^
38 LL | |             a + b;
39 LL | |         });
40    | |__________^ `Iterator::Item` changed to `()` here
41 note: required by a bound in `std::iter::Iterator::sum`
42   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
43
44 error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
45   --> $DIR/invalid-iterator-chain.rs:26:14
46    |
47 LL |             .sum::<i32>(),
48    |              ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
49    |
50    = help: the trait `Sum<()>` is not implemented for `i32`
51    = help: the following other types implement trait `Sum<A>`:
52              <i32 as Sum<&'a i32>>
53              <i32 as Sum>
54 note: the method call chain might not have had the expected associated types
55   --> $DIR/invalid-iterator-chain.rs:25:14
56    |
57 LL |         vec![0, 1]
58    |         ---------- this expression has type `Vec<{integer}>`
59 LL |             .iter()
60    |              ------ `Iterator::Item` is `&{integer}` here
61 LL |             .map(|x| x * 2)
62    |              -------------- `Iterator::Item` changed to `{integer}` here
63 LL |             .map(|x| x as f64)
64    |              ----------------- `Iterator::Item` changed to `f64` here
65 LL |             .map(|x| x as i64)
66    |              ----------------- `Iterator::Item` changed to `i64` here
67 LL |             .filter(|x| *x > 0)
68    |              ------------------ `Iterator::Item` remains `i64` here
69 LL |             .map(|x| { x + 1 })
70    |              ------------------ `Iterator::Item` remains `i64` here
71 LL |             .map(|x| { x; })
72    |              ^^^^^^^^^^^^^^^ `Iterator::Item` changed to `()` here
73 note: required by a bound in `std::iter::Iterator::sum`
74   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
75
76 error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `f64`
77   --> $DIR/invalid-iterator-chain.rs:36:14
78    |
79 LL |             .sum::<i32>(),
80    |              ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=f64>`
81    |
82    = help: the trait `Sum<f64>` is not implemented for `i32`
83    = help: the following other types implement trait `Sum<A>`:
84              <i32 as Sum<&'a i32>>
85              <i32 as Sum>
86 note: the method call chain might not have had the expected associated types
87   --> $DIR/invalid-iterator-chain.rs:33:14
88    |
89 LL |         vec![0, 1]
90    |         ---------- this expression has type `Vec<{integer}>`
91 LL |             .iter()
92    |              ------ `Iterator::Item` is `&{integer}` here
93 LL |             .map(|x| x * 2)
94    |              -------------- `Iterator::Item` changed to `{integer}` here
95 LL |             .map(|x| x as f64)
96    |              ^^^^^^^^^^^^^^^^^ `Iterator::Item` changed to `f64` here
97 LL |             .filter(|x| *x > 0.0)
98    |              -------------------- `Iterator::Item` remains `f64` here
99 LL |             .map(|x| { x + 1.0 })
100    |              -------------------- `Iterator::Item` remains `f64` here
101 note: required by a bound in `std::iter::Iterator::sum`
102   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
103
104 error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
105   --> $DIR/invalid-iterator-chain.rs:38:54
106    |
107 LL |     println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
108    |                                                      ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
109    |
110    = help: the trait `Sum<()>` is not implemented for `i32`
111    = help: the following other types implement trait `Sum<A>`:
112              <i32 as Sum<&'a i32>>
113              <i32 as Sum>
114 note: the method call chain might not have had the expected associated types
115   --> $DIR/invalid-iterator-chain.rs:38:38
116    |
117 LL |     println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
118    |                    ---------- ------ ^^^^^^^^^^^^^^^ `Iterator::Item` changed to `()` here
119    |                    |          |
120    |                    |          `Iterator::Item` is `&{integer}` here
121    |                    this expression has type `Vec<{integer}>`
122 note: required by a bound in `std::iter::Iterator::sum`
123   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
124
125 error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `&()`
126   --> $DIR/invalid-iterator-chain.rs:39:40
127    |
128 LL |     println!("{}", vec![(), ()].iter().sum::<i32>());
129    |                                        ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
130    |
131    = help: the trait `Sum<&()>` is not implemented for `i32`
132    = help: the following other types implement trait `Sum<A>`:
133              <i32 as Sum<&'a i32>>
134              <i32 as Sum>
135 note: the method call chain might not have had the expected associated types
136   --> $DIR/invalid-iterator-chain.rs:39:33
137    |
138 LL |     println!("{}", vec![(), ()].iter().sum::<i32>());
139    |                    ------------ ^^^^^^ `Iterator::Item` is `&()` here
140    |                    |
141    |                    this expression has type `Vec<()>`
142 note: required by a bound in `std::iter::Iterator::sum`
143   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
144
145 error[E0277]: a value of type `Vec<i32>` cannot be built from an iterator over elements of type `()`
146   --> $DIR/invalid-iterator-chain.rs:48:25
147    |
148 LL |     let g: Vec<i32> = f.collect();
149    |                         ^^^^^^^ value of type `Vec<i32>` cannot be built from `std::iter::Iterator<Item=()>`
150    |
151    = help: the trait `FromIterator<()>` is not implemented for `Vec<i32>`
152    = help: the trait `FromIterator<T>` is implemented for `Vec<T>`
153 note: the method call chain might not have had the expected associated types
154   --> $DIR/invalid-iterator-chain.rs:44:15
155    |
156 LL |       let a = vec![0];
157    |               ------- this expression has type `Vec<{integer}>`
158 LL |       let b = a.into_iter();
159    |                 ----------- `Iterator::Item` is `{integer}` here
160 LL |       let c = b.map(|x| x + 1);
161    |                 -------------- `Iterator::Item` remains `{integer}` here
162 LL |       let d = c.filter(|x| *x > 10 );
163    |                 -------------------- `Iterator::Item` remains `{integer}` here
164 LL |       let e = d.map(|x| {
165    |  _______________^
166 LL | |         x + 1;
167 LL | |     });
168    | |______^ `Iterator::Item` changed to `()` here
169 LL |       let f = e.filter(|_| false);
170    |                 ----------------- `Iterator::Item` remains `()` here
171 note: required by a bound in `collect`
172   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
173
174 error: aborting due to 7 previous errors
175
176 For more information about this error, try `rustc --explain E0277`.