Skip to content

Commit 6f8211e

Browse files
committed
Remove unnecessary argument from suggest_cloning
1 parent 27a787f commit 6f8211e

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
@@ -466,7 +466,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
466466
} else if self.suggest_hoisting_call_outside_loop(err, expr) {
467467
// The place where the the type moves would be misleading to suggest clone.
468468
// #121466
469-
self.suggest_cloning(err, ty, expr, move_span);
469+
self.suggest_cloning(err, ty, expr);
470470
}
471471
}
472472
if let Some(pat) = finder.pat {
@@ -977,20 +977,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
977977
can_suggest_clone
978978
}
979979

980-
pub(crate) fn suggest_cloning(
981-
&self,
982-
err: &mut Diag<'_>,
983-
ty: Ty<'tcx>,
984-
expr: &hir::Expr<'_>,
985-
span: Span,
986-
) {
980+
pub(crate) fn suggest_cloning(&self, err: &mut Diag<'_>, ty: Ty<'tcx>, expr: &hir::Expr<'_>) {
987981
if let Some(clone_trait_def) = self.infcx.tcx.lang_items().clone_trait()
988982
&& self
989983
.infcx
990984
.type_implements_trait(clone_trait_def, [ty], self.param_env)
991985
.must_apply_modulo_regions()
992986
{
993-
self.suggest_cloning_inner(err, ty, expr, span);
987+
self.suggest_cloning_inner(err, ty, expr);
994988
}
995989
}
996990

@@ -1009,13 +1003,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10091003
}
10101004
}
10111005

1012-
fn suggest_cloning_inner(
1013-
&self,
1014-
err: &mut Diag<'_>,
1015-
ty: Ty<'tcx>,
1016-
expr: &hir::Expr<'_>,
1017-
span: Span,
1018-
) {
1006+
fn suggest_cloning_inner(&self, err: &mut Diag<'_>, ty: Ty<'tcx>, expr: &hir::Expr<'_>) {
10191007
let tcx = self.infcx.tcx;
10201008
if let Some(_) = self.clone_on_reference(expr) {
10211009
// Avoid redundant clone suggestion already suggested in `explain_captures`.
@@ -1043,7 +1031,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10431031
// Account for `(*x)` to suggest `x.clone()`.
10441032
expr.span.with_lo(inner_expr.span.hi())
10451033
} else {
1046-
span.shrink_to_hi()
1034+
expr.span.shrink_to_hi()
10471035
};
10481036
sugg.push((span, suggestion));
10491037
let msg = if let ty::Adt(def, _) = ty.kind()
@@ -1163,7 +1151,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11631151
if let Some(expr) = self.find_expr(borrow_span)
11641152
&& let Some(ty) = typeck_results.node_type_opt(expr.hir_id)
11651153
{
1166-
self.suggest_cloning(&mut err, ty, expr, borrow_span);
1154+
self.suggest_cloning(&mut err, ty, expr);
11671155
}
11681156
self.buffer_error(err);
11691157
}

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)