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