mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 06:28:42 +00:00
avoid some Symbol
to String
conversions
This commit is contained in:
parent
1e033a9818
commit
a2c6252cd3
3 changed files with 3 additions and 3 deletions
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue