about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-09-05 04:26:37 +0000
committerMichael Goulet <michael@errs.io>2022-09-05 04:27:07 +0000
commit41d4ea231410004f8f07bc097c51a5fe991b4ba5 (patch)
treed51b416051d0842f0c179a07e338b2b13e9cd61f /compiler
parenta2cdcb3fea2baae5d20eabaa412e0d2f5b98c318 (diff)
downloadrust-41d4ea231410004f8f07bc097c51a5fe991b4ba5.tar.gz
rust-41d4ea231410004f8f07bc097c51a5fe991b4ba5.zip
Don't suggest reborrow if usage is inside a closure
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
index 5971f7623f2..f2204c24263 100644
--- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
@@ -258,7 +258,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
             let ty = place.ty(self.body, self.infcx.tcx).ty;
 
             // If we're in pattern, we do nothing in favor of the previous suggestion (#80913).
-            if is_loop_move & !in_pattern {
+            // Same for if we're in a loop, see #101119.
+            if is_loop_move & !in_pattern && !matches!(use_spans, UseSpans::ClosureUse { .. }) {
                 if let ty::Ref(_, _, hir::Mutability::Mut) = ty.kind() {
                     // We have a `&mut` ref, we need to reborrow on each iteration (#62112).
                     err.span_suggestion_verbose(