about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorjoboet <jonasboettiger@icloud.com>2023-03-18 20:09:13 +0100
committerjoboet <jonasboettiger@icloud.com>2023-03-19 12:53:04 +0100
commit500ad266199ee2ea30ff022e3247e8a11979fec3 (patch)
tree472ab6f670efa7c81977944ebe8c56bf8bd2ab45 /src/tools
parentab9bb3ea368b2412531a3e8c07ba73d1dd690134 (diff)
downloadrust-500ad266199ee2ea30ff022e3247e8a11979fec3.tar.gz
rust-500ad266199ee2ea30ff022e3247e8a11979fec3.zip
tidy: ignore files in .gitignore in mir opt check
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/tidy/src/mir_opt_tests.rs41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/tools/tidy/src/mir_opt_tests.rs b/src/tools/tidy/src/mir_opt_tests.rs
index 2a9dcac2e8d..b316e9e9009 100644
--- a/src/tools/tidy/src/mir_opt_tests.rs
+++ b/src/tools/tidy/src/mir_opt_tests.rs
@@ -3,19 +3,24 @@
 use std::collections::HashSet;
 use std::path::{Path, PathBuf};
 
+use crate::walk::walk_no_read;
+
 fn check_unused_files(path: &Path, bless: bool, bad: &mut bool) {
     let mut rs_files = Vec::<PathBuf>::new();
     let mut output_files = HashSet::<PathBuf>::new();
-    let files = walkdir::WalkDir::new(&path.join("mir-opt")).into_iter();
 
-    for file in files.filter_map(Result::ok).filter(|e| e.file_type().is_file()) {
-        let filepath = file.path();
-        if filepath.extension() == Some("rs".as_ref()) {
-            rs_files.push(filepath.to_owned());
-        } else {
-            output_files.insert(filepath.to_owned());
-        }
-    }
+    walk_no_read(
+        &[&path.join("mir-opt")],
+        |path| path.file_name() == Some("README.md".as_ref()),
+        &mut |file| {
+            let filepath = file.path();
+            if filepath.extension() == Some("rs".as_ref()) {
+                rs_files.push(filepath.to_owned());
+            } else {
+                output_files.insert(filepath.to_owned());
+            }
+        },
+    );
 
     for file in rs_files {
         for bw in [32, 64] {
@@ -26,16 +31,14 @@ fn check_unused_files(path: &Path, bless: bool, bad: &mut bool) {
     }
 
     for extra in output_files {
-        if extra.file_name() != Some("README.md".as_ref()) {
-            if !bless {
-                tidy_error!(
-                    bad,
-                    "the following output file is not associated with any mir-opt test, you can remove it: {}",
-                    extra.display()
-                );
-            } else {
-                let _ = std::fs::remove_file(extra);
-            }
+        if !bless {
+            tidy_error!(
+                bad,
+                "the following output file is not associated with any mir-opt test, you can remove it: {}",
+                extra.display()
+            );
+        } else {
+            let _ = std::fs::remove_file(extra);
         }
     }
 }