Skip to content

Account for incorrect [].into_iter() in <2021 edition #85189

Closed
@estebank

Description

@estebank

Currently uses of <[_; _] as _>::into_iter() emit a future compat warning:

warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
 --> src/main.rs:2:23
  |
2 |     let _ = [1, 2, 3].into_iter();
  |                       ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
  |
  = note: `#[warn(array_into_iter)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>

but at some point this will cause ambiguity errors on 2015 and 2018 editions. On 2021 onwards, this case is handled by a special attribute and keeps the code compiling.

We should detect that case explicitly and provide guidance about what to write in the current edition, or to update to the new edition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-edition-2021Area: The 2021 editionD-editionDiagnostics: An error or lint that should account for edition differences.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions