Skip to content

Commit b8d2f5c

Browse files
committed
Don't crate-locally reexport walk functions in tidy
1 parent 503e19d commit b8d2f5c

12 files changed

+28
-21
lines changed

src/tools/tidy/src/bins.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ mod os_impl {
2121

2222
#[cfg(unix)]
2323
mod os_impl {
24+
use crate::walk::{filter_dirs, walk_no_read};
2425
use std::fs;
2526
use std::os::unix::prelude::*;
2627
use std::path::Path;
@@ -100,10 +101,10 @@ mod os_impl {
100101

101102
const ALLOWED: &[&str] = &["configure", "x"];
102103

103-
crate::walk_no_read(
104+
walk_no_read(
104105
path,
105106
&mut |path| {
106-
crate::filter_dirs(path)
107+
filter_dirs(path)
107108
|| path.ends_with("src/etc")
108109
// This is a list of directories that we almost certainly
109110
// don't need to walk. A future PR will likely want to

src/tools/tidy/src/debug_artifacts.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
//! Tidy check to prevent creation of unnecessary debug artifacts while running tests.
22
3+
use crate::walk::{filter_dirs, walk};
34
use std::path::{Path, PathBuf};
45

56
const GRAPHVIZ_POSTFLOW_MSG: &str = "`borrowck_graphviz_postflow` attribute in test";
67

78
pub fn check(path: &Path, bad: &mut bool) {
89
let test_dir: PathBuf = path.join("test");
910

10-
super::walk(&test_dir, &mut super::filter_dirs, &mut |entry, contents| {
11+
walk(&test_dir, &mut filter_dirs, &mut |entry, contents| {
1112
let filename = entry.path();
1213
let is_rust = filename.extension().map_or(false, |ext| ext == "rs");
1314
if !is_rust {

src/tools/tidy/src/edition.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Tidy check to ensure that crate `edition` is '2018' or '2021'.
22
3+
use crate::walk::{filter_dirs, walk};
34
use std::path::Path;
45

56
fn is_edition_2021(mut line: &str) -> bool {
@@ -8,9 +9,9 @@ fn is_edition_2021(mut line: &str) -> bool {
89
}
910

1011
pub fn check(path: &Path, bad: &mut bool) {
11-
super::walk(
12+
walk(
1213
path,
13-
&mut |path| super::filter_dirs(path) || path.ends_with("src/test"),
14+
&mut |path| filter_dirs(path) || path.ends_with("src/test"),
1415
&mut |entry, contents| {
1516
let file = entry.path();
1617
let filename = file.file_name().unwrap();

src/tools/tidy/src/error_codes_check.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Checks that all error codes have at least one test to prevent having error
22
//! codes that are silently not thrown by the compiler anymore.
33
4+
use crate::walk::{filter_dirs, walk};
45
use std::collections::{HashMap, HashSet};
56
use std::ffi::OsStr;
67
use std::fs::read_to_string;
@@ -217,7 +218,7 @@ pub fn check(paths: &[&Path], bad: &mut bool) {
217218
println!("Checking which error codes lack tests...");
218219

219220
for path in paths {
220-
super::walk(path, &mut super::filter_dirs, &mut |entry, contents| {
221+
walk(path, &mut filter_dirs, &mut |entry, contents| {
221222
let file_name = entry.file_name();
222223
let entry_path = entry.path();
223224

src/tools/tidy/src/errors.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
//! This ensures that error codes are used at most once and also prints out some
44
//! statistics about the error codes.
55
6+
use crate::walk::{filter_dirs, walk};
67
use std::collections::HashMap;
78
use std::path::Path;
89

910
pub fn check(path: &Path, bad: &mut bool) {
1011
let mut map: HashMap<_, Vec<_>> = HashMap::new();
11-
super::walk(
12+
walk(
1213
path,
13-
&mut |path| super::filter_dirs(path) || path.ends_with("src/test"),
14+
&mut |path| filter_dirs(path) || path.ends_with("src/test"),
1415
&mut |entry, contents| {
1516
let file = entry.path();
1617
let filename = file.file_name().unwrap().to_string_lossy();

src/tools/tidy/src/features.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//! * All unstable lang features have tests to ensure they are actually unstable.
1010
//! * Language features in a group are sorted by feature name.
1111
12+
use crate::walk::{filter_dirs, walk, walk_many};
1213
use std::collections::HashMap;
1314
use std::fmt;
1415
use std::fs;
@@ -92,14 +93,14 @@ pub fn check(
9293
let lib_features = get_and_check_lib_features(lib_path, bad, &features);
9394
assert!(!lib_features.is_empty());
9495

95-
super::walk_many(
96+
walk_many(
9697
&[
9798
&src_path.join("test/ui"),
9899
&src_path.join("test/ui-fulldeps"),
99100
&src_path.join("test/rustdoc-ui"),
100101
&src_path.join("test/rustdoc"),
101102
],
102-
&mut |path| super::filter_dirs(path),
103+
&mut filter_dirs,
103104
&mut |entry, contents| {
104105
let file = entry.path();
105106
let filename = file.file_name().unwrap().to_string_lossy();
@@ -466,9 +467,9 @@ fn map_lib_features(
466467
base_src_path: &Path,
467468
mf: &mut dyn FnMut(Result<(&str, Feature), &str>, &Path, usize),
468469
) {
469-
super::walk(
470+
walk(
470471
base_src_path,
471-
&mut |path| super::filter_dirs(path) || path.ends_with("src/test"),
472+
&mut |path| filter_dirs(path) || path.ends_with("src/test"),
472473
&mut |entry, contents| {
473474
let file = entry.path();
474475
let filename = file.file_name().unwrap().to_string_lossy();

src/tools/tidy/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
//! This library contains the tidy lints and exposes it
44
//! to be used by tools.
55
6-
use walk::{filter_dirs, walk, walk_many, walk_no_read};
7-
86
/// A helper macro to `unwrap` a result except also print out details like:
97
///
108
/// * The expression that failed

src/tools/tidy/src/pal.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
//! platform-specific cfgs are allowed. Not sure yet how to deal with
3131
//! this in the long term.
3232
33+
use crate::walk::{filter_dirs, walk};
3334
use std::iter::Iterator;
3435
use std::path::Path;
3536

@@ -67,7 +68,7 @@ pub fn check(path: &Path, bad: &mut bool) {
6768
// Sanity check that the complex parsing here works.
6869
let mut saw_target_arch = false;
6970
let mut saw_cfg_bang = false;
70-
super::walk(path, &mut super::filter_dirs, &mut |entry, contents| {
71+
walk(path, &mut filter_dirs, &mut |entry, contents| {
7172
let file = entry.path();
7273
let filestr = file.to_string_lossy().replace("\\", "/");
7374
if !filestr.ends_with(".rs") {

src/tools/tidy/src/style.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
//! A number of these checks can be opted-out of with various directives of the form:
1717
//! `// ignore-tidy-CHECK-NAME`.
1818
19+
use crate::walk::{filter_dirs, walk};
1920
use regex::Regex;
2021
use std::path::Path;
2122

@@ -218,13 +219,13 @@ fn is_unexplained_ignore(extension: &str, line: &str) -> bool {
218219

219220
pub fn check(path: &Path, bad: &mut bool) {
220221
fn skip(path: &Path) -> bool {
221-
super::filter_dirs(path) || skip_markdown_path(path)
222+
filter_dirs(path) || skip_markdown_path(path)
222223
}
223224
let problematic_consts_strings: Vec<String> = (PROBLEMATIC_CONSTS.iter().map(u32::to_string))
224225
.chain(PROBLEMATIC_CONSTS.iter().map(|v| format!("{:x}", v)))
225226
.chain(PROBLEMATIC_CONSTS.iter().map(|v| format!("{:X}", v)))
226227
.collect();
227-
super::walk(path, &mut skip, &mut |entry, contents| {
228+
walk(path, &mut skip, &mut |entry, contents| {
228229
let file = entry.path();
229230
let filename = file.file_name().unwrap().to_string_lossy();
230231
let extensions = [".rs", ".py", ".js", ".sh", ".c", ".cpp", ".h", ".md", ".css", ".ftl"];

src/tools/tidy/src/target_specific_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct RevisionInfo<'a> {
3636

3737
pub fn check(path: &Path, bad: &mut bool) {
3838
let tests = path.join("test");
39-
super::walk(
39+
crate::walk::walk(
4040
&tests,
4141
&mut |path| path.extension().map(|p| p == "rs") == Some(false),
4242
&mut |entry, content| {

src/tools/tidy/src/ui_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn check_entries(path: &Path, bad: &mut bool) {
4747
pub fn check(path: &Path, bad: &mut bool) {
4848
check_entries(&path, bad);
4949
for path in &[&path.join("test/ui"), &path.join("test/ui-fulldeps")] {
50-
super::walk_no_read(path, &mut |_| false, &mut |entry| {
50+
crate::walk::walk_no_read(path, &mut |_| false, &mut |entry| {
5151
let file_path = entry.path();
5252
if let Some(ext) = file_path.extension() {
5353
if ext == "stderr" || ext == "stdout" {

src/tools/tidy/src/unit_tests.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//! named `tests.rs` or `benches.rs`, or directories named `tests` or `benches` unconfigured
88
//! during normal build.
99
10+
use crate::walk::{filter_dirs, walk};
1011
use std::path::Path;
1112

1213
pub fn check(root_path: &Path, bad: &mut bool) {
@@ -20,7 +21,7 @@ pub fn check(root_path: &Path, bad: &mut bool) {
2021
let mut skip = |path: &Path| {
2122
let file_name = path.file_name().unwrap_or_default();
2223
if path.is_dir() {
23-
super::filter_dirs(path)
24+
filter_dirs(path)
2425
|| path.ends_with("src/test")
2526
|| path.ends_with("src/doc")
2627
|| (file_name == "tests" || file_name == "benches") && !is_core(path)
@@ -34,7 +35,7 @@ pub fn check(root_path: &Path, bad: &mut bool) {
3435
}
3536
};
3637

37-
super::walk(root_path, &mut skip, &mut |entry, contents| {
38+
walk(root_path, &mut skip, &mut |entry, contents| {
3839
let path = entry.path();
3940
let is_core = path.starts_with(core);
4041
for (i, line) in contents.lines().enumerate() {

0 commit comments

Comments
 (0)