Skip to content

Commit 7e02721

Browse files
committed
Fix dogfood and pedantic lints
1 parent 64bd658 commit 7e02721

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

clippy_dev/src/lib.rs

+20-18
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,28 @@ pub fn gen_changelog_lint_list(lints: Vec<Lint>) -> Vec<String> {
7878
lint_list_sorted.sort_by_key(|l| l.name.clone());
7979
lint_list_sorted
8080
.iter()
81-
.filter(|l| !l.is_internal())
82-
.map(|l| {
83-
format!("[`{}`]: {}#{}", l.name, DOCS_LINK.clone(), l.name)
84-
})
85-
.collect()
81+
.filter_map(|l| {
82+
if l.is_internal() {
83+
None
84+
} else {
85+
Some(format!("[`{}`]: {}#{}", l.name, DOCS_LINK.clone(), l.name))
86+
}
87+
}).collect()
8688
}
8789

88-
/// Generates the 'register_removed' code in `./clippy_lints/src/lib.rs`.
89-
pub fn gen_deprecated(lints: Vec<Lint>) -> Vec<String> {
90+
/// Generates the `register_removed` code in `./clippy_lints/src/lib.rs`.
91+
pub fn gen_deprecated(lints: &[Lint]) -> Vec<String> {
9092
lints.iter()
91-
.filter(|l| l.deprecation.is_some())
92-
.map(|l| {
93-
format!(
94-
r#" store.register_removed(
95-
"{}",
96-
"{}",
97-
);"#,
98-
l.name,
99-
l.deprecation.clone().unwrap()
100-
)
93+
.filter_map(|l| {
94+
l.clone().deprecation.and_then(|depr_text| {
95+
Some(
96+
format!(
97+
" store.register_removed(\n \"{}\",\n \"{}\",\n );",
98+
l.name,
99+
depr_text
100+
)
101+
)
102+
})
101103
})
102104
.collect()
103105
}
@@ -352,5 +354,5 @@ fn test_gen_deprecated() {
352354
"has been superseeded by should_assert_eq2",
353355
);"#.to_string()
354356
];
355-
assert_eq!(expected, gen_deprecated(lints));
357+
assert_eq!(expected, gen_deprecated(&lints));
356358
}

clippy_dev/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,6 @@ fn update_lints() {
8888
"begin deprecated lints",
8989
"end deprecated lints",
9090
false,
91-
|| { gen_deprecated(lint_list.clone()) }
91+
|| { gen_deprecated(&lint_list) }
9292
);
9393
}

0 commit comments

Comments
 (0)