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 // Filter RLS output directories
26 "src/bootstrap/target",
28 skip.iter().any(|p| path.ends_with(p))
33 skip: &mut dyn FnMut(&Path) -> bool,
34 f: &mut dyn FnMut(&DirEntry, &str),
41 pub fn walk(path: &Path, skip: &mut dyn FnMut(&Path) -> bool, f: &mut dyn FnMut(&DirEntry, &str)) {
42 let mut contents = String::new();
43 walk_no_read(path, skip, &mut |entry| {
45 if t!(File::open(entry.path()), entry.path()).read_to_string(&mut contents).is_err() {
52 pub(crate) fn walk_no_read(
54 skip: &mut dyn FnMut(&Path) -> bool,
55 f: &mut dyn FnMut(&DirEntry),
57 let walker = WalkDir::new(path).into_iter().filter_entry(|e| !skip(e.path()));
59 if let Ok(entry) = entry {
60 if entry.file_type().is_dir() {