@@ -186,11 +186,17 @@ fn gather_from_file(dir_entry: &walkdir::DirEntry) -> impl Iterator<Item = Lint>
186
186
let path_buf = path. with_file_name ( filename) ;
187
187
let mut rel_path = path_buf
188
188
. 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" ) ;
190
196
// If the lints are stored in mod.rs, we get the module name from
191
197
// the containing directory:
192
198
if filename == "mod" {
193
- rel_path = rel_path. parent ( ) . unwrap ( ) ;
199
+ rel_path = rel_path. parent ( ) . unwrap ( ) . to_path_buf ( ) ;
194
200
}
195
201
196
202
let module = rel_path
@@ -213,13 +219,15 @@ fn parse_contents(content: &str, module: &str) -> impl Iterator<Item = Lint> {
213
219
lints. chain ( deprecated) . collect :: < Vec < Lint > > ( ) . into_iter ( )
214
220
}
215
221
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
217
223
fn lint_files ( ) -> impl Iterator < Item = walkdir:: DirEntry > {
218
224
// We use `WalkDir` instead of `fs::read_dir` here in order to recurse into subdirectories.
219
225
// 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)
222
229
. into_iter ( )
230
+ . chain ( WalkDir :: new ( clippy_utils_path) . into_iter ( ) )
223
231
. filter_map ( Result :: ok)
224
232
. filter ( |f| f. path ( ) . extension ( ) == Some ( OsStr :: new ( "rs" ) ) )
225
233
}
0 commit comments