Skip to content

Commit f4903b9

Browse files
committed
Update to have same formatting as rustfmt
1 parent 00c2268 commit f4903b9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.rustfmt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# When updating, also update `rust_format::Config` in `node/build.rs`
12
indent_style = "Block"
23
imports_granularity = "Crate"
34
reorder_imports = true

node/build.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::{
1010
};
1111

1212
use regex::Regex;
13-
use rust_format::Formatter;
13+
use rust_format::{Edition, Formatter};
1414

1515
fn visit_dirs(dir: &PathBuf, cb: &mut dyn FnMut(&DirEntry)) -> io::Result<()> {
1616
if dir.is_dir() {
@@ -355,7 +355,15 @@ fn main() -> Result<(), Box<dyn Error>> {
355355

356356
let tmp_path = PathBuf::from(std::env::var("OUT_DIR").unwrap()).join("action_kind.rs");
357357
fs::write(&tmp_path, contents)?;
358-
rust_format::RustFmt::default()
358+
359+
// This should be same as `.rustfmt.toml`
360+
let config = rust_format::Config::new_str()
361+
.edition(Edition::Rust2021)
362+
.option("indent_style", "Block")
363+
.option("imports_granularity", "Crate")
364+
.option("reorder_imports", "true");
365+
366+
rust_format::RustFmt::from_config(config)
359367
.format_file(&tmp_path)
360368
.expect("failed to format generated file");
361369

0 commit comments

Comments
 (0)