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
5 | ^^^^^^^ value of type `Vec<X>` cannot be built from `std::iter::Iterator<Item=&X>`
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
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
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
22 LL | println!("{}", scores.sum::<i32>());
23 | ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
25 = help: the trait `Sum<()>` is not implemented for `i32`
26 = help: the following other types implement trait `Sum<A>`:
29 note: the method call chain might not have had the expected associated types
30 --> $DIR/invalid-iterator-chain.rs:12:10
32 LL | let scores = vec![(0, 0)]
33 | ------------ this expression has type `Vec<({integer}, {integer})>`
35 | ------ `Iterator::Item` is `&({integer}, {integer})` here
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
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
48 | ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
50 = help: the trait `Sum<()>` is not implemented for `i32`
51 = help: the following other types implement trait `Sum<A>`:
54 note: the method call chain might not have had the expected associated types
55 --> $DIR/invalid-iterator-chain.rs:25:14
58 | ---------- this expression has type `Vec<{integer}>`
60 | ------ `Iterator::Item` is `&{integer}` here
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
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
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
80 | ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=f64>`
82 = help: the trait `Sum<f64>` is not implemented for `i32`
83 = help: the following other types implement trait `Sum<A>`:
86 note: the method call chain might not have had the expected associated types
87 --> $DIR/invalid-iterator-chain.rs:33:14
90 | ---------- this expression has type `Vec<{integer}>`
92 | ------ `Iterator::Item` is `&{integer}` here
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
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
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=()>`
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>>
114 note: the method call chain might not have had the expected associated types
115 --> $DIR/invalid-iterator-chain.rs:38:38
117 LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
118 | ---------- ------ ^^^^^^^^^^^^^^^ `Iterator::Item` changed to `()` here
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
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
128 LL | println!("{}", vec![(), ()].iter().sum::<i32>());
129 | ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
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>>
135 note: the method call chain might not have had the expected associated types
136 --> $DIR/invalid-iterator-chain.rs:39:33
138 LL | println!("{}", vec![(), ()].iter().sum::<i32>());
139 | ------------ ^^^^^^ `Iterator::Item` is `&()` here
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
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
148 LL | let g: Vec<i32> = f.collect();
149 | ^^^^^^^ value of type `Vec<i32>` cannot be built from `std::iter::Iterator<Item=()>`
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
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| {
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
174 error: aborting due to 7 previous errors
176 For more information about this error, try `rustc --explain E0277`.