Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ce76fb3

Browse files
committed
Fix update_lints
1 parent 979206f commit ce76fb3

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

clippy_dev/src/lib.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,17 @@ fn gather_from_file(dir_entry: &walkdir::DirEntry) -> impl Iterator<Item = Lint>
186186
let path_buf = path.with_file_name(filename);
187187
let mut rel_path = path_buf
188188
.strip_prefix(clippy_project_root().join("clippy_lints/src"))
189-
.expect("only files in `clippy_lints/src` should be looked at");
189+
.map(PathBuf::from)
190+
.or_else(|_| {
191+
path_buf
192+
.strip_prefix(clippy_project_root().join("clippy_utils/src"))
193+
.map(|c| Path::new("utils").join(c))
194+
})
195+
.expect("only files in `clippy_lints/src` or `clippy_utils/src` should be looked at");
190196
// If the lints are stored in mod.rs, we get the module name from
191197
// the containing directory:
192198
if filename == "mod" {
193-
rel_path = rel_path.parent().unwrap();
199+
rel_path = rel_path.parent().unwrap().to_path_buf();
194200
}
195201

196202
let module = rel_path
@@ -213,13 +219,15 @@ fn parse_contents(content: &str, module: &str) -> impl Iterator<Item = Lint> {
213219
lints.chain(deprecated).collect::<Vec<Lint>>().into_iter()
214220
}
215221

216-
/// Collects all .rs files in the `clippy_lints/src` directory
222+
/// Collects all .rs files in the `clippy_lints/src` and `clippy_lints/src` directories
217223
fn lint_files() -> impl Iterator<Item = walkdir::DirEntry> {
218224
// We use `WalkDir` instead of `fs::read_dir` here in order to recurse into subdirectories.
219225
// Otherwise we would not collect all the lints, for example in `clippy_lints/src/methods/`.
220-
let path = clippy_project_root().join("clippy_lints/src");
221-
WalkDir::new(path)
226+
let clippy_lints_path = clippy_project_root().join("clippy_lints/src");
227+
let clippy_utils_path = clippy_project_root().join("clippy_utils/src");
228+
WalkDir::new(clippy_lints_path)
222229
.into_iter()
230+
.chain(WalkDir::new(clippy_utils_path).into_iter())
223231
.filter_map(Result::ok)
224232
.filter(|f| f.path().extension() == Some(OsStr::new("rs")))
225233
}

0 commit comments

Comments
 (0)