Fix dogfood and pedantic lints

This commit is contained in:
Philipp Hansch 2018-10-31 21:54:30 +01:00
parent 64bd658516
commit 7e027217f1
No known key found for this signature in database
GPG key ID: B6FA06A6E0E2665B
2 changed files with 21 additions and 19 deletions

View file

@ -78,26 +78,28 @@ pub fn gen_changelog_lint_list(lints: Vec<Lint>) -> Vec<String> {
lint_list_sorted.sort_by_key(|l| l.name.clone()); lint_list_sorted.sort_by_key(|l| l.name.clone());
lint_list_sorted lint_list_sorted
.iter() .iter()
.filter(|l| !l.is_internal()) .filter_map(|l| {
.map(|l| { if l.is_internal() {
format!("[`{}`]: {}#{}", l.name, DOCS_LINK.clone(), l.name) None
}) } else {
.collect() Some(format!("[`{}`]: {}#{}", l.name, DOCS_LINK.clone(), l.name))
}
}).collect()
} }
/// Generates the 'register_removed' code in `./clippy_lints/src/lib.rs`. /// Generates the `register_removed` code in `./clippy_lints/src/lib.rs`.
pub fn gen_deprecated(lints: Vec<Lint>) -> Vec<String> { pub fn gen_deprecated(lints: &[Lint]) -> Vec<String> {
lints.iter() lints.iter()
.filter(|l| l.deprecation.is_some()) .filter_map(|l| {
.map(|l| { l.clone().deprecation.and_then(|depr_text| {
format!( Some(
r#" store.register_removed( format!(
"{}", " store.register_removed(\n \"{}\",\n \"{}\",\n );",
"{}", l.name,
);"#, depr_text
l.name, )
l.deprecation.clone().unwrap() )
) })
}) })
.collect() .collect()
} }
@ -352,5 +354,5 @@ fn test_gen_deprecated() {
"has been superseeded by should_assert_eq2", "has been superseeded by should_assert_eq2",
);"#.to_string() );"#.to_string()
]; ];
assert_eq!(expected, gen_deprecated(lints)); assert_eq!(expected, gen_deprecated(&lints));
} }

View file

@ -88,6 +88,6 @@ fn update_lints() {
"begin deprecated lints", "begin deprecated lints",
"end deprecated lints", "end deprecated lints",
false, false,
|| { gen_deprecated(lint_list.clone()) } || { gen_deprecated(&lint_list) }
); );
} }