3
3
use std:: collections:: HashSet ;
4
4
use std:: path:: { Path , PathBuf } ;
5
5
6
+ use crate :: walk:: walk_no_read;
7
+
6
8
fn check_unused_files ( path : & Path , bless : bool , bad : & mut bool ) {
7
9
let mut rs_files = Vec :: < PathBuf > :: new ( ) ;
8
10
let mut output_files = HashSet :: < PathBuf > :: new ( ) ;
9
- let files = walkdir:: WalkDir :: new ( & path. join ( "mir-opt" ) ) . into_iter ( ) ;
10
11
11
- for file in files. filter_map ( Result :: ok) . filter ( |e| e. file_type ( ) . is_file ( ) ) {
12
- let filepath = file. path ( ) ;
13
- if filepath. extension ( ) == Some ( "rs" . as_ref ( ) ) {
14
- rs_files. push ( filepath. to_owned ( ) ) ;
15
- } else {
16
- output_files. insert ( filepath. to_owned ( ) ) ;
17
- }
18
- }
12
+ walk_no_read (
13
+ & [ & path. join ( "mir-opt" ) ] ,
14
+ |path| path. file_name ( ) == Some ( "README.md" . as_ref ( ) ) ,
15
+ & mut |file| {
16
+ let filepath = file. path ( ) ;
17
+ if filepath. extension ( ) == Some ( "rs" . as_ref ( ) ) {
18
+ rs_files. push ( filepath. to_owned ( ) ) ;
19
+ } else {
20
+ output_files. insert ( filepath. to_owned ( ) ) ;
21
+ }
22
+ } ,
23
+ ) ;
19
24
20
25
for file in rs_files {
21
26
for bw in [ 32 , 64 ] {
@@ -26,16 +31,14 @@ fn check_unused_files(path: &Path, bless: bool, bad: &mut bool) {
26
31
}
27
32
28
33
for extra in output_files {
29
- if extra. file_name ( ) != Some ( "README.md" . as_ref ( ) ) {
30
- if !bless {
31
- tidy_error ! (
32
- bad,
33
- "the following output file is not associated with any mir-opt test, you can remove it: {}" ,
34
- extra. display( )
35
- ) ;
36
- } else {
37
- let _ = std:: fs:: remove_file ( extra) ;
38
- }
34
+ if !bless {
35
+ tidy_error ! (
36
+ bad,
37
+ "the following output file is not associated with any mir-opt test, you can remove it: {}" ,
38
+ extra. display( )
39
+ ) ;
40
+ } else {
41
+ let _ = std:: fs:: remove_file ( extra) ;
39
42
}
40
43
}
41
44
}
0 commit comments