Closed
Description
When following the const-generics beta MVP blog post we ran into this diagnostics error. The blog post specifically requests filing const-generics related diagnostics issues, so here goes!
- Rust 1.51.0-beta.3 (2021-02-24)
Given the following code:
use std::array;
fn needs_vec(v: Vec<i32>) {
// ...
}
let arr = [vec![0, 1], vec![1, 2, 3], vec![3]];
for elem in arr {
needs_vec(elem);
}
The current output is:
error[E0277]: `[Vec<{integer}>; 3]` is not an iterator
--> src/main.rs:8:17
|
8 | for elem in arr {
| ^^^ borrow the array with `&` or call `.iter()` on it to iterate over it
|
= help: the trait `Iterator` is not implemented for `[Vec<{integer}>; 3]`
= note: arrays are not iterators, but slices like the following are: `&[1, 2, 3]`
= note: required because of the requirements on the impl of `IntoIterator` for `[Vec<{integer}>; 3]`
= note: required by `into_iter`
Ideally the output should look like:
error[E0277]: `[Vec<{integer}>; 3]` is not an iterator
--> src/main.rs:8:17
|
8 | for elem in arr {
| ^^^ call `array::IntoIter::new(arr)` to iterate over the array
|
= help: the trait `Iterator` is not implemented for `[Vec<{integer}>; 3]`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment