chore: fewer clones in autoformat infrastructure

This commit is contained in:
Jonathan Kelley committed 2023-01-13 16:58:53 -08:00
1 parent ea032eeb8e
commit 9f9bcd747a
1 file changed
+8 -11
+8 -11
View File
@@ -19,10 +19,9 @@ pub fn collect_from_item<'a>(item: &'a Item, macros: &mut Vec<CollectedMacro<'a>
// Ignore macros if they're not rsx or render // Ignore macros if they're not rsx or render
Item::Macro(macro_) => { Item::Macro(macro_) => {
let to_str = macro_.mac.path.segments[0].ident.to_string(); if macro_.mac.path.segments[0].ident == "rsx"
// let Some(ident) = &macro_.ident else { return }; || macro_.mac.path.segments[0].ident == "render"
// let to_str = ident.to_string(); {
if to_str == "rsx" || to_str == "render" {
macros.push(&macro_.mac); macros.push(&macro_.mac);
} }
} }
@@ -43,10 +42,8 @@ pub fn collect_from_item<'a>(item: &'a Item, macros: &mut Vec<CollectedMacro<'a>
} }
// None of these we can really do anything with at the item level // None of these we can really do anything with at the item level
Item::Macro2(m) => { Item::Macro2(_)
panic!("Macro2: {:?}", m); | Item::Enum(_)
}
Item::Enum(_)
| Item::ExternCrate(_) | Item::ExternCrate(_)
| Item::ForeignMod(_) | Item::ForeignMod(_)
| Item::TraitAlias(_) | Item::TraitAlias(_)
@@ -77,9 +74,9 @@ pub fn collect_from_expr<'a>(expr: &'a Expr, macros: &mut Vec<CollectedMacro<'a>
// collect an expr from the exprs, descending into blocks // collect an expr from the exprs, descending into blocks
match expr { match expr {
Expr::Macro(macro_) => { Expr::Macro(macro_) => {
let macro_name = macro_.mac.path.segments[0].ident.to_string(); if macro_.mac.path.segments[0].ident == "rsx"
|| macro_.mac.path.segments[0].ident == "render"
if macro_name == "rsx" { {
macros.push(&macro_.mac); macros.push(&macro_.mac);
} }
} }