@@ -476,7 +476,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
476
476
} else if self . suggest_hoisting_call_outside_loop ( err, expr) {
477
477
// The place where the the type moves would be misleading to suggest clone.
478
478
// #121466
479
- self . suggest_cloning ( err, ty, expr, move_span ) ;
479
+ self . suggest_cloning ( err, ty, expr) ;
480
480
}
481
481
}
482
482
if let Some ( pat) = finder. pat {
@@ -987,20 +987,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
987
987
can_suggest_clone
988
988
}
989
989
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 < ' _ > ) {
997
991
if let Some ( clone_trait_def) = self . infcx . tcx . lang_items ( ) . clone_trait ( )
998
992
&& self
999
993
. infcx
1000
994
. type_implements_trait ( clone_trait_def, [ ty] , self . param_env )
1001
995
. must_apply_modulo_regions ( )
1002
996
{
1003
- self . suggest_cloning_inner ( err, ty, expr, span ) ;
997
+ self . suggest_cloning_inner ( err, ty, expr) ;
1004
998
}
1005
999
}
1006
1000
@@ -1019,13 +1013,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1019
1013
}
1020
1014
}
1021
1015
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 < ' _ > ) {
1029
1017
let tcx = self . infcx . tcx ;
1030
1018
if let Some ( _) = self . clone_on_reference ( expr) {
1031
1019
// Avoid redundant clone suggestion already suggested in `explain_captures`.
@@ -1053,7 +1041,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1053
1041
// Account for `(*x)` to suggest `x.clone()`.
1054
1042
expr. span . with_lo ( inner_expr. span . hi ( ) )
1055
1043
} else {
1056
- span. shrink_to_hi ( )
1044
+ expr . span . shrink_to_hi ( )
1057
1045
} ;
1058
1046
sugg. push ( ( span, suggestion) ) ;
1059
1047
let msg = if let ty:: Adt ( def, _) = ty. kind ( )
@@ -1173,7 +1161,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1173
1161
if let Some ( expr) = self . find_expr ( borrow_span)
1174
1162
&& let Some ( ty) = typeck_results. node_type_opt ( expr. hir_id )
1175
1163
{
1176
- self . suggest_cloning ( & mut err, ty, expr, borrow_span ) ;
1164
+ self . suggest_cloning ( & mut err, ty, expr) ;
1177
1165
}
1178
1166
self . buffer_error ( err) ;
1179
1167
}
0 commit comments