]> git.proxmox.com Git - rustc.git/blobdiff - src/tools/tidy/src/debug_artifacts.rs
New upstream version 1.70.0+dfsg1
[rustc.git] / src / tools / tidy / src / debug_artifacts.rs
index 0dd9c1e160ceef3d3825aca2ecec36f4d16864b4..582014d5059d1550c3d36b63a312c7386130d557 100644 (file)
@@ -1,22 +1,26 @@
 //! Tidy check to prevent creation of unnecessary debug artifacts while running tests.
 
-use crate::walk::{filter_dirs, walk};
+use crate::walk::{filter_dirs, filter_not_rust, walk};
 use std::path::Path;
 
 const GRAPHVIZ_POSTFLOW_MSG: &str = "`borrowck_graphviz_postflow` attribute in test";
 
 pub fn check(test_dir: &Path, bad: &mut bool) {
-    walk(test_dir, &mut filter_dirs, &mut |entry, contents| {
-        let filename = entry.path();
-        let is_rust = filename.extension().map_or(false, |ext| ext == "rs");
-        if !is_rust {
-            return;
-        }
-
-        for (i, line) in contents.lines().enumerate() {
-            if line.contains("borrowck_graphviz_postflow") {
-                tidy_error!(bad, "{}:{}: {}", filename.display(), i + 1, GRAPHVIZ_POSTFLOW_MSG);
+    walk(
+        test_dir,
+        |path, _is_dir| filter_dirs(path) || filter_not_rust(path),
+        &mut |entry, contents| {
+            for (i, line) in contents.lines().enumerate() {
+                if line.contains("borrowck_graphviz_postflow") {
+                    tidy_error!(
+                        bad,
+                        "{}:{}: {}",
+                        entry.path().display(),
+                        i + 1,
+                        GRAPHVIZ_POSTFLOW_MSG
+                    );
+                }
             }
-        }
-    });
+        },
+    );
 }