1
1
use crate :: clippy_project_root;
2
2
use shell_escape:: escape;
3
3
use std:: ffi:: OsStr ;
4
- use std:: path:: Path ;
4
+ use std:: path:: { Path , PathBuf } ;
5
5
use std:: process:: { self , Command } ;
6
6
use std:: { fs, io} ;
7
7
use walkdir:: WalkDir ;
@@ -56,6 +56,7 @@ pub fn run(check: bool, verbose: bool) {
56
56
success &= cargo_fmt ( context, & project_root. join ( "rustc_tools_util" ) ) ?;
57
57
success &= cargo_fmt ( context, & project_root. join ( "lintcheck" ) ) ?;
58
58
59
+ let mut paths = Vec :: new ( ) ;
59
60
for entry in WalkDir :: new ( project_root. join ( "tests" ) ) {
60
61
let entry = entry?;
61
62
let path = entry. path ( ) ;
@@ -64,7 +65,11 @@ pub fn run(check: bool, verbose: bool) {
64
65
continue ;
65
66
}
66
67
67
- success &= rustfmt ( context, path) ?;
68
+ paths. push ( entry. into_path ( ) ) ;
69
+ }
70
+
71
+ for chunk in paths. chunks ( 250 ) {
72
+ success &= rustfmt ( context, chunk) ?;
68
73
}
69
74
70
75
Ok ( success)
@@ -185,14 +190,14 @@ fn rustfmt_test(context: &FmtContext) -> Result<(), CliError> {
185
190
}
186
191
}
187
192
188
- fn rustfmt ( context : & FmtContext , path : & Path ) -> Result < bool , CliError > {
189
- let mut args = vec ! [ path . as_os_str ( ) ] ;
193
+ fn rustfmt ( context : & FmtContext , paths : & [ PathBuf ] ) -> Result < bool , CliError > {
194
+ let mut args = Vec :: new ( ) ;
190
195
if context. check {
191
196
args. push ( "--check" . as_ref ( ) ) ;
192
197
}
198
+ args. extend ( paths. iter ( ) . map ( |path| path. as_os_str ( ) ) ) ;
199
+
193
200
let success = exec ( context, "rustfmt" , std:: env:: current_dir ( ) ?, & args) ?;
194
- if !success {
195
- eprintln ! ( "rustfmt failed on {}" , path. display( ) ) ;
196
- }
201
+
197
202
Ok ( success)
198
203
}
0 commit comments