diff options
| author | Michael Goulet <michael@errs.io> | 2022-09-05 04:26:37 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-09-05 04:27:07 +0000 |
| commit | 41d4ea231410004f8f07bc097c51a5fe991b4ba5 (patch) | |
| tree | d51b416051d0842f0c179a07e338b2b13e9cd61f /compiler | |
| parent | a2cdcb3fea2baae5d20eabaa412e0d2f5b98c318 (diff) | |
| download | rust-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.rs | 3 |
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( |
