@@ -10,12 +10,12 @@ LL | println!("{}", scores.sum::<i32>());
10
10
<i32 as Sum<&'a i32>>
11
11
<i32 as Sum>
12
12
note: the method call chain might not have had the expected associated types
13
- --> $DIR/invalid-iterator-chain.rs:3 :10
13
+ --> $DIR/invalid-iterator-chain.rs:4 :10
14
14
|
15
15
LL | let scores = vec![(0, 0)]
16
16
| ------------ this expression has type `Vec<({integer}, {integer})>`
17
17
LL | .iter()
18
- | ^^^^^^ `std::iter::Iterator::Item` is `&({integer}, {integer})` here
18
+ | ------ `std::iter::Iterator::Item` is `&({integer}, {integer})` here
19
19
LL | .map(|(a, b)| {
20
20
| __________^
21
21
LL | | a + b;
@@ -45,18 +45,18 @@ LL | .sum::<i32>(),
45
45
<i32 as Sum<&'a i32>>
46
46
<i32 as Sum>
47
47
note: the method call chain might not have had the expected associated types
48
- --> $DIR/invalid-iterator-chain.rs:11 :14
48
+ --> $DIR/invalid-iterator-chain.rs:12 :14
49
49
|
50
50
LL | vec![0, 1]
51
51
| ---------- this expression has type `Vec<{integer}>`
52
52
LL | .iter()
53
- | ^^^^^^ `std::iter::Iterator::Item` is `&{integer}` here
53
+ | ------ `std::iter::Iterator::Item` is `&{integer}` here
54
54
LL | .map(|x| x * 2)
55
55
| ^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `{integer}` here
56
56
LL | .map(|x| x as f64)
57
- | ^^^^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `f64` here
57
+ | ----------------- `std::iter::Iterator::Item` changed to `f64` here
58
58
LL | .map(|x| x as i64)
59
- | ^^^^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `i64` here
59
+ | ----------------- `std::iter::Iterator::Item` changed to `i64` here
60
60
LL | .filter(|x| *x > 0)
61
61
| ------------------ `std::iter::Iterator::Item` remains `i64` here
62
62
LL | .map(|x| { x + 1 })
@@ -69,8 +69,45 @@ note: required by a bound in `std::iter::Iterator::sum`
69
69
LL | S: Sum<Self::Item>,
70
70
| ^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::sum`
71
71
72
+ error[E0277]: the trait bound `i32: Sum<f64>` is not satisfied
73
+ --> $DIR/invalid-iterator-chain.rs:22:9
74
+ |
75
+ LL | / vec![0, 1]
76
+ LL | | .iter()
77
+ LL | | .map(|x| x * 2)
78
+ LL | | .map(|x| x as f64)
79
+ LL | | .filter(|x| *x > 0.0)
80
+ LL | | .map(|x| { x + 1.0 })
81
+ | |_________________________________^ the trait `Sum<f64>` is not implemented for `i32`
82
+ LL | .sum::<i32>(),
83
+ | --- required by a bound introduced by this call
84
+ |
85
+ = help: the following other types implement trait `Sum<A>`:
86
+ <i32 as Sum<&'a i32>>
87
+ <i32 as Sum>
88
+ note: the method call chain might not have had the expected associated types
89
+ --> $DIR/invalid-iterator-chain.rs:24:14
90
+ |
91
+ LL | vec![0, 1]
92
+ | ---------- this expression has type `Vec<{integer}>`
93
+ LL | .iter()
94
+ | ------ `std::iter::Iterator::Item` is `&{integer}` here
95
+ LL | .map(|x| x * 2)
96
+ | ^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `{integer}` here
97
+ LL | .map(|x| x as f64)
98
+ | ^^^^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `f64` here
99
+ LL | .filter(|x| *x > 0.0)
100
+ | -------------------- `std::iter::Iterator::Item` remains `f64` here
101
+ LL | .map(|x| { x + 1.0 })
102
+ | -------------------- `std::iter::Iterator::Item` remains `f64` here
103
+ note: required by a bound in `std::iter::Iterator::sum`
104
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
105
+ |
106
+ LL | S: Sum<Self::Item>,
107
+ | ^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::sum`
108
+
72
109
error[E0277]: the trait bound `i32: Sum<()>` is not satisfied
73
- --> $DIR/invalid-iterator-chain.rs:20 :20
110
+ --> $DIR/invalid-iterator-chain.rs:30 :20
74
111
|
75
112
LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
76
113
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --- required by a bound introduced by this call
@@ -81,10 +118,10 @@ LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
81
118
<i32 as Sum<&'a i32>>
82
119
<i32 as Sum>
83
120
note: the method call chain might not have had the expected associated types
84
- --> $DIR/invalid-iterator-chain.rs:20:31
121
+ --> $DIR/invalid-iterator-chain.rs:30:38
85
122
|
86
123
LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
87
- | ---------- ^^^^^^ ^^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `()` here
124
+ | ---------- ------ ^^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `()` here
88
125
| | |
89
126
| | `std::iter::Iterator::Item` is `&{integer}` here
90
127
| this expression has type `Vec<{integer}>`
@@ -95,7 +132,7 @@ LL | S: Sum<Self::Item>,
95
132
| ^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::sum`
96
133
97
134
error[E0277]: the trait bound `i32: Sum<&()>` is not satisfied
98
- --> $DIR/invalid-iterator-chain.rs:21 :20
135
+ --> $DIR/invalid-iterator-chain.rs:31 :20
99
136
|
100
137
LL | println!("{}", vec![(), ()].iter().sum::<i32>());
101
138
| ^^^^^^^^^^^^^^^^^^^ --- required by a bound introduced by this call
@@ -106,7 +143,7 @@ LL | println!("{}", vec![(), ()].iter().sum::<i32>());
106
143
<i32 as Sum<&'a i32>>
107
144
<i32 as Sum>
108
145
note: the method call chain might not have had the expected associated types
109
- --> $DIR/invalid-iterator-chain.rs:21 :33
146
+ --> $DIR/invalid-iterator-chain.rs:31 :33
110
147
|
111
148
LL | println!("{}", vec![(), ()].iter().sum::<i32>());
112
149
| ------------ ^^^^^^ `std::iter::Iterator::Item` is `&()` here
@@ -119,7 +156,7 @@ LL | S: Sum<Self::Item>,
119
156
| ^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::sum`
120
157
121
158
error[E0277]: a value of type `Vec<i32>` cannot be built from an iterator over elements of type `()`
122
- --> $DIR/invalid-iterator-chain.rs:30 :23
159
+ --> $DIR/invalid-iterator-chain.rs:40 :23
123
160
|
124
161
LL | let g: Vec<i32> = f.collect();
125
162
| ^ ------- required by a bound introduced by this call
@@ -129,12 +166,12 @@ LL | let g: Vec<i32> = f.collect();
129
166
= help: the trait `FromIterator<()>` is not implemented for `Vec<i32>`
130
167
= help: the trait `FromIterator<T>` is implemented for `Vec<T>`
131
168
note: the method call chain might not have had the expected associated types
132
- --> $DIR/invalid-iterator-chain.rs:23 :15
169
+ --> $DIR/invalid-iterator-chain.rs:36 :15
133
170
|
134
171
LL | let a = vec![0];
135
172
| ------- this expression has type `Vec<{integer}>`
136
173
LL | let b = a.into_iter();
137
- | ^^^^^^^^^^^ `std::iter::Iterator::Item` is `{integer}` here
174
+ | ----------- `std::iter::Iterator::Item` is `{integer}` here
138
175
LL | let c = b.map(|x| x + 1);
139
176
| -------------- `std::iter::Iterator::Item` remains `{integer}` here
140
177
LL | let d = c.filter(|x| *x > 10 );
@@ -152,6 +189,6 @@ note: required by a bound in `collect`
152
189
LL | fn collect<B: FromIterator<Self::Item>>(self) -> B
153
190
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `collect`
154
191
155
- error: aborting due to 5 previous errors
192
+ error: aborting due to 6 previous errors
156
193
157
194
For more information about this error, try `rustc --explain E0277`.
0 commit comments