Skip to content

Commit 3b237d7

Browse files
committed
Move suggest_hoisting_call_outside_loop out of suggest_cloning
1 parent da2364d commit 3b237d7

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Diff for: compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
463463
} else if let UseSpans::FnSelfUse { kind: CallKind::Normal { .. }, .. } = move_spans
464464
{
465465
// We already suggest cloning for these cases in `explain_captures`.
466-
} else {
466+
} else if self.suggest_hoisting_call_outside_loop(err, expr) {
467+
// The place where the the type moves would be misleading to suggest clone.
468+
// #121466
467469
self.suggest_cloning(err, ty, expr, move_span);
468470
}
469471
}
@@ -977,11 +979,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
977979

978980
fn suggest_cloning(&self, err: &mut Diag<'_>, ty: Ty<'tcx>, expr: &hir::Expr<'_>, span: Span) {
979981
let tcx = self.infcx.tcx;
980-
if !self.suggest_hoisting_call_outside_loop(err, expr) {
981-
// The place where the the type moves would be misleading to suggest clone. (#121466)
982-
return;
983-
}
984-
985982
// Try to find predicates on *generic params* that would allow copying `ty`
986983
let suggestion =
987984
if let Some(symbol) = tcx.hir().maybe_get_struct_pattern_shorthand_field(expr) {

0 commit comments

Comments
 (0)