diff options
| author | Philipp Hansch <dev@phansch.net> | 2018-10-31 21:54:30 +0100 |
|---|---|---|
| committer | Philipp Hansch <dev@phansch.net> | 2018-10-31 21:54:30 +0100 |
| commit | 7e027217f113b2feafd39b0d19500aa030f320d7 (patch) | |
| tree | 33331faa84aa98a5fe6a5b8e3fda011771c1cdcd /clippy_dev | |
| parent | 64bd658516d6a097c04295a3f90537d757c258bd (diff) | |
| download | rust-7e027217f113b2feafd39b0d19500aa030f320d7.tar.gz rust-7e027217f113b2feafd39b0d19500aa030f320d7.zip | |
Fix dogfood and pedantic lints
Diffstat (limited to 'clippy_dev')
| -rw-r--r-- | clippy_dev/src/lib.rs | 38 | ||||
| -rw-r--r-- | clippy_dev/src/main.rs | 2 |
2 files changed, 21 insertions, 19 deletions
diff --git a/clippy_dev/src/lib.rs b/clippy_dev/src/lib.rs index d2191d426ff..656a271aec9 100644 --- a/clippy_dev/src/lib.rs +++ b/clippy_dev/src/lib.rs @@ -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)); } diff --git a/clippy_dev/src/main.rs b/clippy_dev/src/main.rs index cf321dbbc02..887a4ab9328 100644 --- a/clippy_dev/src/main.rs +++ b/clippy_dev/src/main.rs @@ -88,6 +88,6 @@ fn update_lints() { "begin deprecated lints", "end deprecated lints", false, - || { gen_deprecated(lint_list.clone()) } + || { gen_deprecated(&lint_list) } ); } |
