Skip to content

Commit 25f02b2

Browse files
committed
Test Box::new(array).into_iter()
1 parent 3dab4e2 commit 25f02b2

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
// check-pass
2+
// edition:2018
23

34
use std::array::IntoIter;
45
use std::slice::Iter;
56

67
fn main() {
78
let array = [0; 10];
89

9-
// Before 2021, the method dispatched to `IntoIterator for &[T]`,
10+
// Before 2021, the method dispatched to `IntoIterator for &[T; N]`,
1011
// which we continue to support for compatibility.
1112
let _: Iter<'_, i32> = array.into_iter();
1213
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
1314
//~| WARNING this was previously accepted by the compiler but is being phased out
1415

16+
let _: Iter<'_, i32> = Box::new(array).into_iter();
17+
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
18+
//~| WARNING this was previously accepted by the compiler but is being phased out
19+
1520
// But you can always use the trait method explicitly as an array.
1621
let _: IntoIter<i32, 10> = IntoIterator::into_iter(array);
1722
}
Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
2-
--> $DIR/into-iter-on-arrays-2018.rs:11:34
2+
--> $DIR/into-iter-on-arrays-2018.rs:12:34
33
|
44
LL | let _: Iter<'_, i32> = array.into_iter();
55
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
@@ -8,11 +8,20 @@ LL | let _: Iter<'_, i32> = array.into_iter();
88
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
99
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
1010

11-
warning: 1 warning emitted
11+
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
12+
--> $DIR/into-iter-on-arrays-2018.rs:16:44
13+
|
14+
LL | let _: Iter<'_, i32> = Box::new(array).into_iter();
15+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
16+
|
17+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
18+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
19+
20+
warning: 2 warnings emitted
1221

1322
Future incompatibility report: Future breakage date: None, diagnostic:
1423
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
15-
--> $DIR/into-iter-on-arrays-2018.rs:11:34
24+
--> $DIR/into-iter-on-arrays-2018.rs:12:34
1625
|
1726
LL | let _: Iter<'_, i32> = array.into_iter();
1827
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
@@ -21,3 +30,13 @@ LL | let _: Iter<'_, i32> = array.into_iter();
2130
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2231
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
2332

33+
Future breakage date: None, diagnostic:
34+
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
35+
--> $DIR/into-iter-on-arrays-2018.rs:16:44
36+
|
37+
LL | let _: Iter<'_, i32> = Box::new(array).into_iter();
38+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
39+
|
40+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
41+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
42+

src/test/ui/iterators/into-iter-on-arrays-2021.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fn main() {
99

1010
// In 2021, the method dispatches to `IntoIterator for [T; N]`.
1111
let _: IntoIter<i32, 10> = array.into_iter();
12+
let _: IntoIter<i32, 10> = Box::new(array).into_iter();
1213

1314
// And you can always use the trait method explicitly as an array.
1415
let _: IntoIter<i32, 10> = IntoIterator::into_iter(array);

0 commit comments

Comments
 (0)