@@ -10,12 +10,12 @@ LL | println!("{}", scores.sum::<i32>());
1010 <i32 as Sum<&'a i32>>
1111 <i32 as Sum>
1212note: 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
1414 |
1515LL | let scores = vec![(0, 0)]
1616 | ------------ this expression has type `Vec<({integer}, {integer})>`
1717LL | .iter()
18- | ^^^^^^ `std::iter::Iterator::Item` is `&({integer}, {integer})` here
18+ | ------ `std::iter::Iterator::Item` is `&({integer}, {integer})` here
1919LL | .map(|(a, b)| {
2020 | __________^
2121LL | | a + b;
@@ -45,18 +45,18 @@ LL | .sum::<i32>(),
4545 <i32 as Sum<&'a i32>>
4646 <i32 as Sum>
4747note: 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
4949 |
5050LL | vec![0, 1]
5151 | ---------- this expression has type `Vec<{integer}>`
5252LL | .iter()
53- | ^^^^^^ `std::iter::Iterator::Item` is `&{integer}` here
53+ | ------ `std::iter::Iterator::Item` is `&{integer}` here
5454LL | .map(|x| x * 2)
5555 | ^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `{integer}` here
5656LL | .map(|x| x as f64)
57- | ^^^^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `f64` here
57+ | ----------------- `std::iter::Iterator::Item` changed to `f64` here
5858LL | .map(|x| x as i64)
59- | ^^^^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `i64` here
59+ | ----------------- `std::iter::Iterator::Item` changed to `i64` here
6060LL | .filter(|x| *x > 0)
6161 | ------------------ `std::iter::Iterator::Item` remains `i64` here
6262LL | .map(|x| { x + 1 })
@@ -69,8 +69,45 @@ note: required by a bound in `std::iter::Iterator::sum`
6969LL | S: Sum<Self::Item>,
7070 | ^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::sum`
7171
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+
72109error[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
74111 |
75112LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
76113 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --- required by a bound introduced by this call
@@ -81,10 +118,10 @@ LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
81118 <i32 as Sum<&'a i32>>
82119 <i32 as Sum>
83120note: 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
85122 |
86123LL | 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
88125 | | |
89126 | | `std::iter::Iterator::Item` is `&{integer}` here
90127 | this expression has type `Vec<{integer}>`
@@ -95,7 +132,7 @@ LL | S: Sum<Self::Item>,
95132 | ^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::sum`
96133
97134error[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
99136 |
100137LL | println!("{}", vec![(), ()].iter().sum::<i32>());
101138 | ^^^^^^^^^^^^^^^^^^^ --- required by a bound introduced by this call
@@ -106,7 +143,7 @@ LL | println!("{}", vec![(), ()].iter().sum::<i32>());
106143 <i32 as Sum<&'a i32>>
107144 <i32 as Sum>
108145note: 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
110147 |
111148LL | println!("{}", vec![(), ()].iter().sum::<i32>());
112149 | ------------ ^^^^^^ `std::iter::Iterator::Item` is `&()` here
@@ -119,7 +156,7 @@ LL | S: Sum<Self::Item>,
119156 | ^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::sum`
120157
121158error[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
123160 |
124161LL | let g: Vec<i32> = f.collect();
125162 | ^ ------- required by a bound introduced by this call
@@ -129,12 +166,12 @@ LL | let g: Vec<i32> = f.collect();
129166 = help: the trait `FromIterator<()>` is not implemented for `Vec<i32>`
130167 = help: the trait `FromIterator<T>` is implemented for `Vec<T>`
131168note: 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
133170 |
134171LL | let a = vec![0];
135172 | ------- this expression has type `Vec<{integer}>`
136173LL | let b = a.into_iter();
137- | ^^^^^^^^^^^ `std::iter::Iterator::Item` is `{integer}` here
174+ | ----------- `std::iter::Iterator::Item` is `{integer}` here
138175LL | let c = b.map(|x| x + 1);
139176 | -------------- `std::iter::Iterator::Item` remains `{integer}` here
140177LL | let d = c.filter(|x| *x > 10 );
@@ -152,6 +189,6 @@ note: required by a bound in `collect`
152189LL | fn collect<B: FromIterator<Self::Item>>(self) -> B
153190 | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `collect`
154191
155- error: aborting due to 5 previous errors
192+ error: aborting due to 6 previous errors
156193
157194For more information about this error, try `rustc --explain E0277`.
0 commit comments