Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling into_iter on an oversized array only triggers into_iter_on_ref #4492

Open
Nemo157 opened this issue Sep 3, 2019 · 0 comments
Open
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages

Comments

@Nemo157
Copy link
Member

Nemo157 commented Sep 3, 2019

When using into_iter on an array within the size limits of the current impl IntoIterator for &[T; _] implementations you get a deny-by-default lint failure:

error: this .into_iter() call is equivalent to .iter() and will not move the array
 --> src/main.rs:2:22
  |
2 |     for _ in [0; 32].into_iter() {
  |                      ^^^^^^^^^ help: call directly: `iter`
  |
  = note: `#[deny(clippy::into_iter_on_array)]` on by default

If you increase the array size past those provided implementations you instead get a warn-by-default lint:

warning: this .into_iter() call is equivalent to .iter() and will not move the slice
 --> src/main.rs:2:22
  |
2 |     for _ in [0; 33].into_iter() {
  |                      ^^^^^^^^^ help: call directly: `iter`
  |
  = note: `#[warn(clippy::into_iter_on_ref)]` on by default

It seems both of these cases would be affected equally by a future const-generic powered impl<T, const N: usize> IntoIterator for [T; N].

@flip1995 flip1995 added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages
Projects
None yet
Development

No branches or pull requests

2 participants