diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-01-10 10:24:29 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-01-10 10:24:29 +0000 |
commit | 046e46672b47d0530afc7cbc81f099ee0c15ac70 (patch) | |
tree | 23071b83610a2d0b61ffcb606f83c3e95a2809bd /xtask/src/codegen.rs | |
parent | b77a7e29a5b345a5dcdf427a0b332630147bcd5b (diff) | |
parent | fd394ff424a8abde35f24643dfabbd5bd3f2f43c (diff) |
Merge #2782
2782: Use correct rustfmt for codegen r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
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 | } |