about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorJakob Degen <jakob.e.degen@gmail.com>2022-11-03 23:19:59 -0700
committerJakob Degen <jakob.e.degen@gmail.com>2022-11-03 23:19:59 -0700
commitd98cce19b28f37a457db3d27ff5ade33f32bcaa4 (patch)
tree374dbebcf0f995c90cf173e0fa0cd8ef22a9e9df /src/tools
parent6718ea1cff98da785c10079cac1c1ecc30c12d52 (diff)
downloadrust-d98cce19b28f37a457db3d27ff5ade33f32bcaa4.tar.gz
rust-d98cce19b28f37a457db3d27ff5ade33f32bcaa4.zip
Make mir opt unused file check blessable
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/tidy/src/mir_opt_tests.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/tools/tidy/src/mir_opt_tests.rs b/src/tools/tidy/src/mir_opt_tests.rs
index ea24fa45138..018573284ea 100644
--- a/src/tools/tidy/src/mir_opt_tests.rs
+++ b/src/tools/tidy/src/mir_opt_tests.rs
@@ -3,7 +3,7 @@
 use std::collections::HashSet;
 use std::path::{Path, PathBuf};
 
-fn check_unused_files(path: &Path, bad: &mut bool) {
+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("test/mir-opt")).into_iter();
@@ -27,11 +27,15 @@ fn check_unused_files(path: &Path, bad: &mut bool) {
 
     for extra in output_files {
         if extra.file_name() != Some("README.md".as_ref()) {
-            tidy_error!(
-                bad,
-                "the following output file is not associated with any mir-opt test, you can remove it: {}",
-                extra.display()
-            );
+            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);
+            }
         }
     }
 }
@@ -65,6 +69,6 @@ fn check_dash_files(path: &Path, bless: bool, bad: &mut bool) {
 }
 
 pub fn check(path: &Path, bless: bool, bad: &mut bool) {
-    check_unused_files(path, bad);
+    check_unused_files(path, bless, bad);
     check_dash_files(path, bless, bad);
 }