Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# When updating, also update `rust_format::Config` in `node/build.rs`
indent_style = "Block"
imports_granularity = "Crate"
reorder_imports = true
12 changes: 10 additions & 2 deletions node/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{
};

use regex::Regex;
use rust_format::Formatter;
use rust_format::{Edition, Formatter};

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

let tmp_path = PathBuf::from(std::env::var("OUT_DIR").unwrap()).join("action_kind.rs");
fs::write(&tmp_path, contents)?;
rust_format::RustFmt::default()

// This should be same as `.rustfmt.toml`
let config = rust_format::Config::new_str()
.edition(Edition::Rust2021)
.option("indent_style", "Block")
.option("imports_granularity", "Crate")
.option("reorder_imports", "true");

rust_format::RustFmt::from_config(config)
.format_file(&tmp_path)
.expect("failed to format generated file");

Expand Down
Loading