Skip to content

Commit 4e6269d

Browse files
committed
Remove unnecessary argument from suggest_cloning
1 parent c1533d5 commit 4e6269d

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
@@ -464,7 +464,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
464464
{
465465
// We already suggest cloning for these cases in `explain_captures`.
466466
} else {
467-
self.suggest_cloning(err, ty, expr, move_span);
467+
self.suggest_cloning(err, ty, expr);
468468
}
469469
}
470470
if let Some(pat) = finder.pat {
@@ -747,20 +747,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
747747
true
748748
}
749749

750-
pub(crate) fn suggest_cloning(
751-
&self,
752-
err: &mut Diag<'_>,
753-
ty: Ty<'tcx>,
754-
expr: &hir::Expr<'_>,
755-
span: Span,
756-
) {
750+
pub(crate) fn suggest_cloning(&self, err: &mut Diag<'_>, ty: Ty<'tcx>, expr: &hir::Expr<'_>) {
757751
if let Some(clone_trait_def) = self.infcx.tcx.lang_items().clone_trait()
758752
&& self
759753
.infcx
760754
.type_implements_trait(clone_trait_def, [ty], self.param_env)
761755
.must_apply_modulo_regions()
762756
{
763-
self.suggest_cloning_inner(err, ty, expr, span);
757+
self.suggest_cloning_inner(err, ty, expr);
764758
}
765759
}
766760

@@ -779,13 +773,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
779773
}
780774
}
781775

782-
fn suggest_cloning_inner(
783-
&self,
784-
err: &mut Diag<'_>,
785-
ty: Ty<'tcx>,
786-
expr: &hir::Expr<'_>,
787-
span: Span,
788-
) {
776+
fn suggest_cloning_inner(&self, err: &mut Diag<'_>, ty: Ty<'tcx>, expr: &hir::Expr<'_>) {
789777
let tcx = self.infcx.tcx;
790778
if let Some(_) = self.clone_on_reference(expr) {
791779
// Avoid redundant clone suggestion already suggested in `explain_captures`.
@@ -813,7 +801,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
813801
// Account for `(*x)` to suggest `x.clone()`.
814802
expr.span.with_lo(inner_expr.span.hi())
815803
} else {
816-
span.shrink_to_hi()
804+
expr.span.shrink_to_hi()
817805
};
818806
sugg.push((span, suggestion));
819807
let msg = if let ty::Adt(def, _) = ty.kind()
@@ -933,7 +921,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
933921
if let Some(expr) = self.find_expr(borrow_span)
934922
&& let Some(ty) = typeck_results.node_type_opt(expr.hir_id)
935923
{
936-
self.suggest_cloning(&mut err, ty, expr, borrow_span);
924+
self.suggest_cloning(&mut err, ty, expr);
937925
}
938926
self.buffer_error(err);
939927
}

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)