Skip to content

Commit fae4169

Browse files
committed
Update tests for updated array_into_iter lint.
1 parent 1e89954 commit fae4169

5 files changed

+165
-264
lines changed

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ fn main() {
1212
// Before 2021, the method dispatched to `IntoIterator for &[T; N]`,
1313
// which we continue to support for compatibility.
1414
let _: Iter<'_, i32> = array.into_iter();
15-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
16-
//~| WARNING this was previously accepted by the compiler but is being phased out
15+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
1716

1817
let _: Iter<'_, i32> = Box::new(array).into_iter();
19-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
20-
//~| WARNING this was previously accepted by the compiler but is being phased out
18+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
2119

2220
// The `array_into_iter` lint doesn't cover other wrappers that deref to an array.
2321
let _: Iter<'_, i32> = Rc::new(array).into_iter();
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,33 @@
1-
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.
1+
warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021.
22
--> $DIR/into-iter-on-arrays-2018.rs:14:34
33
|
44
LL | let _: Iter<'_, i32> = array.into_iter();
5-
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
5+
| ^^^^^^^^^
66
|
77
= note: `#[warn(array_into_iter)]` on by default
8-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
9-
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
10-
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:18:44
8+
help: use `.iter()` instead of `.into_iter()` to avoid ambiguity
139
|
14-
LL | let _: Iter<'_, i32> = Box::new(array).into_iter();
15-
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
10+
LL | let _: Iter<'_, i32> = array.iter();
11+
| ^^^^
12+
help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value
1613
|
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
14+
LL | let _: Iter<'_, i32> = IntoIterator::into_iter(array);
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^ ^
2116

22-
Future incompatibility report: Future breakage date: None, diagnostic:
23-
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.
24-
--> $DIR/into-iter-on-arrays-2018.rs:14:34
17+
warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to <[T; N] as IntoIterator>::into_iter in Rust 2021.
18+
--> $DIR/into-iter-on-arrays-2018.rs:17:44
2519
|
26-
LL | let _: Iter<'_, i32> = array.into_iter();
27-
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
20+
LL | let _: Iter<'_, i32> = Box::new(array).into_iter();
21+
| ^^^^^^^^^
2822
|
29-
= note: `#[warn(array_into_iter)]` on by default
30-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
31-
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
32-
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:18:44
23+
help: use `.iter()` instead of `.into_iter()` to avoid ambiguity
3624
|
37-
LL | let _: Iter<'_, i32> = Box::new(array).into_iter();
38-
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
25+
LL | let _: Iter<'_, i32> = Box::new(array).iter();
26+
| ^^^^
27+
help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value
3928
|
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>
29+
LL | let _: Iter<'_, i32> = IntoIterator::into_iter(Box::new(array));
30+
| ^^^^^^^^^^^^^^^^^^^^^^^^ ^
31+
32+
warning: 2 warnings emitted
4233

src/test/ui/iterators/into-iter-on-arrays-lint.fixed

+12-24
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,31 @@ fn main() {
77

88
// Expressions that should trigger the lint
99
small.iter();
10-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
11-
//~| WARNING this was previously accepted by the compiler but is being phased out
10+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
1211
[1, 2].iter();
13-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
14-
//~| WARNING this was previously accepted by the compiler but is being phased out
12+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
1513
big.iter();
16-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
17-
//~| WARNING this was previously accepted by the compiler but is being phased out
14+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
1815
[0u8; 33].iter();
19-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
20-
//~| WARNING this was previously accepted by the compiler but is being phased out
16+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
2117

2218
Box::new(small).iter();
23-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
24-
//~| WARNING this was previously accepted by the compiler but is being phased out
19+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
2520
Box::new([1, 2]).iter();
26-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
27-
//~| WARNING this was previously accepted by the compiler but is being phased out
21+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
2822
Box::new(big).iter();
29-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
30-
//~| WARNING this was previously accepted by the compiler but is being phased out
23+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
3124
Box::new([0u8; 33]).iter();
32-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
33-
//~| WARNING this was previously accepted by the compiler but is being phased out
25+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
3426

3527
Box::new(Box::new(small)).iter();
36-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
37-
//~| WARNING this was previously accepted by the compiler but is being phased out
28+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
3829
Box::new(Box::new([1, 2])).iter();
39-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
40-
//~| WARNING this was previously accepted by the compiler but is being phased out
30+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
4131
Box::new(Box::new(big)).iter();
42-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
43-
//~| WARNING this was previously accepted by the compiler but is being phased out
32+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
4433
Box::new(Box::new([0u8; 33])).iter();
45-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
46-
//~| WARNING this was previously accepted by the compiler but is being phased out
34+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
4735

4836
// Expressions that should not
4937
(&[1, 2]).into_iter();

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

+12-24
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,31 @@ fn main() {
77

88
// Expressions that should trigger the lint
99
small.into_iter();
10-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
11-
//~| WARNING this was previously accepted by the compiler but is being phased out
10+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
1211
[1, 2].into_iter();
13-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
14-
//~| WARNING this was previously accepted by the compiler but is being phased out
12+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
1513
big.into_iter();
16-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
17-
//~| WARNING this was previously accepted by the compiler but is being phased out
14+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
1815
[0u8; 33].into_iter();
19-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
20-
//~| WARNING this was previously accepted by the compiler but is being phased out
16+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
2117

2218
Box::new(small).into_iter();
23-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
24-
//~| WARNING this was previously accepted by the compiler but is being phased out
19+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
2520
Box::new([1, 2]).into_iter();
26-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
27-
//~| WARNING this was previously accepted by the compiler but is being phased out
21+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
2822
Box::new(big).into_iter();
29-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
30-
//~| WARNING this was previously accepted by the compiler but is being phased out
23+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
3124
Box::new([0u8; 33]).into_iter();
32-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
33-
//~| WARNING this was previously accepted by the compiler but is being phased out
25+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
3426

3527
Box::new(Box::new(small)).into_iter();
36-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
37-
//~| WARNING this was previously accepted by the compiler but is being phased out
28+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
3829
Box::new(Box::new([1, 2])).into_iter();
39-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
40-
//~| WARNING this was previously accepted by the compiler but is being phased out
30+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
4131
Box::new(Box::new(big)).into_iter();
42-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
43-
//~| WARNING this was previously accepted by the compiler but is being phased out
32+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
4433
Box::new(Box::new([0u8; 33])).into_iter();
45-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
46-
//~| WARNING this was previously accepted by the compiler but is being phased out
34+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
4735

4836
// Expressions that should not
4937
(&[1, 2]).into_iter();

0 commit comments

Comments
 (0)