Skip to content

Commit 45b87fb

Browse files
Lint against executable files in the root directory
This avoids accidental introduction (such as in #97488).
1 parent 9a6fa4f commit 45b87fb

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

src/tools/tidy/src/bins.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,25 @@ mod os_impl {
9696

9797
#[cfg(unix)]
9898
pub fn check(path: &Path, bad: &mut bool) {
99+
const ALLOWED: &[&str] = &["configure"];
100+
99101
crate::walk_no_read(
100102
path,
101-
&mut |path| crate::filter_dirs(path) || path.ends_with("src/etc"),
103+
&mut |path| {
104+
crate::filter_dirs(path)
105+
|| path.ends_with("src/etc")
106+
// This is a list of directories that we almost certainly
107+
// don't need to walk. A future PR will likely want to
108+
// remove these in favor of crate::walk_no_read using git
109+
// ls-files to discover the paths we should check, which
110+
// would naturally ignore all of these directories. It's
111+
// also likely faster than walking the directory tree
112+
// directly (since git is just reading from a couple files
113+
// to produce the results).
114+
|| path.ends_with("target")
115+
|| path.ends_with("build")
116+
|| path.ends_with(".git")
117+
},
102118
&mut |entry| {
103119
let file = entry.path();
104120
let filename = file.file_name().unwrap().to_string_lossy();
@@ -110,6 +126,11 @@ mod os_impl {
110126
if t!(is_executable(&file), file) {
111127
let rel_path = file.strip_prefix(path).unwrap();
112128
let git_friendly_path = rel_path.to_str().unwrap().replace("\\", "/");
129+
130+
if ALLOWED.contains(&git_friendly_path.as_str()) {
131+
return;
132+
}
133+
113134
let output = Command::new("git")
114135
.arg("ls-files")
115136
.arg(&git_friendly_path)

src/tools/tidy/src/main.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,8 @@ fn main() {
7878
check!(unit_tests, &compiler_path);
7979
check!(unit_tests, &library_path);
8080

81-
if bins::check_filesystem_support(
82-
&[&src_path, &compiler_path, &library_path],
83-
&output_directory,
84-
) {
85-
check!(bins, &src_path);
86-
check!(bins, &compiler_path);
87-
check!(bins, &library_path);
81+
if bins::check_filesystem_support(&[&root_path], &output_directory) {
82+
check!(bins, &root_path);
8883
}
8984

9085
check!(style, &src_path);

suggest-blanket-impl-local-trait

-468 KB
Binary file not shown.

0 commit comments

Comments
 (0)