]> git.lizzy.rs Git - rust.git/commitdiff
Lint against executable files in the root directory
authorMark Rousskov <mark.simulacrum@gmail.com>
Sat, 2 Jul 2022 02:12:29 +0000 (22:12 -0400)
committerMark Rousskov <mark.simulacrum@gmail.com>
Sat, 2 Jul 2022 02:12:29 +0000 (22:12 -0400)
This avoids accidental introduction (such as in #97488).

src/tools/tidy/src/bins.rs
src/tools/tidy/src/main.rs
suggest-blanket-impl-local-trait [deleted file]

index 503df53704793f3d212af4b36ca5929ed8670300..9615c4db6b4b51c4fc09fcdaa8f250539ee71415 100644 (file)
@@ -96,9 +96,25 @@ fn check_dir(dir: &Path) -> FilesystemSupport {
 
     #[cfg(unix)]
     pub fn check(path: &Path, bad: &mut bool) {
+        const ALLOWED: &[&str] = &["configure"];
+
         crate::walk_no_read(
             path,
-            &mut |path| crate::filter_dirs(path) || path.ends_with("src/etc"),
+            &mut |path| {
+                crate::filter_dirs(path)
+                    || path.ends_with("src/etc")
+                    // This is a list of directories that we almost certainly
+                    // don't need to walk. A future PR will likely want to
+                    // remove these in favor of crate::walk_no_read using git
+                    // ls-files to discover the paths we should check, which
+                    // would naturally ignore all of these directories. It's
+                    // also likely faster than walking the directory tree
+                    // directly (since git is just reading from a couple files
+                    // to produce the results).
+                    || path.ends_with("target")
+                    || path.ends_with("build")
+                    || path.ends_with(".git")
+            },
             &mut |entry| {
                 let file = entry.path();
                 let filename = file.file_name().unwrap().to_string_lossy();
@@ -110,6 +126,11 @@ pub fn check(path: &Path, bad: &mut bool) {
                 if t!(is_executable(&file), file) {
                     let rel_path = file.strip_prefix(path).unwrap();
                     let git_friendly_path = rel_path.to_str().unwrap().replace("\\", "/");
+
+                    if ALLOWED.contains(&git_friendly_path.as_str()) {
+                        return;
+                    }
+
                     let output = Command::new("git")
                         .arg("ls-files")
                         .arg(&git_friendly_path)
index d555f7c8e34fffbaefb5158ddc5e2b815bf77ea3..aa8d8b4f64d7d0ee3a4e4f5f524480809e8af69b 100644 (file)
@@ -78,13 +78,8 @@ macro_rules! check {
         check!(unit_tests, &compiler_path);
         check!(unit_tests, &library_path);
 
-        if bins::check_filesystem_support(
-            &[&src_path, &compiler_path, &library_path],
-            &output_directory,
-        ) {
-            check!(bins, &src_path);
-            check!(bins, &compiler_path);
-            check!(bins, &library_path);
+        if bins::check_filesystem_support(&[&root_path], &output_directory) {
+            check!(bins, &root_path);
         }
 
         check!(style, &src_path);
diff --git a/suggest-blanket-impl-local-trait b/suggest-blanket-impl-local-trait
deleted file mode 100755 (executable)
index 0a357e0..0000000
Binary files a/suggest-blanket-impl-local-trait and /dev/null differ