half-build-times
This commit is contained in:
1 parent
f69b84bf34
commit
3d8d8a1b6f
24 files changed
+489
-456
No files matched your search
@@ -5,6 +5,8 @@
|
||||
use proc_macro2::LineColumn;
|
||||
use syn::{Block, Expr, File, Item, Macro, Stmt};
|
||||
|
||||
use crate::expr;
|
||||
|
||||
type CollectedMacro<'a> = &'a Macro;
|
||||
|
||||
pub fn collect_from_file<'a>(file: &'a File, macros: &mut Vec<CollectedMacro<'a>>) {
|
||||
@@ -42,7 +44,7 @@ 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
|
||||
Item::Macro2(_)
|
||||
Item::Macro(_)
|
||||
| Item::Enum(_)
|
||||
| Item::ExternCrate(_)
|
||||
| Item::ForeignMod(_)
|
||||
@@ -61,11 +63,18 @@ pub fn collect_from_block<'a>(block: &'a Block, macros: &mut Vec<CollectedMacro<
|
||||
match stmt {
|
||||
Stmt::Item(item) => collect_from_item(item, macros),
|
||||
Stmt::Local(local) => {
|
||||
if let Some((_eq, init)) = &local.init {
|
||||
collect_from_expr(init, macros);
|
||||
if let Some(init) = &local.init {
|
||||
collect_from_expr(&init.expr, macros);
|
||||
}
|
||||
}
|
||||
Stmt::Expr(expr, _) => collect_from_expr(expr, macros),
|
||||
Stmt::Macro(mac) => {
|
||||
if mac.mac.path.segments[0].ident == "rsx"
|
||||
|| mac.mac.path.segments[0].ident == "render"
|
||||
{
|
||||
macros.push(&mac.mac);
|
||||
}
|
||||
}
|
||||
Stmt::Expr(exp) | Stmt::Semi(exp, _) => collect_from_expr(exp, macros),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,10 +156,9 @@ pub fn collect_from_expr<'a>(expr: &'a Expr, macros: &mut Vec<CollectedMacro<'a>
|
||||
|
||||
// don't both formatting these for now
|
||||
Expr::Array(_)
|
||||
| Expr::AssignOp(_)
|
||||
| Expr::Assign(_)
|
||||
| Expr::Await(_)
|
||||
| Expr::Binary(_)
|
||||
| Expr::Box(_)
|
||||
| Expr::Break(_)
|
||||
| Expr::Cast(_)
|
||||
| Expr::Continue(_)
|
||||
@@ -167,7 +175,6 @@ pub fn collect_from_expr<'a>(expr: &'a Expr, macros: &mut Vec<CollectedMacro<'a>
|
||||
| Expr::Try(_)
|
||||
| Expr::TryBlock(_)
|
||||
| Expr::Tuple(_)
|
||||
| Expr::Type(_)
|
||||
| Expr::Unary(_)
|
||||
| Expr::Verbatim(_) => {}
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ impl Writer<'_> {
|
||||
)?;
|
||||
}
|
||||
ContentField::OnHandlerRaw(exp) => {
|
||||
let out = prettyplease::unparse_expr(exp);
|
||||
let out = prettyplease::unparse(exp);
|
||||
let mut lines = out.split('\n').peekable();
|
||||
let first = lines.next().unwrap();
|
||||
write!(self.out, "{name}: {first}")?;
|
||||
|
||||
@@ -88,9 +88,9 @@ pub fn fmt_file(contents: &str) -> Vec<FormattedBlock> {
|
||||
}
|
||||
|
||||
let span = match item.delimiter {
|
||||
MacroDelimiter::Paren(b) => b.span,
|
||||
MacroDelimiter::Brace(b) => b.span,
|
||||
MacroDelimiter::Bracket(b) => b.span,
|
||||
MacroDelimiter::Paren(b) => b.span.open(),
|
||||
MacroDelimiter::Brace(b) => b.span.open(),
|
||||
MacroDelimiter::Bracket(b) => b.span.open(),
|
||||
};
|
||||
|
||||
let mut formatted = String::new();
|
||||
|
||||
@@ -197,7 +197,7 @@ impl<'a> Writer<'a> {
|
||||
self.out,
|
||||
"for {} in {} {{",
|
||||
forloop.pat.clone().into_token_stream(),
|
||||
prettyplease::unparse_expr(&forloop.expr)
|
||||
prettyplease::unparse_expr(&*forloop.expr)
|
||||
)?;
|
||||
|
||||
if forloop.body.is_empty() {
|
||||
|
||||
Reference in new issue
Block a user