Skip to content

Commit 1e89954

Browse files
committed
Add new suggestion to array_into_iter lint.
1 parent 50236d8 commit 1e89954

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
@@ -104,6 +104,14 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
104104
"iter".into(),
105105
Applicability::MachineApplicable,
106106
)
107+
.multipart_suggestion(
108+
"or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value",
109+
vec![
110+
(expr.span.shrink_to_lo(), "IntoIterator::into_iter(".into()),
111+
(receiver_arg.span.shrink_to_hi().to(expr.span.shrink_to_hi()), ")".into()),
112+
],
113+
Applicability::MaybeIncorrect,
114+
)
107115
.emit();
108116
})
109117
}

0 commit comments

Comments
 (0)