@@ -37,17 +37,16 @@ fn generate_lint_files(
37
37
deprecated_lints : & [ DeprecatedLint ] ,
38
38
renamed_lints : & [ RenamedLint ] ,
39
39
) {
40
- let internal_lints = Lint :: internal_lints ( lints) ;
41
- let mut usable_lints = Lint :: usable_lints ( lints) ;
42
- usable_lints. sort_by_key ( |lint| lint. name . clone ( ) ) ;
40
+ let mut lints = lints. to_owned ( ) ;
41
+ lints. sort_by_key ( |lint| lint. name . clone ( ) ) ;
43
42
44
43
replace_region_in_file (
45
44
update_mode,
46
45
Path :: new ( "README.md" ) ,
47
46
"[There are over " ,
48
47
" lints included in this crate!]" ,
49
48
|res| {
50
- write ! ( res, "{}" , round_to_fifty( usable_lints . len( ) ) ) . unwrap ( ) ;
49
+ write ! ( res, "{}" , round_to_fifty( lints . len( ) ) ) . unwrap ( ) ;
51
50
} ,
52
51
) ;
53
52
@@ -57,7 +56,7 @@ fn generate_lint_files(
57
56
"[There are over " ,
58
57
" lints included in this crate!]" ,
59
58
|res| {
60
- write ! ( res, "{}" , round_to_fifty( usable_lints . len( ) ) ) . unwrap ( ) ;
59
+ write ! ( res, "{}" , round_to_fifty( lints . len( ) ) ) . unwrap ( ) ;
61
60
} ,
62
61
) ;
63
62
@@ -67,7 +66,7 @@ fn generate_lint_files(
67
66
"<!-- begin autogenerated links to lint list -->\n " ,
68
67
"<!-- end autogenerated links to lint list -->" ,
69
68
|res| {
70
- for lint in usable_lints
69
+ for lint in lints
71
70
. iter ( )
72
71
. map ( |l| & * l. name )
73
72
. chain ( deprecated_lints. iter ( ) . filter_map ( |l| l. name . strip_prefix ( "clippy::" ) ) )
@@ -86,7 +85,7 @@ fn generate_lint_files(
86
85
"// begin lints modules, do not remove this comment, it’s used in `update_lints`\n " ,
87
86
"// end lints modules, do not remove this comment, it’s used in `update_lints`" ,
88
87
|res| {
89
- for lint_mod in usable_lints . iter ( ) . map ( |l| & l. module ) . unique ( ) . sorted ( ) {
88
+ for lint_mod in lints . iter ( ) . map ( |l| & l. module ) . unique ( ) . sorted ( ) {
90
89
writeln ! ( res, "mod {lint_mod};" ) . unwrap ( ) ;
91
90
}
92
91
} ,
@@ -95,7 +94,7 @@ fn generate_lint_files(
95
94
process_file (
96
95
"clippy_lints/src/declared_lints.rs" ,
97
96
update_mode,
98
- & gen_declared_lints ( internal_lints . iter ( ) , usable_lints . iter ( ) ) ,
97
+ & gen_declared_lints ( lints . iter ( ) ) ,
99
98
) ;
100
99
101
100
let content = gen_deprecated_lints_test ( deprecated_lints) ;
@@ -106,10 +105,9 @@ fn generate_lint_files(
106
105
}
107
106
108
107
pub fn print_lints ( ) {
109
- let ( lint_list, _, _) = gather_all ( ) ;
110
- let usable_lints = Lint :: usable_lints ( & lint_list) ;
111
- let usable_lint_count = usable_lints. len ( ) ;
112
- let grouped_by_lint_group = Lint :: by_lint_group ( usable_lints. into_iter ( ) ) ;
108
+ let ( lints, _, _) = gather_all ( ) ;
109
+ let lint_count = lints. len ( ) ;
110
+ let grouped_by_lint_group = Lint :: by_lint_group ( lints. into_iter ( ) ) ;
113
111
114
112
for ( lint_group, mut lints) in grouped_by_lint_group {
115
113
println ! ( "\n ## {lint_group}" ) ;
@@ -121,7 +119,7 @@ pub fn print_lints() {
121
119
}
122
120
}
123
121
124
- println ! ( "there are {usable_lint_count } lints" ) ;
122
+ println ! ( "there are {lint_count } lints" ) ;
125
123
}
126
124
127
125
/// Runs the `rename_lint` command.
@@ -527,22 +525,6 @@ impl Lint {
527
525
}
528
526
}
529
527
530
- /// Returns all non-deprecated lints and non-internal lints
531
- #[ must_use]
532
- fn usable_lints ( lints : & [ Self ] ) -> Vec < Self > {
533
- lints
534
- . iter ( )
535
- . filter ( |l| !l. group . starts_with ( "internal" ) )
536
- . cloned ( )
537
- . collect ( )
538
- }
539
-
540
- /// Returns all internal lints
541
- #[ must_use]
542
- fn internal_lints ( lints : & [ Self ] ) -> Vec < Self > {
543
- lints. iter ( ) . filter ( |l| l. group == "internal" ) . cloned ( ) . collect ( )
544
- }
545
-
546
528
/// Returns the lints in a `HashMap`, grouped by the different lint groups
547
529
#[ must_use]
548
530
fn by_lint_group ( lints : impl Iterator < Item = Self > ) -> HashMap < String , Vec < Self > > {
@@ -579,23 +561,14 @@ impl RenamedLint {
579
561
580
562
/// Generates the code for registering lints
581
563
#[ must_use]
582
- fn gen_declared_lints < ' a > (
583
- internal_lints : impl Iterator < Item = & ' a Lint > ,
584
- usable_lints : impl Iterator < Item = & ' a Lint > ,
585
- ) -> String {
586
- let mut details: Vec < _ > = internal_lints
587
- . map ( |l| ( false , & l. module , l. name . to_uppercase ( ) ) )
588
- . chain ( usable_lints. map ( |l| ( true , & l. module , l. name . to_uppercase ( ) ) ) )
589
- . collect ( ) ;
564
+ fn gen_declared_lints < ' a > ( lints : impl Iterator < Item = & ' a Lint > ) -> String {
565
+ let mut details: Vec < _ > = lints. map ( |l| ( & l. module , l. name . to_uppercase ( ) ) ) . collect ( ) ;
590
566
details. sort_unstable ( ) ;
591
567
592
568
let mut output = GENERATED_FILE_COMMENT . to_string ( ) ;
593
569
output. push_str ( "pub static LINTS: &[&crate::LintInfo] = &[\n " ) ;
594
570
595
- for ( is_public, module_name, lint_name) in details {
596
- if !is_public {
597
- output. push_str ( " #[cfg(feature = \" internal\" )]\n " ) ;
598
- }
571
+ for ( module_name, lint_name) in details {
599
572
let _: fmt:: Result = writeln ! ( output, " crate::{module_name}::{lint_name}_INFO," ) ;
600
573
}
601
574
output. push_str ( "];\n " ) ;
@@ -936,41 +909,6 @@ mod tests {
936
909
assert_eq ! ( expected, result) ;
937
910
}
938
911
939
- #[ test]
940
- fn test_usable_lints ( ) {
941
- let lints = vec ! [
942
- Lint :: new(
943
- "should_assert_eq2" ,
944
- "Not Deprecated" ,
945
- "\" abc\" " ,
946
- "module_name" ,
947
- Range :: default ( ) ,
948
- ) ,
949
- Lint :: new(
950
- "should_assert_eq2" ,
951
- "internal" ,
952
- "\" abc\" " ,
953
- "module_name" ,
954
- Range :: default ( ) ,
955
- ) ,
956
- Lint :: new(
957
- "should_assert_eq2" ,
958
- "internal_style" ,
959
- "\" abc\" " ,
960
- "module_name" ,
961
- Range :: default ( ) ,
962
- ) ,
963
- ] ;
964
- let expected = vec ! [ Lint :: new(
965
- "should_assert_eq2" ,
966
- "Not Deprecated" ,
967
- "\" abc\" " ,
968
- "module_name" ,
969
- Range :: default ( ) ,
970
- ) ] ;
971
- assert_eq ! ( expected, Lint :: usable_lints( & lints) ) ;
972
- }
973
-
974
912
#[ test]
975
913
fn test_by_lint_group ( ) {
976
914
let lints = vec ! [
0 commit comments