Skip to content

Commit a2c6252

Browse files
committed
avoid some Symbol to String conversions
1 parent 1e033a9 commit a2c6252

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

clippy_lints/src/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessFormat {
8282
then {
8383
let is_new_string = match value.kind {
8484
ExprKind::Binary(..) => true,
85-
ExprKind::MethodCall(path, ..) => path.ident.name.as_str() == "to_string",
85+
ExprKind::MethodCall(path, ..) => path.ident.name == sym::to_string,
8686
_ => false,
8787
};
8888
let sugg = if format_args.format_string_span.contains(value.span) {

clippy_lints/src/inherent_to_string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for InherentToString {
9898
if_chain! {
9999
// Check if item is a method, called to_string and has a parameter 'self'
100100
if let ImplItemKind::Fn(ref signature, _) = impl_item.kind;
101-
if impl_item.ident.name.as_str() == "to_string";
101+
if impl_item.ident.name == sym::to_string;
102102
let decl = &signature.decl;
103103
if decl.implicit_self.has_implicit_self();
104104
if decl.inputs.len() == 1;

clippy_lints/src/methods/unnecessary_to_owned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,5 +427,5 @@ fn is_cow_into_owned(cx: &LateContext<'_>, method_name: Symbol, method_def_id: D
427427

428428
/// Returns true if the named method is `ToString::to_string`.
429429
fn is_to_string(cx: &LateContext<'_>, method_name: Symbol, method_def_id: DefId) -> bool {
430-
method_name.as_str() == "to_string" && is_diag_trait_item(cx, method_def_id, sym::ToString)
430+
method_name == sym::to_string && is_diag_trait_item(cx, method_def_id, sym::ToString)
431431
}

0 commit comments

Comments
 (0)