summaryrefslogtreecommitdiffstats
path: root/tests/ui/iterators/invalid-iterator-chain.stderr
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/ui/iterators/invalid-iterator-chain.stderr176
1 files changed, 176 insertions, 0 deletions
diff --git a/tests/ui/iterators/invalid-iterator-chain.stderr b/tests/ui/iterators/invalid-iterator-chain.stderr
new file mode 100644
index 000000000..f3dceca7e
--- /dev/null
+++ b/tests/ui/iterators/invalid-iterator-chain.stderr
@@ -0,0 +1,176 @@
+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 | 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>`
+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
+
+error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
+ --> $DIR/invalid-iterator-chain.rs:15:27
+ |
+LL | println!("{}", scores.sum::<i32>());
+ | ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
+ |
+ = help: 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>
+note: the method call chain might not have had the expected associated types
+ --> $DIR/invalid-iterator-chain.rs:12:10
+ |
+LL | let scores = vec![(0, 0)]
+ | ------------ this expression has type `Vec<({integer}, {integer})>`
+LL | .iter()
+ | ------ `Iterator::Item` is `&({integer}, {integer})` here
+LL | .map(|(a, b)| {
+ | __________^
+LL | | a + b;
+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
+
+error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
+ --> $DIR/invalid-iterator-chain.rs:26:14
+ |
+LL | .sum::<i32>(),
+ | ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
+ |
+ = help: 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>
+note: the method call chain might not have had the expected associated types
+ --> $DIR/invalid-iterator-chain.rs:25:14
+ |
+LL | vec![0, 1]
+ | ---------- this expression has type `Vec<{integer}>`
+LL | .iter()
+ | ------ `Iterator::Item` is `&{integer}` here
+LL | .map(|x| x * 2)
+ | -------------- `Iterator::Item` changed to `{integer}` here
+LL | .map(|x| x as f64)
+ | ----------------- `Iterator::Item` changed to `f64` here
+LL | .map(|x| x as i64)
+ | ----------------- `Iterator::Item` changed to `i64` here
+LL | .filter(|x| *x > 0)
+ | ------------------ `Iterator::Item` remains `i64` here
+LL | .map(|x| { x + 1 })
+ | ------------------ `Iterator::Item` remains `i64` here
+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
+
+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:14
+ |
+LL | .sum::<i32>(),
+ | ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=f64>`
+ |
+ = help: the trait `Sum<f64>` is not implemented for `i32`
+ = help: the following other types implement trait `Sum<A>`:
+ <i32 as Sum<&'a i32>>
+ <i32 as Sum>
+note: the method call chain might not have had the expected associated types
+ --> $DIR/invalid-iterator-chain.rs:33:14
+ |
+LL | vec![0, 1]
+ | ---------- this expression has type `Vec<{integer}>`
+LL | .iter()
+ | ------ `Iterator::Item` is `&{integer}` here
+LL | .map(|x| x * 2)
+ | -------------- `Iterator::Item` changed to `{integer}` here
+LL | .map(|x| x as f64)
+ | ^^^^^^^^^^^^^^^^^ `Iterator::Item` changed to `f64` here
+LL | .filter(|x| *x > 0.0)
+ | -------------------- `Iterator::Item` remains `f64` here
+LL | .map(|x| { x + 1.0 })
+ | -------------------- `Iterator::Item` remains `f64` here
+note: required by a bound in `std::iter::Iterator::sum`
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
+
+error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
+ --> $DIR/invalid-iterator-chain.rs:38:54
+ |
+LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
+ | ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
+ |
+ = help: 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>
+note: the method call chain might not have had the expected associated types
+ --> $DIR/invalid-iterator-chain.rs:38:38
+ |
+LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
+ | ---------- ------ ^^^^^^^^^^^^^^^ `Iterator::Item` changed to `()` here
+ | | |
+ | | `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
+
+error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `&()`
+ --> $DIR/invalid-iterator-chain.rs:39:40
+ |
+LL | println!("{}", vec![(), ()].iter().sum::<i32>());
+ | ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
+ |
+ = help: 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>
+note: the method call chain might not have had the expected associated types
+ --> $DIR/invalid-iterator-chain.rs:39:33
+ |
+LL | println!("{}", vec![(), ()].iter().sum::<i32>());
+ | ------------ ^^^^^^ `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
+
+error[E0277]: a value of type `Vec<i32>` cannot be built from an iterator over elements of type `()`
+ --> $DIR/invalid-iterator-chain.rs:48:25
+ |
+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>`
+note: the method call chain might not have had the expected associated types
+ --> $DIR/invalid-iterator-chain.rs:44:15
+ |
+LL | let a = vec![0];
+ | ------- this expression has type `Vec<{integer}>`
+LL | let b = a.into_iter();
+ | ----------- `Iterator::Item` is `{integer}` here
+LL | let c = b.map(|x| x + 1);
+ | -------------- `Iterator::Item` remains `{integer}` here
+LL | let d = c.filter(|x| *x > 10 );
+ | -------------------- `Iterator::Item` remains `{integer}` here
+LL | let e = d.map(|x| {
+ | _______________^
+LL | | x + 1;
+LL | | });
+ | |______^ `Iterator::Item` changed to `()` here
+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
+
+error: aborting due to 7 previous errors
+
+For more information about this error, try `rustc --explain E0277`.