2022-12-13 20:00:24 -06:00
|
|
|
error[E0277]: a value of type `Vec<X>` cannot be built from an iterator over elements of type `&X`
|
|
|
|
--> $DIR/invalid-iterator-chain.rs:6:7
|
|
|
|
|
|
2023-10-13 23:11:54 -05:00
|
|
|
LL | let i = i.map(|x| x.clone());
|
|
|
|
| ------- this method call is cloning the reference `&X`, not `X` which doesn't implement `Clone`
|
2022-12-13 20:00:24 -06:00
|
|
|
LL | i.collect()
|
|
|
|
| ^^^^^^^ value of type `Vec<X>` cannot be built from `std::iter::Iterator<Item=&X>`
|
|
|
|
|
|
|
|
|
= help: the trait `FromIterator<&X>` is not implemented for `Vec<X>`
|
2023-09-09 22:21:52 -05:00
|
|
|
= help: the trait `FromIterator<X>` is implemented for `Vec<X>`
|
2023-09-09 22:33:07 -05:00
|
|
|
= help: for that trait implementation, expected `X`, found `&X`
|
2022-12-13 20:00:24 -06:00
|
|
|
note: the method call chain might not have had the expected associated types
|
|
|
|
--> $DIR/invalid-iterator-chain.rs:4:26
|
|
|
|
|
|
|
|
|
LL | fn iter_to_vec<'b, X>(i: Iter<'b, X>) -> Vec<X> {
|
|
|
|
| ^^^^^^^^^^^ `Iterator::Item` is `&X` here
|
|
|
|
LL | let i = i.map(|x| x.clone());
|
|
|
|
| ------------------ `Iterator::Item` remains `&X` here
|
|
|
|
note: required by a bound in `collect`
|
|
|
|
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
2023-10-13 23:11:54 -05:00
|
|
|
help: consider further restricting type parameter `X`
|
|
|
|
|
|
|
|
|
LL | fn iter_to_vec<'b, X>(i: Iter<'b, X>) -> Vec<X> where X: Clone {
|
|
|
|
| ++++++++++++++
|
2022-12-13 20:00:24 -06:00
|
|
|
|
2022-12-10 21:08:59 -06:00
|
|
|
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
|
2023-08-26 14:25:46 -05:00
|
|
|
--> $DIR/invalid-iterator-chain.rs:15:33
|
2022-12-06 11:34:24 -06:00
|
|
|
|
|
|
|
|
LL | println!("{}", scores.sum::<i32>());
|
2023-08-26 14:25:46 -05:00
|
|
|
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
|
|
|
|
| |
|
|
|
|
| required by a bound introduced by this call
|
2022-12-06 11:34:24 -06:00
|
|
|
|
|
2022-12-10 21:08:59 -06:00
|
|
|
= help: the trait `Sum<()>` is not implemented for `i32`
|
2022-12-06 11:34:24 -06:00
|
|
|
= help: the following other types implement trait `Sum<A>`:
|
2023-06-27 18:31:06 -05:00
|
|
|
<i32 as Sum<&'a i32>>
|
2024-03-21 07:55:28 -05:00
|
|
|
<i32 as Sum>
|
2022-12-06 14:08:17 -06:00
|
|
|
note: the method call chain might not have had the expected associated types
|
2022-12-13 20:00:24 -06:00
|
|
|
--> $DIR/invalid-iterator-chain.rs:12:10
|
2022-12-06 11:34:24 -06:00
|
|
|
|
|
|
|
|
LL | let scores = vec![(0, 0)]
|
|
|
|
| ------------ this expression has type `Vec<({integer}, {integer})>`
|
|
|
|
LL | .iter()
|
2022-12-11 13:38:43 -06:00
|
|
|
| ------ `Iterator::Item` is `&({integer}, {integer})` here
|
2022-12-06 11:34:24 -06:00
|
|
|
LL | .map(|(a, b)| {
|
2022-12-06 14:08:17 -06:00
|
|
|
| __________^
|
2022-12-06 11:34:24 -06:00
|
|
|
LL | | a + b;
|
|
|
|
LL | | });
|
2022-12-11 13:38:43 -06:00
|
|
|
| |__________^ `Iterator::Item` changed to `()` here
|
2022-12-06 11:34:24 -06:00
|
|
|
note: required by a bound in `std::iter::Iterator::sum`
|
|
|
|
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
2023-10-13 23:11:54 -05:00
|
|
|
help: consider removing this semicolon
|
|
|
|
|
|
|
|
|
LL - a + b;
|
|
|
|
LL + a + b
|
|
|
|
|
|
2022-12-06 11:34:24 -06:00
|
|
|
|
2022-12-10 21:08:59 -06:00
|
|
|
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
|
2023-08-26 14:25:46 -05:00
|
|
|
--> $DIR/invalid-iterator-chain.rs:26:20
|
2022-12-11 16:49:50 -06:00
|
|
|
|
|
|
|
|
LL | .sum::<i32>(),
|
2023-08-26 14:25:46 -05:00
|
|
|
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
|
|
|
|
| |
|
|
|
|
| required by a bound introduced by this call
|
2022-12-06 11:34:24 -06:00
|
|
|
|
|
2022-12-10 21:08:59 -06:00
|
|
|
= help: the trait `Sum<()>` is not implemented for `i32`
|
2022-12-06 11:34:24 -06:00
|
|
|
= help: the following other types implement trait `Sum<A>`:
|
2023-06-27 18:31:06 -05:00
|
|
|
<i32 as Sum<&'a i32>>
|
2024-03-21 07:55:28 -05:00
|
|
|
<i32 as Sum>
|
2022-12-06 14:08:17 -06:00
|
|
|
note: the method call chain might not have had the expected associated types
|
2022-12-20 23:36:26 -06:00
|
|
|
--> $DIR/invalid-iterator-chain.rs:25:14
|
2022-12-06 11:34:24 -06:00
|
|
|
|
|
|
|
|
LL | vec![0, 1]
|
|
|
|
| ---------- this expression has type `Vec<{integer}>`
|
|
|
|
LL | .iter()
|
2022-12-11 13:38:43 -06:00
|
|
|
| ------ `Iterator::Item` is `&{integer}` here
|
2022-12-06 12:32:49 -06:00
|
|
|
LL | .map(|x| x * 2)
|
2022-12-20 23:36:26 -06:00
|
|
|
| -------------- `Iterator::Item` changed to `{integer}` here
|
2022-12-06 12:32:49 -06:00
|
|
|
LL | .map(|x| x as f64)
|
2022-12-11 13:38:43 -06:00
|
|
|
| ----------------- `Iterator::Item` changed to `f64` here
|
2022-12-06 12:32:49 -06:00
|
|
|
LL | .map(|x| x as i64)
|
2022-12-11 13:38:43 -06:00
|
|
|
| ----------------- `Iterator::Item` changed to `i64` here
|
2022-12-06 12:32:49 -06:00
|
|
|
LL | .filter(|x| *x > 0)
|
2022-12-11 13:38:43 -06:00
|
|
|
| ------------------ `Iterator::Item` remains `i64` here
|
2022-12-06 12:32:49 -06:00
|
|
|
LL | .map(|x| { x + 1 })
|
2022-12-11 13:38:43 -06:00
|
|
|
| ------------------ `Iterator::Item` remains `i64` here
|
2022-12-06 11:34:24 -06:00
|
|
|
LL | .map(|x| { x; })
|
2022-12-11 13:38:43 -06:00
|
|
|
| ^^^^^^^^^^^^^^^ `Iterator::Item` changed to `()` here
|
2022-12-06 11:34:24 -06:00
|
|
|
note: required by a bound in `std::iter::Iterator::sum`
|
|
|
|
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
2023-10-13 23:11:54 -05:00
|
|
|
help: consider removing this semicolon
|
|
|
|
|
|
|
|
|
LL - .map(|x| { x; })
|
|
|
|
LL + .map(|x| { x })
|
|
|
|
|
|
2022-12-06 11:34:24 -06:00
|
|
|
|
2022-12-10 21:08:59 -06:00
|
|
|
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `f64`
|
2023-08-26 14:25:46 -05:00
|
|
|
--> $DIR/invalid-iterator-chain.rs:36:20
|
2022-12-11 16:49:50 -06:00
|
|
|
|
|
|
|
|
LL | .sum::<i32>(),
|
2023-08-26 14:25:46 -05:00
|
|
|
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=f64>`
|
|
|
|
| |
|
|
|
|
| required by a bound introduced by this call
|
2022-12-07 16:16:37 -06:00
|
|
|
|
|
2022-12-10 21:08:59 -06:00
|
|
|
= help: the trait `Sum<f64>` is not implemented for `i32`
|
2022-12-07 16:16:37 -06:00
|
|
|
= help: the following other types implement trait `Sum<A>`:
|
2023-06-27 18:31:06 -05:00
|
|
|
<i32 as Sum<&'a i32>>
|
2024-03-21 07:55:28 -05:00
|
|
|
<i32 as Sum>
|
2022-12-07 16:16:37 -06:00
|
|
|
note: the method call chain might not have had the expected associated types
|
2022-12-20 23:36:26 -06:00
|
|
|
--> $DIR/invalid-iterator-chain.rs:33:14
|
2022-12-07 16:16:37 -06:00
|
|
|
|
|
|
|
|
LL | vec![0, 1]
|
|
|
|
| ---------- this expression has type `Vec<{integer}>`
|
|
|
|
LL | .iter()
|
2022-12-11 13:38:43 -06:00
|
|
|
| ------ `Iterator::Item` is `&{integer}` here
|
2022-12-07 16:16:37 -06:00
|
|
|
LL | .map(|x| x * 2)
|
2022-12-20 23:36:26 -06:00
|
|
|
| -------------- `Iterator::Item` changed to `{integer}` here
|
2022-12-07 16:16:37 -06:00
|
|
|
LL | .map(|x| x as f64)
|
2022-12-11 13:38:43 -06:00
|
|
|
| ^^^^^^^^^^^^^^^^^ `Iterator::Item` changed to `f64` here
|
2022-12-07 16:16:37 -06:00
|
|
|
LL | .filter(|x| *x > 0.0)
|
2022-12-11 13:38:43 -06:00
|
|
|
| -------------------- `Iterator::Item` remains `f64` here
|
2022-12-07 16:16:37 -06:00
|
|
|
LL | .map(|x| { x + 1.0 })
|
2022-12-11 13:38:43 -06:00
|
|
|
| -------------------- `Iterator::Item` remains `f64` here
|
2022-12-07 16:16:37 -06:00
|
|
|
note: required by a bound in `std::iter::Iterator::sum`
|
|
|
|
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
|
|
|
|
2022-12-10 21:08:59 -06:00
|
|
|
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
|
2023-08-26 14:25:46 -05:00
|
|
|
--> $DIR/invalid-iterator-chain.rs:38:60
|
2022-12-06 11:34:24 -06:00
|
|
|
|
|
|
|
|
LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
|
2023-08-26 14:25:46 -05:00
|
|
|
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
|
|
|
|
| |
|
|
|
|
| required by a bound introduced by this call
|
2022-12-06 11:34:24 -06:00
|
|
|
|
|
2022-12-10 21:08:59 -06:00
|
|
|
= help: the trait `Sum<()>` is not implemented for `i32`
|
2022-12-06 11:34:24 -06:00
|
|
|
= help: the following other types implement trait `Sum<A>`:
|
2023-06-27 18:31:06 -05:00
|
|
|
<i32 as Sum<&'a i32>>
|
2024-03-21 07:55:28 -05:00
|
|
|
<i32 as Sum>
|
2022-12-06 14:08:17 -06:00
|
|
|
note: the method call chain might not have had the expected associated types
|
2022-12-13 20:00:24 -06:00
|
|
|
--> $DIR/invalid-iterator-chain.rs:38:38
|
2022-12-06 11:34:24 -06:00
|
|
|
|
|
|
|
|
LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
|
2022-12-11 13:38:43 -06:00
|
|
|
| ---------- ------ ^^^^^^^^^^^^^^^ `Iterator::Item` changed to `()` here
|
2022-12-06 11:34:24 -06:00
|
|
|
| | |
|
2022-12-11 13:38:43 -06:00
|
|
|
| | `Iterator::Item` is `&{integer}` here
|
2022-12-06 11:34:24 -06:00
|
|
|
| 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
|
2023-10-13 23:11:54 -05:00
|
|
|
help: consider removing this semicolon
|
|
|
|
|
|
|
|
|
LL - println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
|
|
|
|
LL + println!("{}", vec![0, 1].iter().map(|x| { x }).sum::<i32>());
|
|
|
|
|
|
2022-12-06 11:34:24 -06:00
|
|
|
|
2022-12-10 21:08:59 -06:00
|
|
|
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `&()`
|
2023-08-26 14:25:46 -05:00
|
|
|
--> $DIR/invalid-iterator-chain.rs:39:46
|
2022-12-06 11:34:24 -06:00
|
|
|
|
|
|
|
|
LL | println!("{}", vec![(), ()].iter().sum::<i32>());
|
2023-08-26 14:25:46 -05:00
|
|
|
| --- ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
|
|
|
|
| |
|
|
|
|
| required by a bound introduced by this call
|
2022-12-06 11:34:24 -06:00
|
|
|
|
|
2022-12-10 21:08:59 -06:00
|
|
|
= help: the trait `Sum<&()>` is not implemented for `i32`
|
2022-12-06 11:34:24 -06:00
|
|
|
= help: the following other types implement trait `Sum<A>`:
|
2023-06-27 18:31:06 -05:00
|
|
|
<i32 as Sum<&'a i32>>
|
2024-03-21 07:55:28 -05:00
|
|
|
<i32 as Sum>
|
2022-12-06 14:08:17 -06:00
|
|
|
note: the method call chain might not have had the expected associated types
|
2022-12-13 20:00:24 -06:00
|
|
|
--> $DIR/invalid-iterator-chain.rs:39:33
|
2022-12-06 11:34:24 -06:00
|
|
|
|
|
|
|
|
LL | println!("{}", vec![(), ()].iter().sum::<i32>());
|
2022-12-11 13:38:43 -06:00
|
|
|
| ------------ ^^^^^^ `Iterator::Item` is `&()` here
|
2022-12-06 11:34:24 -06:00
|
|
|
| |
|
|
|
|
| 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
|
|
|
|
|
2022-12-07 13:11:06 -06:00
|
|
|
error[E0277]: a value of type `Vec<i32>` cannot be built from an iterator over elements of type `()`
|
2022-12-13 20:00:24 -06:00
|
|
|
--> $DIR/invalid-iterator-chain.rs:48:25
|
2022-12-07 13:11:06 -06:00
|
|
|
|
|
|
|
|
LL | let g: Vec<i32> = f.collect();
|
2022-12-11 16:49:50 -06:00
|
|
|
| ^^^^^^^ value of type `Vec<i32>` cannot be built from `std::iter::Iterator<Item=()>`
|
2022-12-07 13:11:06 -06:00
|
|
|
|
|
|
|
|
= help: the trait `FromIterator<()>` is not implemented for `Vec<i32>`
|
2023-09-09 22:21:52 -05:00
|
|
|
= help: the trait `FromIterator<i32>` is implemented for `Vec<i32>`
|
2023-09-09 22:33:07 -05:00
|
|
|
= help: for that trait implementation, expected `i32`, found `()`
|
2022-12-07 13:11:06 -06:00
|
|
|
note: the method call chain might not have had the expected associated types
|
2022-12-13 20:00:24 -06:00
|
|
|
--> $DIR/invalid-iterator-chain.rs:44:15
|
2022-12-07 13:11:06 -06:00
|
|
|
|
|
|
|
|
LL | let a = vec![0];
|
|
|
|
| ------- this expression has type `Vec<{integer}>`
|
|
|
|
LL | let b = a.into_iter();
|
2022-12-11 13:38:43 -06:00
|
|
|
| ----------- `Iterator::Item` is `{integer}` here
|
2022-12-07 13:11:06 -06:00
|
|
|
LL | let c = b.map(|x| x + 1);
|
2022-12-11 13:38:43 -06:00
|
|
|
| -------------- `Iterator::Item` remains `{integer}` here
|
2022-12-07 13:11:06 -06:00
|
|
|
LL | let d = c.filter(|x| *x > 10 );
|
2022-12-11 13:38:43 -06:00
|
|
|
| -------------------- `Iterator::Item` remains `{integer}` here
|
2022-12-07 13:11:06 -06:00
|
|
|
LL | let e = d.map(|x| {
|
|
|
|
| _______________^
|
|
|
|
LL | | x + 1;
|
|
|
|
LL | | });
|
2022-12-11 13:38:43 -06:00
|
|
|
| |______^ `Iterator::Item` changed to `()` here
|
2022-12-07 13:11:06 -06:00
|
|
|
LL | let f = e.filter(|_| false);
|
2022-12-11 13:38:43 -06:00
|
|
|
| ----------------- `Iterator::Item` remains `()` here
|
2022-12-07 13:11:06 -06:00
|
|
|
note: required by a bound in `collect`
|
|
|
|
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
2023-10-13 23:11:54 -05:00
|
|
|
help: consider removing this semicolon
|
|
|
|
|
|
|
|
|
LL - x + 1;
|
|
|
|
LL + x + 1
|
|
|
|
|
|
2022-12-07 13:11:06 -06:00
|
|
|
|
2022-12-13 20:00:24 -06:00
|
|
|
error: aborting due to 7 previous errors
|
2022-12-06 11:34:24 -06:00
|
|
|
|
|
|
|
For more information about this error, try `rustc --explain E0277`.
|