diff options
Diffstat (limited to 'xtask/src/codegen.rs')
-rw-r--r-- | xtask/src/codegen.rs | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs index 158cfc2d6..efa638e06 100644 --- a/xtask/src/codegen.rs +++ b/xtask/src/codegen.rs | |||
@@ -9,15 +9,9 @@ mod gen_syntax; | |||
9 | mod gen_parser_tests; | 9 | mod gen_parser_tests; |
10 | mod gen_assists_docs; | 10 | mod gen_assists_docs; |
11 | 11 | ||
12 | use std::{ | 12 | use std::{fs, mem, path::Path}; |
13 | fs, | ||
14 | io::Write, | ||
15 | mem, | ||
16 | path::Path, | ||
17 | process::{Command, Stdio}, | ||
18 | }; | ||
19 | 13 | ||
20 | use crate::{project_root, Result}; | 14 | use crate::Result; |
21 | 15 | ||
22 | pub use self::{ | 16 | pub use self::{ |
23 | gen_assists_docs::generate_assists_docs, gen_parser_tests::generate_parser_tests, | 17 | gen_assists_docs::generate_assists_docs, gen_parser_tests::generate_parser_tests, |
@@ -62,20 +56,6 @@ fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> { | |||
62 | } | 56 | } |
63 | } | 57 | } |
64 | 58 | ||
65 | fn reformat(text: impl std::fmt::Display) -> Result<String> { | ||
66 | let mut rustfmt = Command::new("rustfmt") | ||
67 | .arg("--config-path") | ||
68 | .arg(project_root().join("rustfmt.toml")) | ||
69 | .stdin(Stdio::piped()) | ||
70 | .stdout(Stdio::piped()) | ||
71 | .spawn()?; | ||
72 | write!(rustfmt.stdin.take().unwrap(), "{}", text)?; | ||
73 | let output = rustfmt.wait_with_output()?; | ||
74 | let stdout = String::from_utf8(output.stdout)?; | ||
75 | let preamble = "Generated file, do not edit by hand, see `crate/ra_tools/src/codegen`"; | ||
76 | Ok(format!("//! {}\n\n{}", preamble, stdout)) | ||
77 | } | ||
78 | |||
79 | fn extract_comment_blocks(text: &str) -> Vec<Vec<String>> { | 59 | fn extract_comment_blocks(text: &str) -> Vec<Vec<String>> { |
80 | do_extract_comment_blocks(text, false) | 60 | do_extract_comment_blocks(text, false) |
81 | } | 61 | } |