Change wording on array_into_iter lint for 1.53 and edition changes.
This commit is contained in:
parent
481971978f
commit
37e17803b5
1 changed files with 11 additions and 17 deletions
|
@ -21,21 +21,15 @@ declare_lint! {
|
||||||
///
|
///
|
||||||
/// ### Explanation
|
/// ### Explanation
|
||||||
///
|
///
|
||||||
/// In the future, it is planned to add an `IntoIter` implementation for
|
/// Since Rust 1.53, arrays implement `IntoIterator`. However, to avoid
|
||||||
/// arrays such that it will iterate over *values* of the array instead of
|
/// breakage, `array.into_iter()` in Rust 2015 and 2018 code will still
|
||||||
/// references. Due to how method resolution works, this will change
|
/// behave as `(&array).into_iter()`, returning an iterator over
|
||||||
/// existing code that uses `into_iter` on arrays. The solution to avoid
|
/// references, just like in Rust 1.52 and earlier.
|
||||||
/// this warning is to use `iter()` instead of `into_iter()`.
|
/// This only applies to the method call syntax `array.into_iter()`, not to
|
||||||
///
|
/// any other syntax such as `for _ in array` or `IntoIterator::into_iter(array)`.
|
||||||
/// This is a [future-incompatible] lint to transition this to a hard error
|
|
||||||
/// in the future. See [issue #66145] for more details and a more thorough
|
|
||||||
/// description of the lint.
|
|
||||||
///
|
|
||||||
/// [issue #66145]: https://github.com/rust-lang/rust/issues/66145
|
|
||||||
/// [future-incompatible]: ../index.md#future-incompatible-lints
|
|
||||||
pub ARRAY_INTO_ITER,
|
pub ARRAY_INTO_ITER,
|
||||||
Warn,
|
Warn,
|
||||||
"detects calling `into_iter` on arrays",
|
"detects calling `into_iter` on arrays in Rust 2015 and 2018",
|
||||||
@future_incompatible = FutureIncompatibleInfo {
|
@future_incompatible = FutureIncompatibleInfo {
|
||||||
reference: "issue #66145 <https://github.com/rust-lang/rust/issues/66145>",
|
reference: "issue #66145 <https://github.com/rust-lang/rust/issues/66145>",
|
||||||
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2021),
|
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2021),
|
||||||
|
@ -105,10 +99,10 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
|
||||||
};
|
};
|
||||||
cx.struct_span_lint(ARRAY_INTO_ITER, *span, |lint| {
|
cx.struct_span_lint(ARRAY_INTO_ITER, *span, |lint| {
|
||||||
lint.build(&format!(
|
lint.build(&format!(
|
||||||
"this method call currently resolves to `<&{} as IntoIterator>::into_iter` (due \
|
"this method call resolves to `<&{} as IntoIterator>::into_iter` \
|
||||||
to autoref coercions), but that might change in the future when \
|
(due to backwards compatibility), \
|
||||||
`IntoIterator` impls for arrays are added.",
|
but will resolve to <{} as IntoIterator>::into_iter in Rust 2021.",
|
||||||
target,
|
target, target,
|
||||||
))
|
))
|
||||||
.span_suggestion(
|
.span_suggestion(
|
||||||
call.ident.span,
|
call.ident.span,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue