3 use walkdir::{DirEntry, WalkDir};
7 pub fn filter_dirs(path: &Path) -> bool {
10 "compiler/rustc_codegen_cranelift",
11 "compiler/rustc_codegen_gcc",
14 "library/portable-simd",
20 "src/tools/rust-analyzer",
21 "src/tools/rust-installer",
24 "src/doc/edition-guide",
25 "src/doc/embedded-book",
27 "src/doc/rust-by-example",
28 "src/doc/rustc-dev-guide",
30 // Filter RLS output directories
32 "src/bootstrap/target",
34 skip.iter().any(|p| path.ends_with(p))
39 skip: &mut dyn FnMut(&Path) -> bool,
40 f: &mut dyn FnMut(&DirEntry, &str),
47 pub fn walk(path: &Path, skip: &mut dyn FnMut(&Path) -> bool, f: &mut dyn FnMut(&DirEntry, &str)) {
48 let mut contents = String::new();
49 walk_no_read(path, skip, &mut |entry| {
51 if t!(File::open(entry.path()), entry.path()).read_to_string(&mut contents).is_err() {
58 pub(crate) fn walk_no_read(
60 skip: &mut dyn FnMut(&Path) -> bool,
61 f: &mut dyn FnMut(&DirEntry),
63 let walker = WalkDir::new(path).into_iter().filter_entry(|e| !skip(e.path()));
65 if let Ok(entry) = entry {
66 if entry.file_type().is_dir() {