@@ -1306,37 +1306,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
1306
1306
// result of `foo(...)` won't help.
1307
1307
break ' outer;
1308
1308
}
1309
-
1310
- // We're suggesting `.clone()` on an borrowed value. See if the expression we have
1311
- // is an argument to a function or method call, and try to suggest cloning the
1312
- // *result* of the call, instead of the argument. This is closest to what people
1313
- // would actually be looking for in most cases, with maybe the exception of things
1314
- // like `fn(T) -> T`, but even then it is reasonable.
1315
- let typeck_results = self . infcx . tcx . typeck ( self . mir_def_id ( ) ) ;
1316
- let mut prev = expr;
1317
- while let hir:: Node :: Expr ( parent) = self . infcx . tcx . parent_hir_node ( prev. hir_id ) {
1318
- if let hir:: ExprKind :: Call ( ..) | hir:: ExprKind :: MethodCall ( ..) = parent. kind
1319
- && let Some ( call_ty) = typeck_results. node_type_opt ( parent. hir_id )
1320
- && let call_ty = call_ty. peel_refs ( )
1321
- && ( !call_ty
1322
- . walk ( )
1323
- . any ( |t| matches ! ( t. unpack( ) , ty:: GenericArgKind :: Lifetime ( _) ) )
1324
- || if let ty:: Alias ( ty:: Projection , _) = call_ty. kind ( ) {
1325
- // FIXME: this isn't quite right with lifetimes on assoc types,
1326
- // but ignore for now. We will only suggest cloning if
1327
- // `<Ty as Trait>::Assoc: Clone`, which should keep false positives
1328
- // down to a managable ammount.
1329
- true
1330
- } else {
1331
- false
1332
- } )
1333
- && self . implements_clone ( call_ty)
1334
- && self . suggest_cloning_inner ( err, call_ty, parent)
1335
- {
1336
- return ;
1337
- }
1338
- prev = parent;
1339
- }
1340
1309
}
1341
1310
}
1342
1311
let ty = ty. peel_refs ( ) ;
0 commit comments