about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-03-13 06:10:12 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-04-11 16:41:41 +0000
commit259348cf7e6078e5e955ad53e14aeb9cc24c48ca (patch)
tree9a44d7670e04cb78131d05771e515e58221580b8
parent01b810e0523806445273e6aaeb26d1c77c66556c (diff)
downloadrust-259348cf7e6078e5e955ad53e14aeb9cc24c48ca.tar.gz
rust-259348cf7e6078e5e955ad53e14aeb9cc24c48ca.zip
Remove unnecessary argument from `suggest_cloning`
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs24
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/move_errors.rs6
2 files changed, 9 insertions, 21 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
index 3bc9f39d0f8..f978a8df66b 100644
--- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
@@ -476,7 +476,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
                 } else if self.suggest_hoisting_call_outside_loop(err, expr) {
                     // The place where the the type moves would be misleading to suggest clone.
                     // #121466
-                    self.suggest_cloning(err, ty, expr, move_span);
+                    self.suggest_cloning(err, ty, expr);
                 }
             }
             if let Some(pat) = finder.pat {
@@ -987,20 +987,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
         can_suggest_clone
     }
 
-    pub(crate) fn suggest_cloning(
-        &self,
-        err: &mut Diag<'_>,
-        ty: Ty<'tcx>,
-        expr: &hir::Expr<'_>,
-        span: Span,
-    ) {
+    pub(crate) fn suggest_cloning(&self, err: &mut Diag<'_>, ty: Ty<'tcx>, expr: &hir::Expr<'_>) {
         if let Some(clone_trait_def) = self.infcx.tcx.lang_items().clone_trait()
             && self
                 .infcx
                 .type_implements_trait(clone_trait_def, [ty], self.param_env)
                 .must_apply_modulo_regions()
         {
-            self.suggest_cloning_inner(err, ty, expr, span);
+            self.suggest_cloning_inner(err, ty, expr);
         }
     }
 
@@ -1019,13 +1013,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
         }
     }
 
-    fn suggest_cloning_inner(
-        &self,
-        err: &mut Diag<'_>,
-        ty: Ty<'tcx>,
-        expr: &hir::Expr<'_>,
-        span: Span,
-    ) {
+    fn suggest_cloning_inner(&self, err: &mut Diag<'_>, ty: Ty<'tcx>, expr: &hir::Expr<'_>) {
         let tcx = self.infcx.tcx;
         if let Some(_) = self.clone_on_reference(expr) {
             // Avoid redundant clone suggestion already suggested in `explain_captures`.
@@ -1053,7 +1041,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
             // Account for `(*x)` to suggest `x.clone()`.
             expr.span.with_lo(inner_expr.span.hi())
         } else {
-            span.shrink_to_hi()
+            expr.span.shrink_to_hi()
         };
         sugg.push((span, suggestion));
         let msg = if let ty::Adt(def, _) = ty.kind()
@@ -1173,7 +1161,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
         if let Some(expr) = self.find_expr(borrow_span)
             && let Some(ty) = typeck_results.node_type_opt(expr.hir_id)
         {
-            self.suggest_cloning(&mut err, ty, expr, borrow_span);
+            self.suggest_cloning(&mut err, ty, expr);
         }
         self.buffer_error(err);
     }
diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs
index 17e43a5b39c..31ef3519fff 100644
--- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs
@@ -445,7 +445,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
                     };
 
                     if let Some(expr) = self.find_expr(span) {
-                        self.suggest_cloning(err, place_ty, expr, span);
+                        self.suggest_cloning(err, place_ty, expr);
                     }
 
                     err.subdiagnostic(
@@ -480,7 +480,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
                 };
 
                 if let Some(expr) = self.find_expr(span) {
-                    self.suggest_cloning(err, place_ty, expr, span);
+                    self.suggest_cloning(err, place_ty, expr);
                 }
 
                 err.subdiagnostic(
@@ -593,7 +593,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
                 let place_desc = &format!("`{}`", self.local_names[*local].unwrap());
 
                 if let Some(expr) = self.find_expr(binding_span) {
-                    self.suggest_cloning(err, bind_to.ty, expr, binding_span);
+                    self.suggest_cloning(err, bind_to.ty, expr);
                 }
 
                 err.subdiagnostic(