Add test for 2021 ambiguous [T; N].into_iter().
This commit is contained in:
parent
336f31432d
commit
756ef3bff6
27
src/test/ui/rust-2021/array-into-iter-ambiguous.fixed
Normal file
27
src/test/ui/rust-2021/array-into-iter-ambiguous.fixed
Normal 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
|
||||
}
|
27
src/test/ui/rust-2021/array-into-iter-ambiguous.rs
Normal file
27
src/test/ui/rust-2021/array-into-iter-ambiguous.rs
Normal 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
|
||||
}
|
16
src/test/ui/rust-2021/array-into-iter-ambiguous.stderr
Normal file
16
src/test/ui/rust-2021/array-into-iter-ambiguous.stderr
Normal 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user