fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
9.0 KiB188 linesraw
1error[E0277]: a value of type `Vec<X>` cannot be built from an iterator over elements of type `&X`
2  --> $DIR/invalid-iterator-chain.rs:6:7
3   |
4LL |     i.collect()
5   |       ^^^^^^^ value of type `Vec<X>` cannot be built from `std::iter::Iterator<Item=&X>`
6   |
7   = help: the trait `FromIterator<&X>` is not implemented for `Vec<X>`
8   = help: the trait `FromIterator<X>` is implemented for `Vec<X>`
9   = help: for that trait implementation, expected `X`, found `&X`
10note: the method call chain might not have had the expected associated types
11  --> $DIR/invalid-iterator-chain.rs:4:26
12   |
13LL | fn iter_to_vec<'b, X>(i: Iter<'b, X>) -> Vec<X> {
14   |                          ^^^^^^^^^^^ `Iterator::Item` is `&X` here
15LL |     let i = i.map(|x| x.clone());
16   |               ------------------ `Iterator::Item` remains `&X` here
17note: required by a bound in `collect`
18  --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
19
20error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
21  --> $DIR/invalid-iterator-chain.rs:15:33
22   |
23LL |     println!("{}", scores.sum::<i32>());
24   |                           ---   ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
25   |                           |
26   |                           required by a bound introduced by this call
27   |
28   = help: the trait `Sum<()>` is not implemented for `i32`
29   = help: the following other types implement trait `Sum<A>`:
30             <i32 as Sum>
31             <i32 as Sum<&'a i32>>
32note: the method call chain might not have had the expected associated types
33  --> $DIR/invalid-iterator-chain.rs:12:10
34   |
35LL |       let scores = vec![(0, 0)]
36   |                    ------------ this expression has type `Vec<({integer}, {integer})>`
37LL |           .iter()
38   |            ------ `Iterator::Item` is `&({integer}, {integer})` here
39LL |           .map(|(a, b)| {
40   |  __________^
41LL | |             a + b;
42LL | |         });
43   | |__________^ `Iterator::Item` changed to `()` here
44note: required by a bound in `std::iter::Iterator::sum`
45  --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
46
47error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
48  --> $DIR/invalid-iterator-chain.rs:26:20
49   |
50LL |             .sum::<i32>(),
51   |              ---   ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
52   |              |
53   |              required by a bound introduced by this call
54   |
55   = help: the trait `Sum<()>` is not implemented for `i32`
56   = help: the following other types implement trait `Sum<A>`:
57             <i32 as Sum>
58             <i32 as Sum<&'a i32>>
59note: the method call chain might not have had the expected associated types
60  --> $DIR/invalid-iterator-chain.rs:25:14
61   |
62LL |         vec![0, 1]
63   |         ---------- this expression has type `Vec<{integer}>`
64LL |             .iter()
65   |              ------ `Iterator::Item` is `&{integer}` here
66LL |             .map(|x| x * 2)
67   |              -------------- `Iterator::Item` changed to `{integer}` here
68LL |             .map(|x| x as f64)
69   |              ----------------- `Iterator::Item` changed to `f64` here
70LL |             .map(|x| x as i64)
71   |              ----------------- `Iterator::Item` changed to `i64` here
72LL |             .filter(|x| *x > 0)
73   |              ------------------ `Iterator::Item` remains `i64` here
74LL |             .map(|x| { x + 1 })
75   |              ------------------ `Iterator::Item` remains `i64` here
76LL |             .map(|x| { x; })
77   |              ^^^^^^^^^^^^^^^ `Iterator::Item` changed to `()` here
78note: required by a bound in `std::iter::Iterator::sum`
79  --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
80
81error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `f64`
82  --> $DIR/invalid-iterator-chain.rs:36:20
83   |
84LL |             .sum::<i32>(),
85   |              ---   ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=f64>`
86   |              |
87   |              required by a bound introduced by this call
88   |
89   = help: the trait `Sum<f64>` is not implemented for `i32`
90   = help: the following other types implement trait `Sum<A>`:
91             <i32 as Sum>
92             <i32 as Sum<&'a i32>>
93note: the method call chain might not have had the expected associated types
94  --> $DIR/invalid-iterator-chain.rs:33:14
95   |
96LL |         vec![0, 1]
97   |         ---------- this expression has type `Vec<{integer}>`
98LL |             .iter()
99   |              ------ `Iterator::Item` is `&{integer}` here
100LL |             .map(|x| x * 2)
101   |              -------------- `Iterator::Item` changed to `{integer}` here
102LL |             .map(|x| x as f64)
103   |              ^^^^^^^^^^^^^^^^^ `Iterator::Item` changed to `f64` here
104LL |             .filter(|x| *x > 0.0)
105   |              -------------------- `Iterator::Item` remains `f64` here
106LL |             .map(|x| { x + 1.0 })
107   |              -------------------- `Iterator::Item` remains `f64` here
108note: required by a bound in `std::iter::Iterator::sum`
109  --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
110
111error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `()`
112  --> $DIR/invalid-iterator-chain.rs:38:60
113   |
114LL |     println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
115   |                                                      ---   ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=()>`
116   |                                                      |
117   |                                                      required by a bound introduced by this call
118   |
119   = help: the trait `Sum<()>` is not implemented for `i32`
120   = help: the following other types implement trait `Sum<A>`:
121             <i32 as Sum>
122             <i32 as Sum<&'a i32>>
123note: the method call chain might not have had the expected associated types
124  --> $DIR/invalid-iterator-chain.rs:38:38
125   |
126LL |     println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
127   |                    ---------- ------ ^^^^^^^^^^^^^^^ `Iterator::Item` changed to `()` here
128   |                    |          |
129   |                    |          `Iterator::Item` is `&{integer}` here
130   |                    this expression has type `Vec<{integer}>`
131note: required by a bound in `std::iter::Iterator::sum`
132  --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
133
134error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `&()`
135  --> $DIR/invalid-iterator-chain.rs:39:46
136   |
137LL |     println!("{}", vec![(), ()].iter().sum::<i32>());
138   |                                        ---   ^^^ value of type `i32` cannot be made by summing a `std::iter::Iterator<Item=&()>`
139   |                                        |
140   |                                        required by a bound introduced by this call
141   |
142   = help: the trait `Sum<&()>` is not implemented for `i32`
143   = help: the following other types implement trait `Sum<A>`:
144             <i32 as Sum>
145             <i32 as Sum<&'a i32>>
146note: the method call chain might not have had the expected associated types
147  --> $DIR/invalid-iterator-chain.rs:39:33
148   |
149LL |     println!("{}", vec![(), ()].iter().sum::<i32>());
150   |                    ------------ ^^^^^^ `Iterator::Item` is `&()` here
151   |                    |
152   |                    this expression has type `Vec<()>`
153note: required by a bound in `std::iter::Iterator::sum`
154  --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
155
156error[E0277]: a value of type `Vec<i32>` cannot be built from an iterator over elements of type `()`
157  --> $DIR/invalid-iterator-chain.rs:48:25
158   |
159LL |     let g: Vec<i32> = f.collect();
160   |                         ^^^^^^^ value of type `Vec<i32>` cannot be built from `std::iter::Iterator<Item=()>`
161   |
162   = help: the trait `FromIterator<()>` is not implemented for `Vec<i32>`
163   = help: the trait `FromIterator<i32>` is implemented for `Vec<i32>`
164   = help: for that trait implementation, expected `i32`, found `()`
165note: the method call chain might not have had the expected associated types
166  --> $DIR/invalid-iterator-chain.rs:44:15
167   |
168LL |       let a = vec![0];
169   |               ------- this expression has type `Vec<{integer}>`
170LL |       let b = a.into_iter();
171   |                 ----------- `Iterator::Item` is `{integer}` here
172LL |       let c = b.map(|x| x + 1);
173   |                 -------------- `Iterator::Item` remains `{integer}` here
174LL |       let d = c.filter(|x| *x > 10 );
175   |                 -------------------- `Iterator::Item` remains `{integer}` here
176LL |       let e = d.map(|x| {
177   |  _______________^
178LL | |         x + 1;
179LL | |     });
180   | |______^ `Iterator::Item` changed to `()` here
181LL |       let f = e.filter(|_| false);
182   |                 ----------------- `Iterator::Item` remains `()` here
183note: required by a bound in `collect`
184  --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
185
186error: aborting due to 7 previous errors
187
188For more information about this error, try `rustc --explain E0277`.