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