@@ -411,58 +411,6 @@ impl<'tcx> LateLintPass<'tcx> for StrToString {
411
411
}
412
412
}
413
413
414
- declare_clippy_lint ! {
415
- /// ### What it does
416
- /// This lint checks for `.to_string()` method calls on values of type `String`.
417
- ///
418
- /// ### Why restrict this?
419
- /// The `to_string` method is also used on other types to convert them to a string.
420
- /// When called on a `String` it only clones the `String`, which can be more specifically
421
- /// expressed with `.clone()`.
422
- ///
423
- /// ### Example
424
- /// ```no_run
425
- /// let msg = String::from("Hello World");
426
- /// let _ = msg.to_string();
427
- /// ```
428
- /// Use instead:
429
- /// ```no_run
430
- /// let msg = String::from("Hello World");
431
- /// let _ = msg.clone();
432
- /// ```
433
- #[ clippy:: version = "pre 1.29.0" ]
434
- pub STRING_TO_STRING ,
435
- restriction,
436
- "using `to_string()` on a `String`, which should be `clone()`"
437
- }
438
-
439
- declare_lint_pass ! ( StringToString => [ STRING_TO_STRING ] ) ;
440
-
441
- impl < ' tcx > LateLintPass < ' tcx > for StringToString {
442
- fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & Expr < ' _ > ) {
443
- if expr. span . from_expansion ( ) {
444
- return ;
445
- }
446
-
447
- if let ExprKind :: MethodCall ( path, self_arg, [ ] , _) = & expr. kind
448
- && path. ident . name == sym:: to_string
449
- && let ty = cx. typeck_results ( ) . expr_ty ( self_arg)
450
- && is_type_lang_item ( cx, ty, LangItem :: String )
451
- {
452
- #[ expect( clippy:: collapsible_span_lint_calls, reason = "rust-clippy#7797" ) ]
453
- span_lint_and_then (
454
- cx,
455
- STRING_TO_STRING ,
456
- expr. span ,
457
- "`to_string()` called on a `String`" ,
458
- |diag| {
459
- diag. help ( "consider using `.clone()`" ) ;
460
- } ,
461
- ) ;
462
- }
463
- }
464
- }
465
-
466
414
declare_clippy_lint ! {
467
415
/// ### What it does
468
416
/// Warns about calling `str::trim` (or variants) before `str::split_whitespace`.
0 commit comments