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
+
1
19
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
2
- --> $DIR/invalid-iterator-chain.rs:7 :27
20
+ --> $DIR/invalid-iterator-chain.rs:15 :27
3
21
|
4
22
LL | println!("{}", scores.sum::<i32>());
5
23
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
@@ -9,7 +27,7 @@ LL | println!("{}", scores.sum::<i32>());
9
27
<i32 as Sum<&'a i32>>
10
28
<i32 as Sum>
11
29
note: the method call chain might not have had the expected associated types
12
- --> $DIR/invalid-iterator-chain.rs:4 :10
30
+ --> $DIR/invalid-iterator-chain.rs:12 :10
13
31
|
14
32
LL | let scores = vec![(0, 0)]
15
33
| ------------ this expression has type `Vec<({integer}, {integer})>`
@@ -24,7 +42,7 @@ note: required by a bound in `std::iter::Iterator::sum`
24
42
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
25
43
26
44
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
27
- --> $DIR/invalid-iterator-chain.rs:18 :14
45
+ --> $DIR/invalid-iterator-chain.rs:26 :14
28
46
|
29
47
LL | .sum::<i32>(),
30
48
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
@@ -34,7 +52,7 @@ LL | .sum::<i32>(),
34
52
<i32 as Sum<&'a i32>>
35
53
<i32 as Sum>
36
54
note: the method call chain might not have had the expected associated types
37
- --> $DIR/invalid-iterator-chain.rs:12 :14
55
+ --> $DIR/invalid-iterator-chain.rs:20 :14
38
56
|
39
57
LL | vec![0, 1]
40
58
| ---------- this expression has type `Vec<{integer}>`
@@ -56,7 +74,7 @@ note: required by a bound in `std::iter::Iterator::sum`
56
74
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
57
75
58
76
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `f64`
59
- --> $DIR/invalid-iterator-chain.rs:28 :14
77
+ --> $DIR/invalid-iterator-chain.rs:36 :14
60
78
|
61
79
LL | .sum::<i32>(),
62
80
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=f64>`
@@ -66,7 +84,7 @@ LL | .sum::<i32>(),
66
84
<i32 as Sum<&'a i32>>
67
85
<i32 as Sum>
68
86
note: the method call chain might not have had the expected associated types
69
- --> $DIR/invalid-iterator-chain.rs:24 :14
87
+ --> $DIR/invalid-iterator-chain.rs:32 :14
70
88
|
71
89
LL | vec![0, 1]
72
90
| ---------- this expression has type `Vec<{integer}>`
@@ -84,7 +102,7 @@ note: required by a bound in `std::iter::Iterator::sum`
84
102
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
85
103
86
104
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
87
- --> $DIR/invalid-iterator-chain.rs:30 :54
105
+ --> $DIR/invalid-iterator-chain.rs:38 :54
88
106
|
89
107
LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
90
108
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
@@ -94,7 +112,7 @@ LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
94
112
<i32 as Sum<&'a i32>>
95
113
<i32 as Sum>
96
114
note: the method call chain might not have had the expected associated types
97
- --> $DIR/invalid-iterator-chain.rs:30 :38
115
+ --> $DIR/invalid-iterator-chain.rs:38 :38
98
116
|
99
117
LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
100
118
| ---------- ------ ^^^^^^^^^^^^^^^ `Iterator::Item` changed to `()` here
@@ -105,7 +123,7 @@ note: required by a bound in `std::iter::Iterator::sum`
105
123
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
106
124
107
125
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `&()`
108
- --> $DIR/invalid-iterator-chain.rs:31 :40
126
+ --> $DIR/invalid-iterator-chain.rs:39 :40
109
127
|
110
128
LL | println!("{}", vec![(), ()].iter().sum::<i32>());
111
129
| ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
@@ -115,7 +133,7 @@ LL | println!("{}", vec![(), ()].iter().sum::<i32>());
115
133
<i32 as Sum<&'a i32>>
116
134
<i32 as Sum>
117
135
note: the method call chain might not have had the expected associated types
118
- --> $DIR/invalid-iterator-chain.rs:31 :33
136
+ --> $DIR/invalid-iterator-chain.rs:39 :33
119
137
|
120
138
LL | println!("{}", vec![(), ()].iter().sum::<i32>());
121
139
| ------------ ^^^^^^ `Iterator::Item` is `&()` here
@@ -125,15 +143,15 @@ note: required by a bound in `std::iter::Iterator::sum`
125
143
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
126
144
127
145
error[E0277]: a value of type `Vec<i32>` cannot be built from an iterator over elements of type `()`
128
- --> $DIR/invalid-iterator-chain.rs:40 :25
146
+ --> $DIR/invalid-iterator-chain.rs:48 :25
129
147
|
130
148
LL | let g: Vec<i32> = f.collect();
131
149
| ^^^^^^^ value of type `Vec<i32>` cannot be built from `std::iter::Iterator<Item=()>`
132
150
|
133
151
= help: the trait `FromIterator<()>` is not implemented for `Vec<i32>`
134
152
= help: the trait `FromIterator<T>` is implemented for `Vec<T>`
135
153
note: the method call chain might not have had the expected associated types
136
- --> $DIR/invalid-iterator-chain.rs:36 :15
154
+ --> $DIR/invalid-iterator-chain.rs:44 :15
137
155
|
138
156
LL | let a = vec![0];
139
157
| ------- this expression has type `Vec<{integer}>`
@@ -153,6 +171,6 @@ LL | let f = e.filter(|_| false);
153
171
note: required by a bound in `collect`
154
172
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
155
173
156
- error: aborting due to 6 previous errors
174
+ error: aborting due to 7 previous errors
157
175
158
176
For more information about this error, try `rustc --explain E0277`.
0 commit comments