about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSamuel E. Moelius III <sam@moeli.us>2021-02-17 20:54:14 -0500
committerSamuel E. Moelius III <sam@moeli.us>2021-02-23 18:50:30 -0500
commitce76fb3d095eb0b28fd4f382e2d9e8065728c452 (patch)
tree2a391f8071ee4ac56dec8639c85c53bcdf14b694
parent979206f6b4bc1dcd30e621e1f53f6b8c6283ebbc (diff)
downloadrust-ce76fb3d095eb0b28fd4f382e2d9e8065728c452.tar.gz
rust-ce76fb3d095eb0b28fd4f382e2d9e8065728c452.zip
Fix update_lints
-rw-r--r--clippy_dev/src/lib.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/clippy_dev/src/lib.rs b/clippy_dev/src/lib.rs
index 01d1fc9211a..296ef00b3f1 100644
--- a/clippy_dev/src/lib.rs
+++ b/clippy_dev/src/lib.rs
@@ -186,11 +186,17 @@ fn gather_from_file(dir_entry: &walkdir::DirEntry) -> impl Iterator<Item = Lint>
     let path_buf = path.with_file_name(filename);
     let mut rel_path = path_buf
         .strip_prefix(clippy_project_root().join("clippy_lints/src"))
-        .expect("only files in `clippy_lints/src` should be looked at");
+        .map(PathBuf::from)
+        .or_else(|_| {
+            path_buf
+                .strip_prefix(clippy_project_root().join("clippy_utils/src"))
+                .map(|c| Path::new("utils").join(c))
+        })
+        .expect("only files in `clippy_lints/src` or `clippy_utils/src` should be looked at");
     // If the lints are stored in mod.rs, we get the module name from
     // the containing directory:
     if filename == "mod" {
-        rel_path = rel_path.parent().unwrap();
+        rel_path = rel_path.parent().unwrap().to_path_buf();
     }
 
     let module = rel_path
@@ -213,13 +219,15 @@ fn parse_contents(content: &str, module: &str) -> impl Iterator<Item = Lint> {
     lints.chain(deprecated).collect::<Vec<Lint>>().into_iter()
 }
 
-/// Collects all .rs files in the `clippy_lints/src` directory
+/// Collects all .rs files in the `clippy_lints/src` and `clippy_lints/src` directories
 fn lint_files() -> impl Iterator<Item = walkdir::DirEntry> {
     // We use `WalkDir` instead of `fs::read_dir` here in order to recurse into subdirectories.
     // Otherwise we would not collect all the lints, for example in `clippy_lints/src/methods/`.
-    let path = clippy_project_root().join("clippy_lints/src");
-    WalkDir::new(path)
+    let clippy_lints_path = clippy_project_root().join("clippy_lints/src");
+    let clippy_utils_path = clippy_project_root().join("clippy_utils/src");
+    WalkDir::new(clippy_lints_path)
         .into_iter()
+        .chain(WalkDir::new(clippy_utils_path).into_iter())
         .filter_map(Result::ok)
         .filter(|f| f.path().extension() == Some(OsStr::new("rs")))
 }