@@ -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 }
0 commit comments