@@ -466,7 +466,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
466
466
} else if self . suggest_hoisting_call_outside_loop ( err, expr) {
467
467
// The place where the the type moves would be misleading to suggest clone.
468
468
// #121466
469
- self . suggest_cloning ( err, ty, expr, move_span ) ;
469
+ self . suggest_cloning ( err, ty, expr) ;
470
470
}
471
471
}
472
472
if let Some ( pat) = finder. pat {
@@ -977,20 +977,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
977
977
can_suggest_clone
978
978
}
979
979
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 < ' _ > ) {
987
981
if let Some ( clone_trait_def) = self . infcx . tcx . lang_items ( ) . clone_trait ( )
988
982
&& self
989
983
. infcx
990
984
. type_implements_trait ( clone_trait_def, [ ty] , self . param_env )
991
985
. must_apply_modulo_regions ( )
992
986
{
993
- self . suggest_cloning_inner ( err, ty, expr, span ) ;
987
+ self . suggest_cloning_inner ( err, ty, expr) ;
994
988
}
995
989
}
996
990
@@ -1009,13 +1003,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1009
1003
}
1010
1004
}
1011
1005
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 < ' _ > ) {
1019
1007
let tcx = self . infcx . tcx ;
1020
1008
if let Some ( _) = self . clone_on_reference ( expr) {
1021
1009
// Avoid redundant clone suggestion already suggested in `explain_captures`.
@@ -1043,7 +1031,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1043
1031
// Account for `(*x)` to suggest `x.clone()`.
1044
1032
expr. span . with_lo ( inner_expr. span . hi ( ) )
1045
1033
} else {
1046
- span. shrink_to_hi ( )
1034
+ expr . span . shrink_to_hi ( )
1047
1035
} ;
1048
1036
sugg. push ( ( span, suggestion) ) ;
1049
1037
let msg = if let ty:: Adt ( def, _) = ty. kind ( )
@@ -1163,7 +1151,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1163
1151
if let Some ( expr) = self . find_expr ( borrow_span)
1164
1152
&& let Some ( ty) = typeck_results. node_type_opt ( expr. hir_id )
1165
1153
{
1166
- self . suggest_cloning ( & mut err, ty, expr, borrow_span ) ;
1154
+ self . suggest_cloning ( & mut err, ty, expr) ;
1167
1155
}
1168
1156
self . buffer_error ( err) ;
1169
1157
}
0 commit comments