From da679825e0d3b1dda22044b3ec9ec1612a4e26f0 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Thu, 2 Apr 2020 18:31:32 +0200 Subject: [PATCH] Get rid of Lint::is_internal method --- clippy_dev/src/lib.rs | 27 +++++---------------------- clippy_dev/src/update_lints.rs | 4 ++-- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/clippy_dev/src/lib.rs b/clippy_dev/src/lib.rs index b01112539..4531d9b39 100644 --- a/clippy_dev/src/lib.rs +++ b/clippy_dev/src/lib.rs @@ -63,7 +63,7 @@ impl Lint { /// Returns all non-deprecated lints and non-internal lints pub fn usable_lints(lints: impl Iterator) -> impl Iterator { - lints.filter(|l| l.deprecation.is_none() && !l.is_internal()) + lints.filter(|l| l.deprecation.is_none() && !l.group.starts_with("internal")) } /// Returns all internal lints (not `internal_warn` lints) @@ -76,11 +76,6 @@ impl Lint { pub fn by_lint_group(lints: impl Iterator) -> HashMap> { lints.map(|lint| (lint.group.to_string(), lint)).into_group_map() } - - #[must_use] - pub fn is_internal(&self) -> bool { - self.group.starts_with("internal") - } } /// Generates the Vec items for `register_lint_group` calls in `clippy_lints/src/lib.rs`. @@ -103,14 +98,8 @@ pub fn gen_lint_group_list(lints: &[Lint]) -> Vec { #[must_use] pub fn gen_modules_list(lints: &[Lint]) -> Vec { lints - .into_iter() - .filter_map(|l| { - if l.is_internal() || l.deprecation.is_some() { - None - } else { - Some(l.module.clone()) - } - }) + .iter() + .map(|l| &l.module) .unique() .map(|module| format!("pub mod {};", module)) .sorted() @@ -124,7 +113,7 @@ pub fn gen_changelog_lint_list(lints: &[Lint]) -> Vec { .iter() .sorted_by_key(|l| l.name.clone()) .filter_map(|l| { - if l.is_internal() { + if l.group.starts_with("internal") { None } else { Some(format!("[`{}`]: {}#{}", l.name, DOCS_LINK, l.name)) @@ -158,13 +147,7 @@ pub fn gen_register_lint_list(lints: &[Lint]) -> Vec { let post = " ]);".to_string(); let mut inner = lints .iter() - .filter_map(|l| { - if !l.is_internal() && l.deprecation.is_none() { - Some(format!(" &{}::{},", l.module, l.name.to_uppercase())) - } else { - None - } - }) + .map(|l| format!(" &{}::{},", l.module, l.name.to_uppercase())) .sorted() .collect::>(); inner.insert(0, pre); diff --git a/clippy_dev/src/update_lints.rs b/clippy_dev/src/update_lints.rs index d709e4892..be565700b 100644 --- a/clippy_dev/src/update_lints.rs +++ b/clippy_dev/src/update_lints.rs @@ -81,7 +81,7 @@ pub fn run(update_mode: UpdateMode) { "end register lints", false, update_mode == UpdateMode::Change, - || gen_register_lint_list(&lint_list), + || gen_register_lint_list(&usable_lints), ) .changed; @@ -91,7 +91,7 @@ pub fn run(update_mode: UpdateMode) { "end lints modules", false, update_mode == UpdateMode::Change, - || gen_modules_list(&lint_list), + || gen_modules_list(&usable_lints), ) .changed;