@@ -464,7 +464,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
464
464
{
465
465
// We already suggest cloning for these cases in `explain_captures`.
466
466
} else {
467
- self . suggest_cloning ( err, ty, expr, move_span ) ;
467
+ self . suggest_cloning ( err, ty, expr) ;
468
468
}
469
469
}
470
470
if let Some ( pat) = finder. pat {
@@ -747,20 +747,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
747
747
true
748
748
}
749
749
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 < ' _ > ) {
757
751
if let Some ( clone_trait_def) = self . infcx . tcx . lang_items ( ) . clone_trait ( )
758
752
&& self
759
753
. infcx
760
754
. type_implements_trait ( clone_trait_def, [ ty] , self . param_env )
761
755
. must_apply_modulo_regions ( )
762
756
{
763
- self . suggest_cloning_inner ( err, ty, expr, span ) ;
757
+ self . suggest_cloning_inner ( err, ty, expr) ;
764
758
}
765
759
}
766
760
@@ -779,13 +773,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
779
773
}
780
774
}
781
775
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 < ' _ > ) {
789
777
let tcx = self . infcx . tcx ;
790
778
if let Some ( _) = self . clone_on_reference ( expr) {
791
779
// Avoid redundant clone suggestion already suggested in `explain_captures`.
@@ -813,7 +801,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
813
801
// Account for `(*x)` to suggest `x.clone()`.
814
802
expr. span . with_lo ( inner_expr. span . hi ( ) )
815
803
} else {
816
- span. shrink_to_hi ( )
804
+ expr . span . shrink_to_hi ( )
817
805
} ;
818
806
sugg. push ( ( span, suggestion) ) ;
819
807
let msg = if let ty:: Adt ( def, _) = ty. kind ( )
@@ -933,7 +921,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
933
921
if let Some ( expr) = self . find_expr ( borrow_span)
934
922
&& let Some ( ty) = typeck_results. node_type_opt ( expr. hir_id )
935
923
{
936
- self . suggest_cloning ( & mut err, ty, expr, borrow_span ) ;
924
+ self . suggest_cloning ( & mut err, ty, expr) ;
937
925
}
938
926
self . buffer_error ( err) ;
939
927
}
0 commit comments