Skip to content

Commit

Permalink
avoid some Symbol to String conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
TaKO8Ki committed Jul 16, 2022
1 parent 1e033a9 commit a2c6252
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/inherent_to_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/unnecessary_to_owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit a2c6252

Please sign in to comment.