@@ -3,7 +3,7 @@ use crate::utils::{
3
3
} ;
4
4
use itertools:: Itertools ;
5
5
use rustc_lexer:: unescape;
6
- use std:: collections:: { HashMap , HashSet } ;
6
+ use std:: collections:: HashSet ;
7
7
use std:: fmt:: Write ;
8
8
use std:: fs:: OpenOptions ;
9
9
use std:: ops:: Range ;
@@ -107,24 +107,6 @@ pub fn generate_lint_files(
107
107
) ;
108
108
}
109
109
110
- pub fn print_lints ( ) {
111
- let lints = find_lint_decls ( ) ;
112
- let lint_count = lints. len ( ) ;
113
- let grouped_by_lint_group = Lint :: by_lint_group ( lints. into_iter ( ) ) ;
114
-
115
- for ( lint_group, mut lints) in grouped_by_lint_group {
116
- println ! ( "\n ## {lint_group}" ) ;
117
-
118
- lints. sort_by_key ( |l| l. name . clone ( ) ) ;
119
-
120
- for lint in lints {
121
- println ! ( "* [{}]({DOCS_LINK}#{}) ({})" , lint. name, lint. name, lint. desc) ;
122
- }
123
- }
124
-
125
- println ! ( "there are {lint_count} lints" ) ;
126
- }
127
-
128
110
fn round_to_fifty ( count : usize ) -> usize {
129
111
count / 50 * 50
130
112
}
@@ -134,19 +116,10 @@ fn round_to_fifty(count: usize) -> usize {
134
116
pub struct Lint {
135
117
pub name : String ,
136
118
pub group : String ,
137
- pub desc : String ,
138
119
pub module : String ,
139
120
pub declaration_range : Range < usize > ,
140
121
}
141
122
142
- impl Lint {
143
- /// Returns the lints in a `HashMap`, grouped by the different lint groups
144
- #[ must_use]
145
- fn by_lint_group ( lints : impl Iterator < Item = Self > ) -> HashMap < String , Vec < Self > > {
146
- lints. map ( |lint| ( lint. group . to_string ( ) , lint) ) . into_group_map ( )
147
- }
148
- }
149
-
150
123
#[ derive( Clone , PartialEq , Eq , Debug ) ]
151
124
pub struct DeprecatedLint {
152
125
pub name : String ,
@@ -186,7 +159,6 @@ pub fn find_lint_decls() -> Vec<Lint> {
186
159
let mut contents = String :: new ( ) ;
187
160
for ( file, module) in read_src_with_module ( "clippy_lints/src" . as_ref ( ) ) {
188
161
parse_clippy_lint_decls (
189
- file. path ( ) ,
190
162
File :: open_read_to_cleared_string ( file. path ( ) , & mut contents) ,
191
163
& module,
192
164
& mut lints,
@@ -231,7 +203,7 @@ fn read_src_with_module(src_root: &Path) -> impl use<'_> + Iterator<Item = (DirE
231
203
}
232
204
233
205
/// Parse a source file looking for `declare_clippy_lint` macro invocations.
234
- fn parse_clippy_lint_decls ( path : & Path , contents : & str , module : & str , lints : & mut Vec < Lint > ) {
206
+ fn parse_clippy_lint_decls ( contents : & str , module : & str , lints : & mut Vec < Lint > ) {
235
207
#[ allow( clippy:: enum_glob_use) ]
236
208
use Token :: * ;
237
209
#[ rustfmt:: skip]
@@ -240,21 +212,20 @@ fn parse_clippy_lint_decls(path: &Path, contents: &str, module: &str, lints: &mu
240
212
Bang , OpenBrace , AnyDoc ,
241
213
// #[clippy::version = "version"]
242
214
Pound , OpenBracket , Ident ( "clippy" ) , DoubleColon , Ident ( "version" ) , Eq , LitStr , CloseBracket ,
243
- // pub NAME, GROUP, "description"
244
- Ident ( "pub" ) , CaptureIdent , Comma , CaptureIdent , Comma , CaptureLitStr ,
215
+ // pub NAME, GROUP,
216
+ Ident ( "pub" ) , CaptureIdent , Comma , CaptureIdent , Comma ,
245
217
] ;
246
218
247
219
let mut searcher = RustSearcher :: new ( contents) ;
248
220
while searcher. find_token ( Ident ( "declare_clippy_lint" ) ) {
249
221
let start = searcher. pos ( ) as usize - "declare_clippy_lint" . len ( ) ;
250
- let ( mut name, mut group, mut desc ) = ( "" , "" , "" ) ;
251
- if searcher. match_tokens ( DECL_TOKENS , & mut [ & mut name, & mut group, & mut desc ] )
222
+ let ( mut name, mut group) = ( "" , "" ) ;
223
+ if searcher. match_tokens ( DECL_TOKENS , & mut [ & mut name, & mut group] )
252
224
&& searcher. find_token ( CloseBrace )
253
225
{
254
226
lints. push ( Lint {
255
227
name : name. to_lowercase ( ) ,
256
228
group : group. into ( ) ,
257
- desc : parse_str_single_line ( path, desc) ,
258
229
module : module. into ( ) ,
259
230
declaration_range : start..searcher. pos ( ) as usize ,
260
231
} ) ;
@@ -398,61 +369,25 @@ mod tests {
398
369
}
399
370
"# ;
400
371
let mut result = Vec :: new ( ) ;
401
- parse_clippy_lint_decls ( "" . as_ref ( ) , CONTENTS , "module_name" , & mut result) ;
372
+ parse_clippy_lint_decls ( CONTENTS , "module_name" , & mut result) ;
402
373
for r in & mut result {
403
374
r. declaration_range = Range :: default ( ) ;
404
375
}
405
376
406
377
let expected = vec ! [
407
- Lint :: new(
408
- "ptr_arg" ,
409
- "style" ,
410
- "\" really long text\" " ,
411
- "module_name" ,
412
- Range :: default ( ) ,
413
- ) ,
414
- Lint :: new(
415
- "doc_markdown" ,
416
- "pedantic" ,
417
- "\" single line\" " ,
418
- "module_name" ,
419
- Range :: default ( ) ,
420
- ) ,
378
+ Lint {
379
+ name: "ptr_arg" . into( ) ,
380
+ group: "style" . into( ) ,
381
+ module: "module_name" . into( ) ,
382
+ declaration_range: Range :: default ( ) ,
383
+ } ,
384
+ Lint {
385
+ name: "doc_markdown" . into( ) ,
386
+ group: "pedantic" . into( ) ,
387
+ module: "module_name" . into( ) ,
388
+ declaration_range: Range :: default ( ) ,
389
+ } ,
421
390
] ;
422
391
assert_eq ! ( expected, result) ;
423
392
}
424
-
425
- #[ test]
426
- fn test_by_lint_group ( ) {
427
- let lints = vec ! [
428
- Lint :: new( "should_assert_eq" , "group1" , "\" abc\" " , "module_name" , Range :: default ( ) ) ,
429
- Lint :: new(
430
- "should_assert_eq2" ,
431
- "group2" ,
432
- "\" abc\" " ,
433
- "module_name" ,
434
- Range :: default ( ) ,
435
- ) ,
436
- Lint :: new( "incorrect_match" , "group1" , "\" abc\" " , "module_name" , Range :: default ( ) ) ,
437
- ] ;
438
- let mut expected: HashMap < String , Vec < Lint > > = HashMap :: new ( ) ;
439
- expected. insert (
440
- "group1" . to_string ( ) ,
441
- vec ! [
442
- Lint :: new( "should_assert_eq" , "group1" , "\" abc\" " , "module_name" , Range :: default ( ) ) ,
443
- Lint :: new( "incorrect_match" , "group1" , "\" abc\" " , "module_name" , Range :: default ( ) ) ,
444
- ] ,
445
- ) ;
446
- expected. insert (
447
- "group2" . to_string ( ) ,
448
- vec ! [ Lint :: new(
449
- "should_assert_eq2" ,
450
- "group2" ,
451
- "\" abc\" " ,
452
- "module_name" ,
453
- Range :: default ( ) ,
454
- ) ] ,
455
- ) ;
456
- assert_eq ! ( expected, Lint :: by_lint_group( lints. into_iter( ) ) ) ;
457
- }
458
393
}
0 commit comments