diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-07-01 22:12:29 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2022-07-01 22:12:29 -0400 |
| commit | 45b87fb75ce2ed9cf3915f8a46e7c77d1540d010 (patch) | |
| tree | 9baf69bb328eb154852507832b5fe7aab8f5197a | |
| parent | 9a6fa4f118d88991458549464d960aa1e495541b (diff) | |
| download | rust-45b87fb75ce2ed9cf3915f8a46e7c77d1540d010.tar.gz rust-45b87fb75ce2ed9cf3915f8a46e7c77d1540d010.zip | |
Lint against executable files in the root directory
This avoids accidental introduction (such as in #97488).
| -rw-r--r-- | src/tools/tidy/src/bins.rs | 23 | ||||
| -rw-r--r-- | src/tools/tidy/src/main.rs | 9 | ||||
| -rwxr-xr-x | suggest-blanket-impl-local-trait | bin | 479160 -> 0 bytes |
3 files changed, 24 insertions, 8 deletions
diff --git a/src/tools/tidy/src/bins.rs b/src/tools/tidy/src/bins.rs index 503df537047..9615c4db6b4 100644 --- a/src/tools/tidy/src/bins.rs +++ b/src/tools/tidy/src/bins.rs @@ -96,9 +96,25 @@ mod os_impl { #[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 @@ mod os_impl { 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) diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index d555f7c8e34..aa8d8b4f64d 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -78,13 +78,8 @@ fn main() { 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 index 0a357e006c3..00000000000 --- a/suggest-blanket-impl-local-trait +++ /dev/null Binary files differ |
