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