diff --git a/clippy_dev/Cargo.toml b/clippy_dev/Cargo.toml index d6057ba970c..5380ecd9814 100644 --- a/clippy_dev/Cargo.toml +++ b/clippy_dev/Cargo.toml @@ -9,3 +9,4 @@ clap = "~2.32" itertools = "0.7" regex = "1" lazy_static = "1.0" +walkdir = "2" diff --git a/clippy_dev/src/lib.rs b/clippy_dev/src/lib.rs index eee9089e7c4..d312eadf89e 100644 --- a/clippy_dev/src/lib.rs +++ b/clippy_dev/src/lib.rs @@ -14,6 +14,7 @@ use itertools::Itertools; use lazy_static::lazy_static; use regex::Regex; +use walkdir::WalkDir; use std::collections::HashMap; use std::ffi::OsStr; use std::fs; @@ -70,7 +71,7 @@ pub fn gather_all() -> impl Iterator { lint_files().flat_map(|f| gather_from_file(&f)) } -fn gather_from_file(dir_entry: &fs::DirEntry) -> impl Iterator { +fn gather_from_file(dir_entry: &walkdir::DirEntry) -> impl Iterator { let mut file = fs::File::open(dir_entry.path()).unwrap(); let mut content = String::new(); file.read_to_string(&mut content).unwrap(); @@ -89,9 +90,9 @@ fn parse_contents(content: &str, filename: &str) -> impl Iterator { } /// Collects all .rs files in the `clippy_lints/src` directory -fn lint_files() -> impl Iterator { - fs::read_dir("../clippy_lints/src") - .unwrap() +fn lint_files() -> impl Iterator { + WalkDir::new("../clippy_lints/src") + .into_iter() .filter_map(|f| f.ok()) .filter(|f| f.path().extension() == Some(OsStr::new("rs"))) }