diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2021-05-25 17:13:15 +0200 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2021-06-26 12:03:33 +0000 |
| commit | 5cfe2a5fc621092ef4a14c22e2855fa07b690cac (patch) | |
| tree | 4f9a98d307c7b4ea09c0302c05d4d2ddd30076db /compiler/rustc_lint/src/array_into_iter.rs | |
| parent | 37e17803b57877637d4b6b13c8813589bd140452 (diff) | |
| download | rust-5cfe2a5fc621092ef4a14c22e2855fa07b690cac.tar.gz rust-5cfe2a5fc621092ef4a14c22e2855fa07b690cac.zip | |
Add new suggestion to array_into_iter lint.
Diffstat (limited to 'compiler/rustc_lint/src/array_into_iter.rs')
| -rw-r--r-- | compiler/rustc_lint/src/array_into_iter.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_lint/src/array_into_iter.rs b/compiler/rustc_lint/src/array_into_iter.rs index 92c6ae35292..738c63c3b8b 100644 --- a/compiler/rustc_lint/src/array_into_iter.rs +++ b/compiler/rustc_lint/src/array_into_iter.rs @@ -110,6 +110,14 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter { "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(); }) } |
