Rollup merge of #99342 - TaKO8Ki:avoid-symbol-to-string-conversions, r=compiler-errors

Avoid some `Symbol` to `String` conversions

This patch removes some Symbol to String conversions.
This commit is contained in:
Matthias Krüger 2022-07-16 22:30:56 +02:00 committed by GitHub
commit 2300da4412
3 changed files with 3 additions and 3 deletions

View file

@ -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) {

View file

@ -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;

View file

@ -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)
}