Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 259348c

Browse files
committed
Remove unnecessary argument from suggest_cloning
1 parent 01b810e commit 259348c

File tree

2 files changed

+9
-21
lines changed

2 files changed

+9
-21
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
476476
} else if self.suggest_hoisting_call_outside_loop(err, expr) {
477477
// The place where the the type moves would be misleading to suggest clone.
478478
// #121466
479-
self.suggest_cloning(err, ty, expr, move_span);
479+
self.suggest_cloning(err, ty, expr);
480480
}
481481
}
482482
if let Some(pat) = finder.pat {
@@ -987,20 +987,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
987987
can_suggest_clone
988988
}
989989

990-
pub(crate) fn suggest_cloning(
991-
&self,
992-
err: &mut Diag<'_>,
993-
ty: Ty<'tcx>,
994-
expr: &hir::Expr<'_>,
995-
span: Span,
996-
) {
990+
pub(crate) fn suggest_cloning(&self, err: &mut Diag<'_>, ty: Ty<'tcx>, expr: &hir::Expr<'_>) {
997991
if let Some(clone_trait_def) = self.infcx.tcx.lang_items().clone_trait()
998992
&& self
999993
.infcx
1000994
.type_implements_trait(clone_trait_def, [ty], self.param_env)
1001995
.must_apply_modulo_regions()
1002996
{
1003-
self.suggest_cloning_inner(err, ty, expr, span);
997+
self.suggest_cloning_inner(err, ty, expr);
1004998
}
1005999
}
10061000

@@ -1019,13 +1013,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10191013
}
10201014
}
10211015

1022-
fn suggest_cloning_inner(
1023-
&self,
1024-
err: &mut Diag<'_>,
1025-
ty: Ty<'tcx>,
1026-
expr: &hir::Expr<'_>,
1027-
span: Span,
1028-
) {
1016+
fn suggest_cloning_inner(&self, err: &mut Diag<'_>, ty: Ty<'tcx>, expr: &hir::Expr<'_>) {
10291017
let tcx = self.infcx.tcx;
10301018
if let Some(_) = self.clone_on_reference(expr) {
10311019
// Avoid redundant clone suggestion already suggested in `explain_captures`.
@@ -1053,7 +1041,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10531041
// Account for `(*x)` to suggest `x.clone()`.
10541042
expr.span.with_lo(inner_expr.span.hi())
10551043
} else {
1056-
span.shrink_to_hi()
1044+
expr.span.shrink_to_hi()
10571045
};
10581046
sugg.push((span, suggestion));
10591047
let msg = if let ty::Adt(def, _) = ty.kind()
@@ -1173,7 +1161,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11731161
if let Some(expr) = self.find_expr(borrow_span)
11741162
&& let Some(ty) = typeck_results.node_type_opt(expr.hir_id)
11751163
{
1176-
self.suggest_cloning(&mut err, ty, expr, borrow_span);
1164+
self.suggest_cloning(&mut err, ty, expr);
11771165
}
11781166
self.buffer_error(err);
11791167
}

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
445445
};
446446

447447
if let Some(expr) = self.find_expr(span) {
448-
self.suggest_cloning(err, place_ty, expr, span);
448+
self.suggest_cloning(err, place_ty, expr);
449449
}
450450

451451
err.subdiagnostic(
@@ -480,7 +480,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
480480
};
481481

482482
if let Some(expr) = self.find_expr(span) {
483-
self.suggest_cloning(err, place_ty, expr, span);
483+
self.suggest_cloning(err, place_ty, expr);
484484
}
485485

486486
err.subdiagnostic(
@@ -593,7 +593,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
593593
let place_desc = &format!("`{}`", self.local_names[*local].unwrap());
594594

595595
if let Some(expr) = self.find_expr(binding_span) {
596-
self.suggest_cloning(err, bind_to.ty, expr, binding_span);
596+
self.suggest_cloning(err, bind_to.ty, expr);
597597
}
598598

599599
err.subdiagnostic(

0 commit comments

Comments
 (0)