Skip to content

Commit aec2c5b

Browse files
committed
Update tests for updated array_into_iter lint.
1 parent 5cfe2a5 commit aec2c5b

5 files changed

+166
-54
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ 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`
15+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
1616
//~| WARNING this changes meaning
1717

1818
let _: Iter<'_, i32> = Box::new(array).into_iter();
19-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
19+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
2020
//~| WARNING this changes meaning
2121

2222
// The `array_into_iter` lint doesn't cover other wrappers that deref to an array.
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
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
88
= warning: this changes meaning in Rust 2021
99
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
10+
help: use `.iter()` instead of `.into_iter()` to avoid ambiguity
11+
|
12+
LL | let _: Iter<'_, i32> = array.iter();
13+
| ^^^^
14+
help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value
15+
|
16+
LL | let _: Iter<'_, i32> = IntoIterator::into_iter(array);
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^ ^
1018

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.
19+
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.
1220
--> $DIR/into-iter-on-arrays-2018.rs:18:44
1321
|
1422
LL | let _: Iter<'_, i32> = Box::new(array).into_iter();
15-
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
23+
| ^^^^^^^^^
1624
|
1725
= warning: this changes meaning in Rust 2021
1826
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
27+
help: use `.iter()` instead of `.into_iter()` to avoid ambiguity
28+
|
29+
LL | let _: Iter<'_, i32> = Box::new(array).iter();
30+
| ^^^^
31+
help: or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value
32+
|
33+
LL | let _: Iter<'_, i32> = IntoIterator::into_iter(Box::new(array));
34+
| ^^^^^^^^^^^^^^^^^^^^^^^^ ^
1935

2036
warning: 2 warnings emitted
2137

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,42 @@ 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`
10+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
1111
//~| WARNING this changes meaning
1212
[1, 2].iter();
13-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
13+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
1414
//~| WARNING this changes meaning
1515
big.iter();
16-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
16+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
1717
//~| WARNING this changes meaning
1818
[0u8; 33].iter();
19-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
19+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
2020
//~| WARNING this changes meaning
2121

2222
Box::new(small).iter();
23-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
23+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
2424
//~| WARNING this changes meaning
2525
Box::new([1, 2]).iter();
26-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
26+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
2727
//~| WARNING this changes meaning
2828
Box::new(big).iter();
29-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
29+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
3030
//~| WARNING this changes meaning
3131
Box::new([0u8; 33]).iter();
32-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
32+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
3333
//~| WARNING this changes meaning
3434

3535
Box::new(Box::new(small)).iter();
36-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
36+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
3737
//~| WARNING this changes meaning
3838
Box::new(Box::new([1, 2])).iter();
39-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
39+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
4040
//~| WARNING this changes meaning
4141
Box::new(Box::new(big)).iter();
42-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
42+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
4343
//~| WARNING this changes meaning
4444
Box::new(Box::new([0u8; 33])).iter();
45-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
45+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
4646
//~| WARNING this changes meaning
4747

4848
// Expressions that should not

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,42 @@ 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`
10+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
1111
//~| WARNING this changes meaning
1212
[1, 2].into_iter();
13-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
13+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
1414
//~| WARNING this changes meaning
1515
big.into_iter();
16-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
16+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
1717
//~| WARNING this changes meaning
1818
[0u8; 33].into_iter();
19-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
19+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
2020
//~| WARNING this changes meaning
2121

2222
Box::new(small).into_iter();
23-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
23+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
2424
//~| WARNING this changes meaning
2525
Box::new([1, 2]).into_iter();
26-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
26+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
2727
//~| WARNING this changes meaning
2828
Box::new(big).into_iter();
29-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
29+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
3030
//~| WARNING this changes meaning
3131
Box::new([0u8; 33]).into_iter();
32-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
32+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
3333
//~| WARNING this changes meaning
3434

3535
Box::new(Box::new(small)).into_iter();
36-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
36+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
3737
//~| WARNING this changes meaning
3838
Box::new(Box::new([1, 2])).into_iter();
39-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
39+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
4040
//~| WARNING this changes meaning
4141
Box::new(Box::new(big)).into_iter();
42-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
42+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
4343
//~| WARNING this changes meaning
4444
Box::new(Box::new([0u8; 33])).into_iter();
45-
//~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter`
45+
//~^ WARNING this method call resolves to `<&[T; N] as IntoIterator>::into_iter`
4646
//~| WARNING this changes meaning
4747

4848
// Expressions that should not

0 commit comments

Comments
 (0)