Skip to content

Commit 98334f6

Browse files
committed
Don't walk the tests/ directories in checks that always skip it
`WalkBuilder` handles top-level paths differently than `fn walk` used to: it doesn't run the `skip` function to determine if it should be skipped, instead assuming the top-level function is always included. This is a reasonable assumption; adapt our code so it doesn't make pointless calls to `walk`.
1 parent 97cffd5 commit 98334f6

File tree

3 files changed

+15
-25
lines changed

3 files changed

+15
-25
lines changed

src/tools/tidy/src/edition.rs

+15-22
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,20 @@ fn is_edition_2021(mut line: &str) -> bool {
99
}
1010

1111
pub fn check(path: &Path, bad: &mut bool) {
12-
walk(
13-
path,
14-
|path| {
15-
filter_dirs(path)
16-
|| (path.ends_with("tests") && path.join("COMPILER_TESTS.md").exists())
17-
},
18-
&mut |entry, contents| {
19-
let file = entry.path();
20-
let filename = file.file_name().unwrap();
21-
if filename != "Cargo.toml" {
22-
return;
23-
}
12+
walk(path, |path| filter_dirs(path), &mut |entry, contents| {
13+
let file = entry.path();
14+
let filename = file.file_name().unwrap();
15+
if filename != "Cargo.toml" {
16+
return;
17+
}
2418

25-
let is_2021 = contents.lines().any(is_edition_2021);
26-
if !is_2021 {
27-
tidy_error!(
28-
bad,
29-
"{} doesn't have `edition = \"2021\"` on a separate line",
30-
file.display()
31-
);
32-
}
33-
},
34-
);
19+
let is_2021 = contents.lines().any(is_edition_2021);
20+
if !is_2021 {
21+
tidy_error!(
22+
bad,
23+
"{} doesn't have `edition = \"2021\"` on a separate line",
24+
file.display()
25+
);
26+
}
27+
});
3528
}

src/tools/tidy/src/main.rs

-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ fn main() {
9191

9292
// Checks that need to be done for both the compiler and std libraries.
9393
check!(unit_tests, &src_path);
94-
check!(unit_tests, &tests_path);
9594
check!(unit_tests, &compiler_path);
9695
check!(unit_tests, &library_path);
9796

@@ -107,7 +106,6 @@ fn main() {
107106
check!(edition, &src_path);
108107
check!(edition, &compiler_path);
109108
check!(edition, &library_path);
110-
check!(edition, &tests_path);
111109

112110
check!(alphabetical, &src_path);
113111
check!(alphabetical, &tests_path);

src/tools/tidy/src/unit_tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ pub fn check(root_path: &Path, bad: &mut bool) {
2424
let file_name = path.file_name().unwrap_or_default();
2525
if path.is_dir() {
2626
filter_dirs(path)
27-
|| path.ends_with("tests")
2827
|| path.ends_with("src/doc")
2928
|| (file_name == "tests" || file_name == "benches") && !is_core(path)
3029
} else {

0 commit comments

Comments
 (0)