@@ -59,13 +59,29 @@ impl Lint {
59
59
60
60
/// Returns all non-deprecated lints and non-internal lints
61
61
pub fn usable_lints ( lints : impl Iterator < Item =Self > ) -> impl Iterator < Item =Self > {
62
- lints. filter ( |l| l. deprecation . is_none ( ) && !l. group . starts_with ( "internal" ) )
62
+ lints. filter ( |l| l. deprecation . is_none ( ) && !l. is_internal ( ) )
63
63
}
64
64
65
65
/// Returns the lints in a HashMap, grouped by the different lint groups
66
66
pub fn by_lint_group ( lints : & [ Self ] ) -> HashMap < String , Vec < Self > > {
67
67
lints. iter ( ) . map ( |lint| ( lint. group . to_string ( ) , lint. clone ( ) ) ) . into_group_map ( )
68
68
}
69
+
70
+ pub fn is_internal ( & self ) -> bool {
71
+ self . group . starts_with ( "internal" )
72
+ }
73
+ }
74
+
75
+ pub fn gen_changelog_lint_list ( lints : Vec < Lint > ) -> Vec < String > {
76
+ let mut lint_list_sorted: Vec < Lint > = lints;
77
+ lint_list_sorted. sort_by_key ( |l| l. name . clone ( ) ) ;
78
+ lint_list_sorted
79
+ . iter ( )
80
+ . filter ( |l| !l. is_internal ( ) )
81
+ . map ( |l| {
82
+ format ! ( "[`{}`]: {}#{}" , l. name, DOCS_LINK . clone( ) , l. name)
83
+ } )
84
+ . collect ( )
69
85
}
70
86
71
87
/// Gathers all files in `src/clippy_lints` and gathers all lints inside
@@ -291,3 +307,17 @@ fn test_by_lint_group() {
291
307
] ) ;
292
308
assert_eq ! ( expected, Lint :: by_lint_group( & lints) ) ;
293
309
}
310
+
311
+ #[ test]
312
+ fn test_gen_changelog_lint_list ( ) {
313
+ let lints = vec ! [
314
+ Lint :: new( "should_assert_eq" , "group1" , "abc" , None , "module_name" ) ,
315
+ Lint :: new( "should_assert_eq2" , "group2" , "abc" , None , "module_name" ) ,
316
+ Lint :: new( "incorrect_internal" , "internal_style" , "abc" , None , "module_name" ) ,
317
+ ] ;
318
+ let expected = vec ! [
319
+ format!( "[`should_assert_eq`]: {}#should_assert_eq" , DOCS_LINK . to_string( ) ) ,
320
+ format!( "[`should_assert_eq2`]: {}#should_assert_eq2" , DOCS_LINK . to_string( ) )
321
+ ] ;
322
+ assert_eq ! ( expected, gen_changelog_lint_list( lints) ) ;
323
+ }
0 commit comments