From 5cfe2a5fc621092ef4a14c22e2855fa07b690cac Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 25 May 2021 17:13:15 +0200 Subject: [PATCH] Add new suggestion to array_into_iter lint. --- compiler/rustc_lint/src/array_into_iter.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/rustc_lint/src/array_into_iter.rs b/compiler/rustc_lint/src/array_into_iter.rs index 92c6ae352925..738c63c3b8b4 100644 --- a/compiler/rustc_lint/src/array_into_iter.rs +++ b/compiler/rustc_lint/src/array_into_iter.rs @@ -110,6 +110,14 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { "iter".into(), Applicability::MachineApplicable, ) + .multipart_suggestion( + "or use `IntoIterator::into_iter(..)` instead of `.into_iter()` to explicitly iterate by value", + vec![ + (expr.span.shrink_to_lo(), "IntoIterator::into_iter(".into()), + (receiver_arg.span.shrink_to_hi().to(expr.span.shrink_to_hi()), ")".into()), + ], + Applicability::MaybeIncorrect, + ) .emit(); }) }