Skip to content

Commit af441b5

Browse files
committed
Rename active_lints to usable_lints
Because now `usable_lints` will also exclude internal lints.
1 parent eb683e6 commit af441b5

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

clippy_dev/src/lib.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ impl Lint {
5757
}
5858
}
5959

60-
/// Returns all non-deprecated lints
61-
pub fn active_lints(lints: impl Iterator<Item=Self>) -> impl Iterator<Item=Self> {
62-
lints.filter(|l| l.deprecation.is_none())
60+
/// Returns all non-deprecated lints and non-internal lints
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"))
6363
}
6464

6565
/// Returns the lints in a HashMap, grouped by the different lint groups
@@ -141,15 +141,17 @@ declare_deprecated_lint! {
141141
}
142142

143143
#[test]
144-
fn test_active_lints() {
144+
fn test_usable_lints() {
145145
let lints = vec![
146146
Lint::new("should_assert_eq", "Deprecated", "abc", Some("Reason"), "module_name"),
147-
Lint::new("should_assert_eq2", "Not Deprecated", "abc", None, "module_name")
147+
Lint::new("should_assert_eq2", "Not Deprecated", "abc", None, "module_name"),
148+
Lint::new("should_assert_eq2", "internal", "abc", None, "module_name"),
149+
Lint::new("should_assert_eq2", "internal_style", "abc", None, "module_name")
148150
];
149151
let expected = vec![
150152
Lint::new("should_assert_eq2", "Not Deprecated", "abc", None, "module_name")
151153
];
152-
assert_eq!(expected, Lint::active_lints(lints.into_iter()).collect::<Vec<Lint>>());
154+
assert_eq!(expected, Lint::usable_lints(lints.into_iter()).collect::<Vec<Lint>>());
153155
}
154156

155157
#[test]

clippy_dev/src/main.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ fn main() {
3737
}
3838

3939
fn print_lints() {
40-
let lint_list = gather_all().collect::<Vec<Lint>>();
41-
let grouped_by_lint_group = Lint::by_lint_group(&lint_list);
40+
let lint_list = gather_all();
41+
let usable_lints: Vec<Lint> = Lint::usable_lints(lint_list).collect();
42+
let lint_count = usable_lints.len();
43+
let grouped_by_lint_group = Lint::by_lint_group(&usable_lints);
4244

4345
for (lint_group, mut lints) in grouped_by_lint_group {
4446
if lint_group == "Deprecated" { continue; }
@@ -51,5 +53,5 @@ fn print_lints() {
5153
}
5254
}
5355

54-
println!("there are {} lints", Lint::active_lints(lint_list.into_iter()).count());
56+
println!("there are {} lints", lint_count);
5557
}

0 commit comments

Comments
 (0)