Repository: rust
Issue: Tracking Issue for edition-dependent IntoIterator for arrays
Labels: A-docs,C-tracking-issue,A-iterators,T-libs,A-edition-2021,A-array

- [x] `array::IntoIter` type: https://github.com/rust-lang/rust/issues/65798
- [x] Idea to make `.into_iter()` resolution edition dependent: https://github.com/rust-lang/rust/issues/84133
- [x] FCP: https://github.com/rust-lang/rust/pull/84147#issuecomment-818988924
- [x] IntoIterator implementation for arrays: ~~https://github.com/rust-lang/rust/pull/65819~~ Included in https://github.com/rust-lang/rust/pull/84147
- [x] Ignore the by-value `.into_iter()` in method resolution on Rust 2015 and Rust 2018: https://github.com/rust-lang/rust/pull/84147
- [x] Update `array_into_iter` lint.
    - [x] Change the "might change in the future" wording: #85682
    - [x] Correct wording for the current situation in the message (arrays *do* implement the trait, the method is just hiding itself in `a.into_iter()` syntax for backwards compatibility): #85682
    - [x] Also suggest just removing `.into_iter()` in `for a in [1, 2, 3].into_iter()`, since that now works on all editions: #85682
    - [x] Also suggest `IntoIterator::into_iter(array)`: #85682
    - [x] Extend lint to also cover [this case](https://github.com/rust-lang/rust/pull/84147#issuecomment-819000436) and [this case](https://github.com/rust-lang/rust/issues/88099)? https://github.com/rust-lang/rust/pull/88512
- [x] Update documentation
    - [x] #87701
        - [x] Point out that behaviour might be switched on 2015 and 2018 too one day - https://github.com/rust-lang/rust/pull/84590
        - [x] Fix docs of `array::IntoIter::new` (the ".. in the future, after .." part): https://github.com/rust-lang/rust/pull/88610
        - [x] Update docs of the `array` primitive type - https://github.com/rust-lang/rust/pull/88613
    - [x] Update the book (e.g. [this section](https://doc.rust-lang.org/book/ch03-05-control-flow.html#looping-through-a-collection-with-for) and probably more, and many examples).
- [x] Update standard library
    - [x] Remove usages of `array::IntoIter::new`: #85930
    - [x] Update expressions like like `.chain(array.iter().cloned())` to just `.chain(array)` since that now works on all editions. (Same for `zip`, `extend` etc.): #85930
    - [x] Use `.extend(array)` and `from_iter(array)` wherever that simplifies things.
    - [x] Remove `arrays do not yet implement IntoIterator` message from Iterator trait: #85670
    - [x] Remove `for _ in [start..end]` messages from Iterator trait. (Could use a new clippy lint?): https://github.com/rust-lang/rust/pull/85689
- [x] Deprecate `array::IntoIter::new` (`IntoIterator::into_iter([1,2,3])` now works too on all editions.): https://github.com/rust-lang/rust/pull/88611

Once edition 2021 is stable:
- [ ] Update examples like [this](https://github.com/rust-lang/rust/blob/e11a9fa52a3f372dadd6db3d3f2ed7dc2621dcc4/library/core/src/iter/traits/iterator.rs#L458-L469) to use arrays by value. (`Some(&1)` → `Some(1)` etc.)
    - [ ] Update examples to no longer avoid iterating arrays. (Many doctest examples are using iterators over e.g. `&i32` instead of just `i32`.)
- [ ] Remove about 200 usages of `.iter().copied()` and `.iter().cloned()` from examples and tests.

Unresolved questions:
- [ ] Do something about the 'copying large arrays' [footgun](https://github.com/rust-lang/rust/pull/84147#issuecomment-819417230). (Add `IntoIterator` implementation for `Box<[T; N]>` etc? Add lint about big copies?)