summaryrefslogtreecommitdiffstats
path: root/tests/ui/iterators/invalid-iterator-chain.stderr
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/iterators/invalid-iterator-chain.stderr')
-rw-r--r--tests/ui/iterators/invalid-iterator-chain.stderr32
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/ui/iterators/invalid-iterator-chain.stderr b/tests/ui/iterators/invalid-iterator-chain.stderr
index b355da5cb..4dc130869 100644
--- a/tests/ui/iterators/invalid-iterator-chain.stderr
+++ b/tests/ui/iterators/invalid-iterator-chain.stderr
@@ -1,11 +1,14 @@
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
|
+LL | let i = i.map(|x| x.clone());
+ | ------- this method call is cloning the reference `&X`, not `X` which doesn't implement `Clone`
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>`
- = help: the trait `FromIterator<T>` is implemented for `Vec<T>`
+ = help: the trait `FromIterator<X>` is implemented for `Vec<X>`
+ = help: for that trait implementation, expected `X`, found `&X`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:4:26
|
@@ -15,6 +18,10 @@ 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
+help: consider further restricting type parameter `X`
+ |
+LL | fn iter_to_vec<'b, X>(i: Iter<'b, X>) -> Vec<X> where X: Clone {
+ | ++++++++++++++
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
--> $DIR/invalid-iterator-chain.rs:15:33
@@ -42,6 +49,11 @@ LL | | });
| |__________^ `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
+help: consider removing this semicolon
+ |
+LL - a + b;
+LL + a + b
+ |
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
--> $DIR/invalid-iterator-chain.rs:26:20
@@ -76,6 +88,11 @@ LL | .map(|x| { x; })
| ^^^^^^^^^^^^^^^ `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
+help: consider removing this semicolon
+ |
+LL - .map(|x| { x; })
+LL + .map(|x| { x })
+ |
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `f64`
--> $DIR/invalid-iterator-chain.rs:36:20
@@ -129,6 +146,11 @@ LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
| 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
+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>());
+ |
error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `&()`
--> $DIR/invalid-iterator-chain.rs:39:46
@@ -159,7 +181,8 @@ LL | let g: Vec<i32> = f.collect();
| ^^^^^^^ value of type `Vec<i32>` cannot be built from `std::iter::Iterator<Item=()>`
|
= help: the trait `FromIterator<()>` is not implemented for `Vec<i32>`
- = help: the trait `FromIterator<T>` is implemented for `Vec<T>`
+ = help: the trait `FromIterator<i32>` is implemented for `Vec<i32>`
+ = help: for that trait implementation, expected `i32`, found `()`
note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:44:15
|
@@ -180,6 +203,11 @@ LL | let f = e.filter(|_| false);
| ----------------- `Iterator::Item` remains `()` here
note: required by a bound in `collect`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+help: consider removing this semicolon
+ |
+LL - x + 1;
+LL + x + 1
+ |
error: aborting due to 7 previous errors