Skip to content

Commit 5cfe2a5

Browse files
committed
Add new suggestion to array_into_iter lint.
1 parent 37e1780 commit 5cfe2a5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

compiler/rustc_lint/src/array_into_iter.rs

+8
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
110110
"iter".into(),
111111
Applicability::MachineApplicable,
112112
)
113+
.multipart_suggestion(
114+
"or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value",
115+
vec![
116+
(expr.span.shrink_to_lo(), "IntoIterator::into_iter(".into()),
117+
(receiver_arg.span.shrink_to_hi().to(expr.span.shrink_to_hi()), ")".into()),
118+
],
119+
Applicability::MaybeIncorrect,
120+
)
113121
.emit();
114122
})
115123
}

0 commit comments

Comments
 (0)