about summary refs log tree commit diff
diff options
context:
space:
mode:
authorflip1995 <hello@philkrones.com>2020-04-02 18:20:23 +0200
committerflip1995 <hello@philkrones.com>2020-04-03 21:18:36 +0200
commitffb2e4123458e50202c02e63b9e044583c0fe79a (patch)
treea86bd3a5c73b9431d9347fd51054f9cb275502cb
parent7907abea272bbf97812683ce03a1ab9c22f0557b (diff)
downloadrust-ffb2e4123458e50202c02e63b9e044583c0fe79a.tar.gz
rust-ffb2e4123458e50202c02e63b9e044583c0fe79a.zip
Clean up update_lints
-rw-r--r--clippy_dev/src/lib.rs19
-rw-r--r--clippy_dev/src/update_lints.rs10
2 files changed, 14 insertions, 15 deletions
diff --git a/clippy_dev/src/lib.rs b/clippy_dev/src/lib.rs
index 83f60f15906..b01112539be 100644
--- a/clippy_dev/src/lib.rs
+++ b/clippy_dev/src/lib.rs
@@ -85,7 +85,7 @@ impl Lint {
 
 /// Generates the Vec items for `register_lint_group` calls in `clippy_lints/src/lib.rs`.
 #[must_use]
-pub fn gen_lint_group_list(lints: Vec<Lint>) -> Vec<String> {
+pub fn gen_lint_group_list(lints: &[Lint]) -> Vec<String> {
     lints
         .into_iter()
         .filter_map(|l| {
@@ -101,14 +101,14 @@ pub fn gen_lint_group_list(lints: Vec<Lint>) -> Vec<String> {
 
 /// Generates the `pub mod module_name` list in `clippy_lints/src/lib.rs`.
 #[must_use]
-pub fn gen_modules_list(lints: Vec<Lint>) -> Vec<String> {
+pub fn gen_modules_list(lints: &[Lint]) -> Vec<String> {
     lints
         .into_iter()
         .filter_map(|l| {
             if l.is_internal() || l.deprecation.is_some() {
                 None
             } else {
-                Some(l.module)
+                Some(l.module.clone())
             }
         })
         .unique()
@@ -119,11 +119,10 @@ pub fn gen_modules_list(lints: Vec<Lint>) -> Vec<String> {
 
 /// Generates the list of lint links at the bottom of the README
 #[must_use]
-pub fn gen_changelog_lint_list(lints: Vec<Lint>) -> Vec<String> {
-    let mut lint_list_sorted: Vec<Lint> = lints;
-    lint_list_sorted.sort_by_key(|l| l.name.clone());
-    lint_list_sorted
+pub fn gen_changelog_lint_list(lints: &[Lint]) -> Vec<String> {
+    lints
         .iter()
+        .sorted_by_key(|l| l.name.clone())
         .filter_map(|l| {
             if l.is_internal() {
                 None
@@ -475,7 +474,7 @@ fn test_gen_changelog_lint_list() {
         format!("[`should_assert_eq`]: {}#should_assert_eq", DOCS_LINK.to_string()),
         format!("[`should_assert_eq2`]: {}#should_assert_eq2", DOCS_LINK.to_string()),
     ];
-    assert_eq!(expected, gen_changelog_lint_list(lints));
+    assert_eq!(expected, gen_changelog_lint_list(&lints));
 }
 
 #[test]
@@ -525,7 +524,7 @@ fn test_gen_modules_list() {
         "pub mod another_module;".to_string(),
         "pub mod module_name;".to_string(),
     ];
-    assert_eq!(expected, gen_modules_list(lints));
+    assert_eq!(expected, gen_modules_list(&lints));
 }
 
 #[test]
@@ -541,5 +540,5 @@ fn test_gen_lint_group_list() {
         "        LintId::of(&module_name::INTERNAL),".to_string(),
         "        LintId::of(&module_name::SHOULD_ASSERT_EQ),".to_string(),
     ];
-    assert_eq!(expected, gen_lint_group_list(lints));
+    assert_eq!(expected, gen_lint_group_list(&lints));
 }
diff --git a/clippy_dev/src/update_lints.rs b/clippy_dev/src/update_lints.rs
index d30d6f97a2f..d709e4892fe 100644
--- a/clippy_dev/src/update_lints.rs
+++ b/clippy_dev/src/update_lints.rs
@@ -61,7 +61,7 @@ pub fn run(update_mode: UpdateMode) {
         "<!-- end autogenerated links to lint list -->",
         false,
         update_mode == UpdateMode::Change,
-        || gen_changelog_lint_list(lint_list.clone()),
+        || gen_changelog_lint_list(&lint_list),
     )
     .changed;
 
@@ -91,7 +91,7 @@ pub fn run(update_mode: UpdateMode) {
         "end lints modules",
         false,
         update_mode == UpdateMode::Change,
-        || gen_modules_list(lint_list.clone()),
+        || gen_modules_list(&lint_list),
     )
     .changed;
 
@@ -110,9 +110,9 @@ pub fn run(update_mode: UpdateMode) {
                 .filter(|l| {
                     l.group == "correctness" || l.group == "style" || l.group == "complexity" || l.group == "perf"
                 })
-                .collect();
+                .collect::<Vec<_>>();
 
-            gen_lint_group_list(all_group_lints)
+            gen_lint_group_list(&all_group_lints)
         },
     )
     .changed;
@@ -125,7 +125,7 @@ pub fn run(update_mode: UpdateMode) {
             r#"\]\);"#,
             false,
             update_mode == UpdateMode::Change,
-            || gen_lint_group_list(lints.clone()),
+            || gen_lint_group_list(&lints),
         )
         .changed;
     }