Add test for 2021 ambiguous [T; N].into_iter().

This commit is contained in:
Mara Bos 2021-08-30 21:23:56 +02:00
parent 336f31432d
commit 756ef3bff6
3 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,27 @@
// See https://github.com/rust-lang/rust/issues/88475
// run-rustfix
// edition:2018
// check-pass
#![warn(array_into_iter)]
#![allow(unused)]
struct FooIter;
trait MyIntoIter {
fn into_iter(self) -> FooIter;
}
impl<T, const N: usize> MyIntoIter for [T; N] {
fn into_iter(self) -> FooIter {
FooIter
}
}
struct Point;
pub fn main() {
let points: [Point; 1] = [Point];
let y = MyIntoIter::into_iter(points);
//~^ WARNING trait method `into_iter` will become ambiguous in Rust 2021
//~| WARNING this changes meaning in Rust 2021
}

View File

@ -0,0 +1,27 @@
// See https://github.com/rust-lang/rust/issues/88475
// run-rustfix
// edition:2018
// check-pass
#![warn(array_into_iter)]
#![allow(unused)]
struct FooIter;
trait MyIntoIter {
fn into_iter(self) -> FooIter;
}
impl<T, const N: usize> MyIntoIter for [T; N] {
fn into_iter(self) -> FooIter {
FooIter
}
}
struct Point;
pub fn main() {
let points: [Point; 1] = [Point];
let y = points.into_iter();
//~^ WARNING trait method `into_iter` will become ambiguous in Rust 2021
//~| WARNING this changes meaning in Rust 2021
}

View File

@ -0,0 +1,16 @@
warning: trait method `into_iter` will become ambiguous in Rust 2021
--> $DIR/array-into-iter-ambiguous.rs:24:13
|
LL | let y = points.into_iter();
| ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `MyIntoIter::into_iter(points)`
|
note: the lint level is defined here
--> $DIR/array-into-iter-ambiguous.rs:5:9
|
LL | #![warn(array_into_iter)]
| ^^^^^^^^^^^^^^^
= warning: this changes meaning in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/IntoIterator-for-arrays.html>
warning: 1 warning emitted