@@ -62,13 +62,25 @@ impl Lint {
6262 }
6363
6464 /// Returns all non-deprecated lints and non-internal lints
65- pub fn usable_lints ( lints : impl Iterator < Item = Self > ) -> impl Iterator < Item = Self > {
66- lints. filter ( |l| l. deprecation . is_none ( ) && !l. group . starts_with ( "internal" ) )
65+ #[ must_use]
66+ pub fn usable_lints ( lints : & [ Self ] ) -> Vec < Self > {
67+ lints
68+ . iter ( )
69+ . filter ( |l| l. deprecation . is_none ( ) && !l. group . starts_with ( "internal" ) )
70+ . cloned ( )
71+ . collect ( )
6772 }
6873
6974 /// Returns all internal lints (not `internal_warn` lints)
70- pub fn internal_lints ( lints : impl Iterator < Item = Self > ) -> impl Iterator < Item = Self > {
71- lints. filter ( |l| l. group == "internal" )
75+ #[ must_use]
76+ pub fn internal_lints ( lints : & [ Self ] ) -> Vec < Self > {
77+ lints. iter ( ) . filter ( |l| l. group == "internal" ) . cloned ( ) . collect ( )
78+ }
79+
80+ /// Returns all deprecated lints
81+ #[ must_use]
82+ pub fn deprecated_lints ( lints : & [ Self ] ) -> Vec < Self > {
83+ lints. iter ( ) . filter ( |l| l. deprecation . is_some ( ) ) . cloned ( ) . collect ( )
7284 }
7385
7486 /// Returns the lints in a `HashMap`, grouped by the different lint groups
@@ -80,9 +92,8 @@ impl Lint {
8092
8193/// Generates the Vec items for `register_lint_group` calls in `clippy_lints/src/lib.rs`.
8294#[ must_use]
83- pub fn gen_lint_group_list ( lints : & [ Lint ] ) -> Vec < String > {
95+ pub fn gen_lint_group_list < ' a > ( lints : impl Iterator < Item = & ' a Lint > ) -> Vec < String > {
8496 lints
85- . into_iter ( )
8697 . filter_map ( |l| {
8798 if l. deprecation . is_some ( ) {
8899 None
@@ -96,9 +107,8 @@ pub fn gen_lint_group_list(lints: &[Lint]) -> Vec<String> {
96107
97108/// Generates the `pub mod module_name` list in `clippy_lints/src/lib.rs`.
98109#[ must_use]
99- pub fn gen_modules_list ( lints : & [ Lint ] ) -> Vec < String > {
110+ pub fn gen_modules_list < ' a > ( lints : impl Iterator < Item = & ' a Lint > ) -> Vec < String > {
100111 lints
101- . iter ( )
102112 . map ( |l| & l. module )
103113 . unique ( )
104114 . map ( |module| format ! ( "pub mod {};" , module) )
@@ -108,9 +118,8 @@ pub fn gen_modules_list(lints: &[Lint]) -> Vec<String> {
108118
109119/// Generates the list of lint links at the bottom of the README
110120#[ must_use]
111- pub fn gen_changelog_lint_list ( lints : & [ Lint ] ) -> Vec < String > {
121+ pub fn gen_changelog_lint_list < ' a > ( lints : impl Iterator < Item = & ' a Lint > ) -> Vec < String > {
112122 lints
113- . iter ( )
114123 . sorted_by_key ( |l| l. name . clone ( ) )
115124 . filter_map ( |l| {
116125 if l. group . starts_with ( "internal" ) {
@@ -124,9 +133,8 @@ pub fn gen_changelog_lint_list(lints: &[Lint]) -> Vec<String> {
124133
125134/// Generates the `register_removed` code in `./clippy_lints/src/lib.rs`.
126135#[ must_use]
127- pub fn gen_deprecated ( lints : & [ Lint ] ) -> Vec < String > {
136+ pub fn gen_deprecated < ' a > ( lints : impl Iterator < Item = & ' a Lint > ) -> Vec < String > {
128137 lints
129- . iter ( )
130138 . filter_map ( |l| {
131139 l. clone ( ) . deprecation . map ( |depr_text| {
132140 vec ! [
@@ -142,11 +150,10 @@ pub fn gen_deprecated(lints: &[Lint]) -> Vec<String> {
142150}
143151
144152#[ must_use]
145- pub fn gen_register_lint_list ( lints : & [ Lint ] ) -> Vec < String > {
153+ pub fn gen_register_lint_list < ' a > ( lints : impl Iterator < Item = & ' a Lint > ) -> Vec < String > {
146154 let pre = " store.register_lints(&[" . to_string ( ) ;
147155 let post = " ]);" . to_string ( ) ;
148156 let mut inner = lints
149- . iter ( )
150157 . map ( |l| format ! ( " &{}::{}," , l. module, l. name. to_uppercase( ) ) )
151158 . sorted ( )
152159 . collect :: < Vec < String > > ( ) ;
@@ -421,7 +428,7 @@ fn test_usable_lints() {
421428 None ,
422429 "module_name" ,
423430 ) ] ;
424- assert_eq ! ( expected, Lint :: usable_lints( lints. into_iter ( ) ) . collect :: < Vec < Lint >> ( ) ) ;
431+ assert_eq ! ( expected, Lint :: usable_lints( & lints) ) ;
425432}
426433
427434#[ test]
@@ -457,7 +464,7 @@ fn test_gen_changelog_lint_list() {
457464 format!( "[`should_assert_eq`]: {}#should_assert_eq" , DOCS_LINK . to_string( ) ) ,
458465 format!( "[`should_assert_eq2`]: {}#should_assert_eq2" , DOCS_LINK . to_string( ) ) ,
459466 ] ;
460- assert_eq ! ( expected, gen_changelog_lint_list( & lints) ) ;
467+ assert_eq ! ( expected, gen_changelog_lint_list( lints. iter ( ) ) ) ;
461468}
462469
463470#[ test]
@@ -492,7 +499,7 @@ fn test_gen_deprecated() {
492499 . into_iter ( )
493500 . map ( String :: from)
494501 . collect ( ) ;
495- assert_eq ! ( expected, gen_deprecated( & lints) ) ;
502+ assert_eq ! ( expected, gen_deprecated( lints. iter ( ) ) ) ;
496503}
497504
498505#[ test]
@@ -507,7 +514,7 @@ fn test_gen_modules_list() {
507514 "pub mod another_module;" . to_string( ) ,
508515 "pub mod module_name;" . to_string( ) ,
509516 ] ;
510- assert_eq ! ( expected, gen_modules_list( & lints) ) ;
517+ assert_eq ! ( expected, gen_modules_list( lints. iter ( ) ) ) ;
511518}
512519
513520#[ test]
@@ -523,5 +530,5 @@ fn test_gen_lint_group_list() {
523530 " LintId::of(&module_name::INTERNAL)," . to_string( ) ,
524531 " LintId::of(&module_name::SHOULD_ASSERT_EQ)," . to_string( ) ,
525532 ] ;
526- assert_eq ! ( expected, gen_lint_group_list( & lints) ) ;
533+ assert_eq ! ( expected, gen_lint_group_list( lints. iter ( ) ) ) ;
527534}
0 commit comments