Remove unnecessary sigils around Ident::as_str() calls.

This commit is contained in:
Nicholas Nethercote 2021-12-15 16:13:11 +11:00
parent 3bb5f81d8d
commit 122e1c3802
3 changed files with 7 additions and 7 deletions

View File

@ -616,10 +616,10 @@ impl<'a> FmtVisitor<'a> {
(TyAlias(lty), TyAlias(rty))
if both_type(&lty.ty, &rty.ty) || both_opaque(&lty.ty, &rty.ty) =>
{
a.ident.as_str().cmp(&b.ident.as_str())
a.ident.as_str().cmp(b.ident.as_str())
}
(Const(..), Const(..)) | (MacCall(..), MacCall(..)) => {
a.ident.as_str().cmp(&b.ident.as_str())
a.ident.as_str().cmp(b.ident.as_str())
}
(Fn(..), Fn(..)) => a.span.lo().cmp(&b.span.lo()),
(TyAlias(ty), _) if is_type(&ty.ty) => Ordering::Less,
@ -1029,7 +1029,7 @@ pub(crate) fn format_trait(
if !bounds.is_empty() {
let ident_hi = context
.snippet_provider
.span_after(item.span, &item.ident.as_str());
.span_after(item.span, item.ident.as_str());
let bound_hi = bounds.last().unwrap().span().hi();
let snippet = context.snippet(mk_sp(ident_hi, bound_hi));
if contains_comment(snippet) {

View File

@ -467,10 +467,10 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
if let DirectoryOwnership::Owned { relative } = &mut self.directory.ownership {
if let Some(ident) = relative.take() {
// remove the relative offset
self.directory.path.push(&*ident.as_str());
self.directory.path.push(ident.as_str());
}
}
self.directory.path.push(&*id.as_str());
self.directory.path.push(id.as_str());
}
}

View File

@ -26,7 +26,7 @@ use crate::visitor::FmtVisitor;
fn compare_items(a: &ast::Item, b: &ast::Item) -> Ordering {
match (&a.kind, &b.kind) {
(&ast::ItemKind::Mod(..), &ast::ItemKind::Mod(..)) => {
a.ident.as_str().cmp(&b.ident.as_str())
a.ident.as_str().cmp(b.ident.as_str())
}
(&ast::ItemKind::ExternCrate(ref a_name), &ast::ItemKind::ExternCrate(ref b_name)) => {
// `extern crate foo as bar;`
@ -44,7 +44,7 @@ fn compare_items(a: &ast::Item, b: &ast::Item) -> Ordering {
(Some(..), None) => Ordering::Greater,
(None, Some(..)) => Ordering::Less,
(None, None) => Ordering::Equal,
(Some(..), Some(..)) => a.ident.as_str().cmp(&b.ident.as_str()),
(Some(..), Some(..)) => a.ident.as_str().cmp(b.ident.as_str()),
}
}
_ => unreachable!(),