rust/src/test/ui/iterators/invalid-iterator-chain.stderr

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

124 lines
5.5 KiB
Plaintext
Raw Normal View History

error[E0277]: the trait bound `i32: Sum<()>` is not satisfied
--> $DIR/invalid-iterator-chain.rs:7:20
|
LL | println!("{}", scores.sum::<i32>());
| ^^^^^^ --- required by a bound introduced by this call
| |
| the trait `Sum<()>` is not implemented for `i32`
|
= help: the following other types implement trait `Sum<A>`:
<i32 as Sum<&'a i32>>
<i32 as Sum>
2022-12-06 20:08:17 +00:00
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:3:10
|
LL | let scores = vec![(0, 0)]
| ------------ this expression has type `Vec<({integer}, {integer})>`
LL | .iter()
2022-12-06 20:08:17 +00:00
| ^^^^^^ associated type `std::iter::Iterator::Item` is `&({integer}, {integer})` here
LL | .map(|(a, b)| {
2022-12-06 20:08:17 +00:00
| __________^
LL | | a + b;
LL | | });
2022-12-06 20:08:17 +00:00
| |__________^ associated type `std::iter::Iterator::Item` changed to `()` here
note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
LL | S: Sum<Self::Item>,
| ^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::sum`
error[E0277]: the trait bound `i32: Sum<()>` is not satisfied
--> $DIR/invalid-iterator-chain.rs:10:9
|
LL | / vec![0, 1]
LL | | .iter()
2022-12-06 18:32:49 +00:00
LL | | .map(|x| x * 2)
LL | | .map(|x| x as f64)
... |
LL | | .map(|x| { x + 1 })
LL | | .map(|x| { x; })
| |____________________________^ the trait `Sum<()>` is not implemented for `i32`
LL | .sum::<i32>(),
| --- required by a bound introduced by this call
|
= help: the following other types implement trait `Sum<A>`:
<i32 as Sum<&'a i32>>
<i32 as Sum>
2022-12-06 20:08:17 +00:00
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:11:14
|
LL | vec![0, 1]
| ---------- this expression has type `Vec<{integer}>`
LL | .iter()
2022-12-06 20:08:17 +00:00
| ^^^^^^ associated type `std::iter::Iterator::Item` is `&{integer}` here
2022-12-06 18:32:49 +00:00
LL | .map(|x| x * 2)
2022-12-06 20:08:17 +00:00
| ^^^^^^^^^^^^^^ associated type `std::iter::Iterator::Item` changed to `{integer}` here
2022-12-06 18:32:49 +00:00
LL | .map(|x| x as f64)
2022-12-06 20:08:17 +00:00
| ^^^^^^^^^^^^^^^^^ associated type `std::iter::Iterator::Item` changed to `f64` here
2022-12-06 18:32:49 +00:00
LL | .map(|x| x as i64)
2022-12-06 20:08:17 +00:00
| ^^^^^^^^^^^^^^^^^ associated type `std::iter::Iterator::Item` changed to `i64` here
2022-12-06 18:32:49 +00:00
LL | .filter(|x| *x > 0)
2022-12-06 20:08:17 +00:00
| ------------------
2022-12-06 18:32:49 +00:00
LL | .map(|x| { x + 1 })
2022-12-06 20:08:17 +00:00
| ------------------
LL | .map(|x| { x; })
2022-12-06 20:08:17 +00:00
| ^^^^^^^^^^^^^^^ associated type `std::iter::Iterator::Item` changed to `()` here
note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
LL | S: Sum<Self::Item>,
| ^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::sum`
error[E0277]: the trait bound `i32: Sum<()>` is not satisfied
2022-12-06 18:32:49 +00:00
--> $DIR/invalid-iterator-chain.rs:20:20
|
LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --- required by a bound introduced by this call
| |
| the trait `Sum<()>` is not implemented for `i32`
|
= help: the following other types implement trait `Sum<A>`:
<i32 as Sum<&'a i32>>
<i32 as Sum>
2022-12-06 20:08:17 +00:00
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:20:31
|
LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
2022-12-06 20:08:17 +00:00
| ---------- ^^^^^^ ^^^^^^^^^^^^^^^ associated type `std::iter::Iterator::Item` changed to `()` here
| | |
| | associated type `std::iter::Iterator::Item` is `&{integer}` here
| this expression has type `Vec<{integer}>`
note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
LL | S: Sum<Self::Item>,
| ^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::sum`
error[E0277]: the trait bound `i32: Sum<&()>` is not satisfied
2022-12-06 18:32:49 +00:00
--> $DIR/invalid-iterator-chain.rs:21:20
|
LL | println!("{}", vec![(), ()].iter().sum::<i32>());
| ^^^^^^^^^^^^^^^^^^^ --- required by a bound introduced by this call
| |
| the trait `Sum<&()>` is not implemented for `i32`
|
= help: the following other types implement trait `Sum<A>`:
<i32 as Sum<&'a i32>>
<i32 as Sum>
2022-12-06 20:08:17 +00:00
note: the method call chain might not have had the expected associated types
2022-12-06 18:32:49 +00:00
--> $DIR/invalid-iterator-chain.rs:21:33
|
LL | println!("{}", vec![(), ()].iter().sum::<i32>());
| ------------ ^^^^^^ associated type `std::iter::Iterator::Item` is `&()` here
| |
| this expression has type `Vec<()>`
note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
LL | S: Sum<Self::Item>,
| ^^^^^^^^^^^^^^^ required by this bound in `std::iter::Iterator::sum`
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0277`.