Skip to content

Commit 756ef3b

Browse files
committed
Add test for 2021 ambiguous [T; N].into_iter().
1 parent 336f314 commit 756ef3b

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// See https://github.com/rust-lang/rust/issues/88475
2+
// run-rustfix
3+
// edition:2018
4+
// check-pass
5+
#![warn(array_into_iter)]
6+
#![allow(unused)]
7+
8+
struct FooIter;
9+
10+
trait MyIntoIter {
11+
fn into_iter(self) -> FooIter;
12+
}
13+
14+
impl<T, const N: usize> MyIntoIter for [T; N] {
15+
fn into_iter(self) -> FooIter {
16+
FooIter
17+
}
18+
}
19+
20+
struct Point;
21+
22+
pub fn main() {
23+
let points: [Point; 1] = [Point];
24+
let y = MyIntoIter::into_iter(points);
25+
//~^ WARNING trait method `into_iter` will become ambiguous in Rust 2021
26+
//~| WARNING this changes meaning in Rust 2021
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// See https://github.com/rust-lang/rust/issues/88475
2+
// run-rustfix
3+
// edition:2018
4+
// check-pass
5+
#![warn(array_into_iter)]
6+
#![allow(unused)]
7+
8+
struct FooIter;
9+
10+
trait MyIntoIter {
11+
fn into_iter(self) -> FooIter;
12+
}
13+
14+
impl<T, const N: usize> MyIntoIter for [T; N] {
15+
fn into_iter(self) -> FooIter {
16+
FooIter
17+
}
18+
}
19+
20+
struct Point;
21+
22+
pub fn main() {
23+
let points: [Point; 1] = [Point];
24+
let y = points.into_iter();
25+
//~^ WARNING trait method `into_iter` will become ambiguous in Rust 2021
26+
//~| WARNING this changes meaning in Rust 2021
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
warning: trait method `into_iter` will become ambiguous in Rust 2021
2+
--> $DIR/array-into-iter-ambiguous.rs:24:13
3+
|
4+
LL | let y = points.into_iter();
5+
| ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `MyIntoIter::into_iter(points)`
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/array-into-iter-ambiguous.rs:5:9
9+
|
10+
LL | #![warn(array_into_iter)]
11+
| ^^^^^^^^^^^^^^^
12+
= warning: this changes meaning in Rust 2021
13+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/IntoIterator-for-arrays.html>
14+
15+
warning: 1 warning emitted
16+

0 commit comments

Comments
 (0)