File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change
1
+ # When updating, also update `rust_format::Config` in `node/build.rs`
1
2
indent_style = " Block"
2
3
imports_granularity = " Crate"
3
4
reorder_imports = true
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ use std::{
10
10
} ;
11
11
12
12
use regex:: Regex ;
13
- use rust_format:: Formatter ;
13
+ use rust_format:: { Edition , Formatter } ;
14
14
15
15
fn visit_dirs ( dir : & PathBuf , cb : & mut dyn FnMut ( & DirEntry ) ) -> io:: Result < ( ) > {
16
16
if dir. is_dir ( ) {
@@ -355,7 +355,15 @@ fn main() -> Result<(), Box<dyn Error>> {
355
355
356
356
let tmp_path = PathBuf :: from ( std:: env:: var ( "OUT_DIR" ) . unwrap ( ) ) . join ( "action_kind.rs" ) ;
357
357
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)
359
367
. format_file ( & tmp_path)
360
368
. expect ( "failed to format generated file" ) ;
361
369
You can’t perform that action at this time.
0 commit comments