aboutsummaryrefslogtreecommitdiff
path: root/xtask/src
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/src')
-rw-r--r--xtask/src/codegen.rs4
-rw-r--r--xtask/src/codegen/gen_assists_docs.rs2
-rw-r--r--xtask/src/codegen/gen_features.rs2
-rw-r--r--xtask/src/codegen/gen_syntax.rs15
4 files changed, 13 insertions, 10 deletions
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs
index 45b17bb48..1e7894617 100644
--- a/xtask/src/codegen.rs
+++ b/xtask/src/codegen.rs
@@ -77,12 +77,12 @@ fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> {
77 77
78const PREAMBLE: &str = "Generated file, do not edit by hand, see `xtask/src/codegen`"; 78const PREAMBLE: &str = "Generated file, do not edit by hand, see `xtask/src/codegen`";
79 79
80fn reformat(text: impl std::fmt::Display) -> Result<String> { 80fn reformat(text: &str) -> Result<String> {
81 let _e = pushenv("RUSTUP_TOOLCHAIN", "stable"); 81 let _e = pushenv("RUSTUP_TOOLCHAIN", "stable");
82 ensure_rustfmt()?; 82 ensure_rustfmt()?;
83 let stdout = run!( 83 let stdout = run!(
84 "rustfmt --config-path {} --config fn_single_line=true", project_root().join("rustfmt.toml").display(); 84 "rustfmt --config-path {} --config fn_single_line=true", project_root().join("rustfmt.toml").display();
85 <text.to_string().as_bytes() 85 <text.as_bytes()
86 )?; 86 )?;
87 Ok(format!("//! {}\n\n{}\n", PREAMBLE, stdout)) 87 Ok(format!("//! {}\n\n{}\n", PREAMBLE, stdout))
88} 88}
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#####"
134 134
135 buf.push_str(&test) 135 buf.push_str(&test)
136 } 136 }
137 let buf = reformat(buf)?; 137 let buf = reformat(&buf.to_string())?;
138 codegen::update(&project_root().join("crates/assists/src/tests/generated.rs"), &buf, mode) 138 codegen::update(&project_root().join("crates/assists/src/tests/generated.rs"), &buf, mode)
139} 139}
140 140
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<String> {
46 #(#definitions),* 46 #(#definitions),*
47 ]; 47 ];
48 }; 48 };
49 reformat(ts) 49 reformat(&ts.to_string())
50} 50}
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<String> {
61 } 61 }
62 }); 62 });
63 63
64 let pretty = reformat(quote! { 64 let pretty = reformat(
65 use crate::{SyntaxKind::{self, *}, SyntaxToken, ast::AstToken}; 65 &quote! {
66 #(#tokens)* 66 use crate::{SyntaxKind::{self, *}, SyntaxToken, ast::AstToken};
67 })? 67 #(#tokens)*
68 }
69 .to_string(),
70 )?
68 .replace("#[derive", "\n#[derive"); 71 .replace("#[derive", "\n#[derive");
69 Ok(pretty) 72 Ok(pretty)
70} 73}
@@ -261,7 +264,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> Result<String> {
261 } 264 }
262 } 265 }
263 266
264 let pretty = reformat(res)?; 267 let pretty = reformat(&res)?;
265 Ok(pretty) 268 Ok(pretty)
266} 269}
267 270
@@ -383,7 +386,7 @@ fn generate_syntax_kinds(grammar: KindsSrc<'_>) -> Result<String> {
383 } 386 }
384 }; 387 };
385 388
386 reformat(ast) 389 reformat(&ast.to_string())
387} 390}
388 391
389fn to_upper_snake_case(s: &str) -> String { 392fn to_upper_snake_case(s: &str) -> String {