about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
diff options
context:
space:
mode:
authorMaybe Waffle <waffle.lapkin@gmail.com>2022-07-25 00:58:04 +0400
committerMaybe Waffle <waffle.lapkin@gmail.com>2022-10-09 13:05:53 +0000
commit23a7674e3eb7e860ae59e81acc0699926dd0797c (patch)
tree063d694e049a2acaaf12e6f597357b8542c5d4f9 /compiler/rustc_lint/src
parent730856442387c9804581eae5927a5667171022ca (diff)
downloadrust-23a7674e3eb7e860ae59e81acc0699926dd0797c.tar.gz
rust-23a7674e3eb7e860ae59e81acc0699926dd0797c.zip
`for_loop_over_fallibles`: fix suggestion for "remove `.next()`" case
if the iterator is used after the loop, we need to use `.by_ref()`
Diffstat (limited to 'compiler/rustc_lint/src')
-rw-r--r--compiler/rustc_lint/src/for_loop_over_fallibles.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_lint/src/for_loop_over_fallibles.rs b/compiler/rustc_lint/src/for_loop_over_fallibles.rs
index 69d8fd84b64..c8d5586d39f 100644
--- a/compiler/rustc_lint/src/for_loop_over_fallibles.rs
+++ b/compiler/rustc_lint/src/for_loop_over_fallibles.rs
@@ -82,7 +82,7 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopOverFallibles {
                 warn.span_suggestion(
                     recv.span.between(arg.span.shrink_to_hi()),
                     format!("to iterate over `{recv_snip}` remove the call to `next`"),
-                    "",
+                    ".by_ref()",
                     Applicability::MaybeIncorrect
                 );
             } else {