diff options
| author | Samuel Moelius <sam@moeli.us> | 2025-03-20 14:01:04 -0400 |
|---|---|---|
| committer | Samuel Moelius <sam@moeli.us> | 2025-05-19 19:29:06 -0400 |
| commit | 8e5b0cdae1aaffcee5455852cb0eec0c6b56b17f (patch) | |
| tree | 08c7548dd2dca8e268771696c344c681b57d0759 /clippy_lints/src | |
| parent | 8a9adba8525e7bf40ca5f3b08d359742173f6fa7 (diff) | |
Account for changes from issue 14396
Diffstat (limited to 'clippy_lints/src')
| -rw-r--r-- | clippy_lints/src/strings.rs | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index 73a9fe71e00..9fcef84eeb3 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -494,21 +494,9 @@ impl<'tcx> LateLintPass<'tcx> for StringToString { if path.ident.name == sym::to_string && let ty = cx.typeck_results().expr_ty(self_arg) && is_type_lang_item(cx, ty.peel_refs(), LangItem::String) + && let Some(parent_span) = is_called_from_map_like(cx, expr) { - if let Some(parent_span) = is_called_from_map_like(cx, expr) { - suggest_cloned_string_to_string(cx, parent_span); - } else { - #[expect(clippy::collapsible_span_lint_calls, reason = "rust-clippy#7797")] - span_lint_and_then( - cx, - STRING_TO_STRING, - expr.span, - "`to_string()` called on a `String`", - |diag| { - diag.help("consider using `.clone()`"); - }, - ); - } + suggest_cloned_string_to_string(cx, parent_span); } }, ExprKind::Path(QPath::TypeRelative(ty, segment)) => { |
