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