diff options
| author | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-07-17 04:09:20 +0900 |
|---|---|---|
| committer | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-07-17 04:09:20 +0900 |
| commit | a2c6252cd33d125a670be991dd17a11745bfbe72 (patch) | |
| tree | 2104e060df76b69335bbcac6be235b023e2a87f6 | |
| parent | 1e033a9818b305b9b22e26e18c81729099aa9c19 (diff) | |
| download | rust-a2c6252cd33d125a670be991dd17a11745bfbe72.tar.gz rust-a2c6252cd33d125a670be991dd17a11745bfbe72.zip | |
avoid some `Symbol` to `String` conversions
| -rw-r--r-- | clippy_lints/src/format.rs | 2 | ||||
| -rw-r--r-- | clippy_lints/src/inherent_to_string.rs | 2 | ||||
| -rw-r--r-- | clippy_lints/src/methods/unnecessary_to_owned.rs | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/clippy_lints/src/format.rs b/clippy_lints/src/format.rs index 3084c70589f..0aa085fc71b 100644 --- a/clippy_lints/src/format.rs +++ b/clippy_lints/src/format.rs @@ -82,7 +82,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessFormat { then { let is_new_string = match value.kind { ExprKind::Binary(..) => true, - ExprKind::MethodCall(path, ..) => path.ident.name.as_str() == "to_string", + ExprKind::MethodCall(path, ..) => path.ident.name == sym::to_string, _ => false, }; let sugg = if format_args.format_string_span.contains(value.span) { diff --git a/clippy_lints/src/inherent_to_string.rs b/clippy_lints/src/inherent_to_string.rs index 39f68a8a1b4..694f646c707 100644 --- a/clippy_lints/src/inherent_to_string.rs +++ b/clippy_lints/src/inherent_to_string.rs @@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for InherentToString { if_chain! { // Check if item is a method, called to_string and has a parameter 'self' if let ImplItemKind::Fn(ref signature, _) = impl_item.kind; - if impl_item.ident.name.as_str() == "to_string"; + if impl_item.ident.name == sym::to_string; let decl = &signature.decl; if decl.implicit_self.has_implicit_self(); if decl.inputs.len() == 1; diff --git a/clippy_lints/src/methods/unnecessary_to_owned.rs b/clippy_lints/src/methods/unnecessary_to_owned.rs index b4c6bfb31ed..b3276f1394e 100644 --- a/clippy_lints/src/methods/unnecessary_to_owned.rs +++ b/clippy_lints/src/methods/unnecessary_to_owned.rs @@ -427,5 +427,5 @@ fn is_cow_into_owned(cx: &LateContext<'_>, method_name: Symbol, method_def_id: D /// Returns true if the named method is `ToString::to_string`. fn is_to_string(cx: &LateContext<'_>, method_name: Symbol, method_def_id: DefId) -> bool { - method_name.as_str() == "to_string" && is_diag_trait_item(cx, method_def_id, sym::ToString) + method_name == sym::to_string && is_diag_trait_item(cx, method_def_id, sym::ToString) } |
