1
Fork 0

Rollup merge of #88503 - m-ou-se:array-into-inter-ambiguous, r=cjgillot

Warn when [T; N].into_iter() is ambiguous in the new edition.

Fixes https://github.com/rust-lang/rust/issues/88475

In https://github.com/rust-lang/rust/issues/88475, a situation was found where `[T; N].into_iter()` becomes *ambiguous* in the new edition. This is different than the case where `(&[T; N]).into_iter()` resolves differently, which was the only case handled by the `array_into_iter` lint. This is almost identical to the new-traits-in-the-prelude problem. Effectively, due to the array-into-iter hack disappearing in Rust 2021, we effectively added `IntoIterator` to the 'prelude' in Rust 2021 specifically for arrays.

This modifies the prelude collisions lint to detect that case and emit a `array_into_iter` lint in that case.
This commit is contained in:
Mara Bos 2021-08-31 10:41:29 +02:00 committed by GitHub
commit caca256b52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 91 additions and 7 deletions

View file

@ -62,6 +62,8 @@ mod traits;
mod types;
mod unused;
pub use array_into_iter::ARRAY_INTO_ITER;
use rustc_ast as ast;
use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;