From c7a079d32d33684d70b8a920eeaa10fc1d0a1fc5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 16 Oct 2020 19:47:47 +0200 Subject: Improve compile time a tiny bit --- xtask/src/codegen/gen_assists_docs.rs | 2 +- xtask/src/codegen/gen_features.rs | 2 +- xtask/src/codegen/gen_syntax.rs | 15 +++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'xtask/src/codegen') diff --git a/xtask/src/codegen/gen_assists_docs.rs b/xtask/src/codegen/gen_assists_docs.rs index f0ded8b87..ff307e2aa 100644 --- a/xtask/src/codegen/gen_assists_docs.rs +++ b/xtask/src/codegen/gen_assists_docs.rs @@ -134,7 +134,7 @@ r#####" buf.push_str(&test) } - let buf = reformat(buf)?; + let buf = reformat(&buf.to_string())?; codegen::update(&project_root().join("crates/assists/src/tests/generated.rs"), &buf, mode) } diff --git a/xtask/src/codegen/gen_features.rs b/xtask/src/codegen/gen_features.rs index 78268308b..b58c4a0c9 100644 --- a/xtask/src/codegen/gen_features.rs +++ b/xtask/src/codegen/gen_features.rs @@ -46,5 +46,5 @@ fn generate_descriptor(src_dir: PathBuf) -> Result { #(#definitions),* ]; }; - reformat(ts) + reformat(&ts.to_string()) } diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index 733493fef..02f4095ce 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs @@ -61,10 +61,13 @@ fn generate_tokens(grammar: &AstSrc) -> Result { } }); - let pretty = reformat(quote! { - use crate::{SyntaxKind::{self, *}, SyntaxToken, ast::AstToken}; - #(#tokens)* - })? + let pretty = reformat( + "e! { + use crate::{SyntaxKind::{self, *}, SyntaxToken, ast::AstToken}; + #(#tokens)* + } + .to_string(), + )? .replace("#[derive", "\n#[derive"); Ok(pretty) } @@ -261,7 +264,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> Result { } } - let pretty = reformat(res)?; + let pretty = reformat(&res)?; Ok(pretty) } @@ -383,7 +386,7 @@ fn generate_syntax_kinds(grammar: KindsSrc<'_>) -> Result { } }; - reformat(ast) + reformat(&ast.to_string()) } fn to_upper_snake_case(s: &str) -> String { -- cgit v1.2.3