@@ -72,6 +72,19 @@ impl Lint {
7272 }
7373}
7474
75+ /// Generates the Vec items for `register_lint_group` calls in `clippy_lints/src/lib.rs`.
76+ pub fn gen_lint_group_list ( lints : Vec < Lint > ) -> Vec < String > {
77+ lints. into_iter ( )
78+ . filter_map ( |l| {
79+ if l. is_internal ( ) || l. deprecation . is_some ( ) {
80+ None
81+ } else {
82+ Some ( format ! ( " {}::{}," , l. module, l. name. to_uppercase( ) ) )
83+ }
84+ } )
85+ . sorted ( )
86+ }
87+
7588/// Generates the `pub mod module_name` list in `clippy_lints/src/lib.rs`.
7689pub fn gen_modules_list ( lints : Vec < Lint > ) -> Vec < String > {
7790 lints. into_iter ( )
@@ -390,3 +403,18 @@ fn test_gen_modules_list() {
390403 ] ;
391404 assert_eq ! ( expected, gen_modules_list( lints) ) ;
392405}
406+
407+ #[ test]
408+ fn test_gen_lint_group_list ( ) {
409+ let lints = vec ! [
410+ Lint :: new( "abc" , "group1" , "abc" , None , "module_name" ) ,
411+ Lint :: new( "should_assert_eq" , "group1" , "abc" , None , "module_name" ) ,
412+ Lint :: new( "should_assert_eq2" , "group2" , "abc" , Some ( "abc" ) , "deprecated" ) ,
413+ Lint :: new( "incorrect_internal" , "internal_style" , "abc" , None , "module_name" ) ,
414+ ] ;
415+ let expected = vec ! [
416+ " module_name::ABC," . to_string( ) ,
417+ " module_name::SHOULD_ASSERT_EQ," . to_string( ) ,
418+ ] ;
419+ assert_eq ! ( expected, gen_lint_group_list( lints) ) ;
420+ }
0 commit comments