You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #67524 - LukasKalbertodt:improve-into-iter-lint, r=matthewjasper
Generalize `array_into_iter` lint to also lint for boxed arrays
`Box` is special in that a method call on a box can move the value out
of the box. Thus, the same backwards-compatibility problem can arise
for boxed arrays as for simple arrays.
---
CC #66145
r? @matthewjasper (as you reviewed the first PR)
Copy file name to clipboardExpand all lines: src/test/ui/iterators/into-iter-on-arrays-lint.stderr
+72
Original file line number
Diff line number
Diff line change
@@ -35,3 +35,75 @@ LL | [0u8; 33].into_iter();
35
35
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
36
36
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
37
37
38
+
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.
39
+
--> $DIR/into-iter-on-arrays-lint.rs:22:21
40
+
|
41
+
LL | Box::new(small).into_iter();
42
+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
43
+
|
44
+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
45
+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
46
+
47
+
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.
48
+
--> $DIR/into-iter-on-arrays-lint.rs:25:22
49
+
|
50
+
LL | Box::new([1, 2]).into_iter();
51
+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
52
+
|
53
+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
54
+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
55
+
56
+
warning: this method call currently resolves to `<&[T] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
57
+
--> $DIR/into-iter-on-arrays-lint.rs:28:19
58
+
|
59
+
LL | Box::new(big).into_iter();
60
+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
61
+
|
62
+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
63
+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
64
+
65
+
warning: this method call currently resolves to `<&[T] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
66
+
--> $DIR/into-iter-on-arrays-lint.rs:31:25
67
+
|
68
+
LL | Box::new([0u8; 33]).into_iter();
69
+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
70
+
|
71
+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
72
+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
73
+
74
+
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.
75
+
--> $DIR/into-iter-on-arrays-lint.rs:35:31
76
+
|
77
+
LL | Box::new(Box::new(small)).into_iter();
78
+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
79
+
|
80
+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
81
+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
82
+
83
+
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.
84
+
--> $DIR/into-iter-on-arrays-lint.rs:38:32
85
+
|
86
+
LL | Box::new(Box::new([1, 2])).into_iter();
87
+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
88
+
|
89
+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
90
+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
91
+
92
+
warning: this method call currently resolves to `<&[T] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
93
+
--> $DIR/into-iter-on-arrays-lint.rs:41:29
94
+
|
95
+
LL | Box::new(Box::new(big)).into_iter();
96
+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
97
+
|
98
+
= 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>
100
+
101
+
warning: this method call currently resolves to `<&[T] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
102
+
--> $DIR/into-iter-on-arrays-lint.rs:44:35
103
+
|
104
+
LL | Box::new(Box::new([0u8; 33])).into_iter();
105
+
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
106
+
|
107
+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
108
+
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
0 commit comments