Skip to content

Commit 37e1780

Browse files
committed
Change wording on array_into_iter lint for 1.53 and edition changes.
1 parent 4819719 commit 37e1780

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

compiler/rustc_lint/src/array_into_iter.rs

+11-17
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,15 @@ declare_lint! {
2121
///
2222
/// ### Explanation
2323
///
24-
/// In the future, it is planned to add an `IntoIter` implementation for
25-
/// arrays such that it will iterate over *values* of the array instead of
26-
/// references. Due to how method resolution works, this will change
27-
/// existing code that uses `into_iter` on arrays. The solution to avoid
28-
/// this warning is to use `iter()` instead of `into_iter()`.
29-
///
30-
/// This is a [future-incompatible] lint to transition this to a hard error
31-
/// in the future. See [issue #66145] for more details and a more thorough
32-
/// description of the lint.
33-
///
34-
/// [issue #66145]: https://github.com/rust-lang/rust/issues/66145
35-
/// [future-incompatible]: ../index.md#future-incompatible-lints
24+
/// Since Rust 1.53, arrays implement `IntoIterator`. However, to avoid
25+
/// breakage, `array.into_iter()` in Rust 2015 and 2018 code will still
26+
/// behave as `(&array).into_iter()`, returning an iterator over
27+
/// references, just like in Rust 1.52 and earlier.
28+
/// This only applies to the method call syntax `array.into_iter()`, not to
29+
/// any other syntax such as `for _ in array` or `IntoIterator::into_iter(array)`.
3630
pub ARRAY_INTO_ITER,
3731
Warn,
38-
"detects calling `into_iter` on arrays",
32+
"detects calling `into_iter` on arrays in Rust 2015 and 2018",
3933
@future_incompatible = FutureIncompatibleInfo {
4034
reference: "issue #66145 <https://github.com/rust-lang/rust/issues/66145>",
4135
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2021),
@@ -105,10 +99,10 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
10599
};
106100
cx.struct_span_lint(ARRAY_INTO_ITER, *span, |lint| {
107101
lint.build(&format!(
108-
"this method call currently resolves to `<&{} as IntoIterator>::into_iter` (due \
109-
to autoref coercions), but that might change in the future when \
110-
`IntoIterator` impls for arrays are added.",
111-
target,
102+
"this method call resolves to `<&{} as IntoIterator>::into_iter` \
103+
(due to backwards compatibility), \
104+
but will resolve to <{} as IntoIterator>::into_iter in Rust 2021.",
105+
target, target,
112106
))
113107
.span_suggestion(
114108
call.ident.span,

0 commit comments

Comments
 (0)