@@ -94,13 +94,7 @@ impl Lint {
94
94
#[ must_use]
95
95
pub fn gen_lint_group_list < ' a > ( lints : impl Iterator < Item = & ' a Lint > ) -> Vec < String > {
96
96
lints
97
- . filter_map ( |l| {
98
- if l. deprecation . is_some ( ) {
99
- None
100
- } else {
101
- Some ( format ! ( " LintId::of(&{}::{})," , l. module, l. name. to_uppercase( ) ) )
102
- }
103
- } )
97
+ . map ( |l| format ! ( " LintId::of(&{}::{})," , l. module, l. name. to_uppercase( ) ) )
104
98
. sorted ( )
105
99
. collect :: < Vec < String > > ( )
106
100
}
@@ -120,32 +114,28 @@ pub fn gen_modules_list<'a>(lints: impl Iterator<Item = &'a Lint>) -> Vec<String
120
114
#[ must_use]
121
115
pub fn gen_changelog_lint_list < ' a > ( lints : impl Iterator < Item = & ' a Lint > ) -> Vec < String > {
122
116
lints
123
- . sorted_by_key ( |l| l. name . clone ( ) )
124
- . filter_map ( |l| {
125
- if l. group . starts_with ( "internal" ) {
126
- None
127
- } else {
128
- Some ( format ! ( "[`{}`]: {}#{}" , l. name, DOCS_LINK , l. name) )
129
- }
130
- } )
117
+ . sorted_by_key ( |l| & l. name )
118
+ . map ( |l| format ! ( "[`{}`]: {}#{}" , l. name, DOCS_LINK , l. name) )
131
119
. collect ( )
132
120
}
133
121
134
122
/// Generates the `register_removed` code in `./clippy_lints/src/lib.rs`.
135
123
#[ must_use]
136
124
pub fn gen_deprecated < ' a > ( lints : impl Iterator < Item = & ' a Lint > ) -> Vec < String > {
137
125
lints
138
- . filter_map ( |l| {
139
- l. clone ( ) . deprecation . map ( |depr_text| {
140
- vec ! [
141
- " store.register_removed(" . to_string( ) ,
142
- format!( " \" clippy::{}\" ," , l. name) ,
143
- format!( " \" {}\" ," , depr_text) ,
144
- " );" . to_string( ) ,
145
- ]
146
- } )
126
+ . flat_map ( |l| {
127
+ l. deprecation
128
+ . clone ( )
129
+ . map ( |depr_text| {
130
+ vec ! [
131
+ " store.register_removed(" . to_string( ) ,
132
+ format!( " \" clippy::{}\" ," , l. name) ,
133
+ format!( " \" {}\" ," , depr_text) ,
134
+ " );" . to_string( ) ,
135
+ ]
136
+ } )
137
+ . expect ( "only deprecated lints should be passed" )
147
138
} )
148
- . flatten ( )
149
139
. collect :: < Vec < String > > ( )
150
140
}
151
141
@@ -458,7 +448,6 @@ fn test_gen_changelog_lint_list() {
458
448
let lints = vec ! [
459
449
Lint :: new( "should_assert_eq" , "group1" , "abc" , None , "module_name" ) ,
460
450
Lint :: new( "should_assert_eq2" , "group2" , "abc" , None , "module_name" ) ,
461
- Lint :: new( "incorrect_internal" , "internal_style" , "abc" , None , "module_name" ) ,
462
451
] ;
463
452
let expected = vec ! [
464
453
format!( "[`should_assert_eq`]: {}#should_assert_eq" , DOCS_LINK . to_string( ) ) ,
@@ -484,7 +473,6 @@ fn test_gen_deprecated() {
484
473
Some ( "will be removed" ) ,
485
474
"module_name" ,
486
475
) ,
487
- Lint :: new( "should_assert_eq2" , "group2" , "abc" , None , "module_name" ) ,
488
476
] ;
489
477
let expected: Vec < String > = vec ! [
490
478
" store.register_removed(" ,
@@ -502,13 +490,18 @@ fn test_gen_deprecated() {
502
490
assert_eq ! ( expected, gen_deprecated( lints. iter( ) ) ) ;
503
491
}
504
492
493
+ #[ test]
494
+ #[ should_panic]
495
+ fn test_gen_deprecated_fail ( ) {
496
+ let lints = vec ! [ Lint :: new( "should_assert_eq2" , "group2" , "abc" , None , "module_name" ) ] ;
497
+ let _ = gen_deprecated ( lints. iter ( ) ) ;
498
+ }
499
+
505
500
#[ test]
506
501
fn test_gen_modules_list ( ) {
507
502
let lints = vec ! [
508
503
Lint :: new( "should_assert_eq" , "group1" , "abc" , None , "module_name" ) ,
509
- Lint :: new( "should_assert_eq2" , "group2" , "abc" , Some ( "abc" ) , "deprecated" ) ,
510
504
Lint :: new( "incorrect_stuff" , "group3" , "abc" , None , "another_module" ) ,
511
- Lint :: new( "incorrect_internal" , "internal_style" , "abc" , None , "module_name" ) ,
512
505
] ;
513
506
let expected = vec ! [
514
507
"pub mod another_module;" . to_string( ) ,
@@ -522,7 +515,6 @@ fn test_gen_lint_group_list() {
522
515
let lints = vec ! [
523
516
Lint :: new( "abc" , "group1" , "abc" , None , "module_name" ) ,
524
517
Lint :: new( "should_assert_eq" , "group1" , "abc" , None , "module_name" ) ,
525
- Lint :: new( "should_assert_eq2" , "group2" , "abc" , Some ( "abc" ) , "deprecated" ) ,
526
518
Lint :: new( "internal" , "internal_style" , "abc" , None , "module_name" ) ,
527
519
] ;
528
520
let expected = vec ! [
0 commit comments