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