From f901a61c4443c8cbc92c555b122f3435e41c9a30 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 6 Feb 2020 21:28:50 +0700 Subject: [PATCH] dev: Make UpdateMode a copy type --- clippy_dev/src/main.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/clippy_dev/src/main.rs b/clippy_dev/src/main.rs index 7369db1f078d..403aa634c34f 100644 --- a/clippy_dev/src/main.rs +++ b/clippy_dev/src/main.rs @@ -8,7 +8,7 @@ mod fmt; mod new_lint; mod stderr_length_check; -#[derive(PartialEq)] +#[derive(Clone, Copy, PartialEq)] enum UpdateMode { Check, Change, @@ -113,9 +113,9 @@ fn main() { if matches.is_present("print-only") { print_lints(); } else if matches.is_present("check") { - update_lints(&UpdateMode::Check); + update_lints(UpdateMode::Check); } else { - update_lints(&UpdateMode::Change); + update_lints(UpdateMode::Change); } }, ("new_lint", Some(matches)) => { @@ -124,7 +124,7 @@ fn main() { matches.value_of("name"), matches.value_of("category"), ) { - Ok(_) => update_lints(&UpdateMode::Change), + Ok(_) => update_lints(UpdateMode::Change), Err(e) => eprintln!("Unable to create lint: {}", e), } }, @@ -161,7 +161,7 @@ fn print_lints() { } #[allow(clippy::too_many_lines)] -fn update_lints(update_mode: &UpdateMode) { +fn update_lints(update_mode: UpdateMode) { let lint_list: Vec = gather_all().collect(); let usable_lints: Vec = Lint::usable_lints(lint_list.clone().into_iter()).collect(); @@ -175,7 +175,7 @@ fn update_lints(update_mode: &UpdateMode) { "begin lint list", "end lint list", false, - update_mode == &UpdateMode::Change, + update_mode == UpdateMode::Change, || { format!( "pub const ALL_LINTS: [Lint; {}] = {:#?};", @@ -194,7 +194,7 @@ fn update_lints(update_mode: &UpdateMode) { r#"\[There are \d+ lints included in this crate!\]\(https://rust-lang.github.io/rust-clippy/master/index.html\)"#, "", true, - update_mode == &UpdateMode::Change, + update_mode == UpdateMode::Change, || { vec![ format!("[There are {} lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)", lint_count) @@ -207,7 +207,7 @@ fn update_lints(update_mode: &UpdateMode) { "", "", false, - update_mode == &UpdateMode::Change, + update_mode == UpdateMode::Change, || gen_changelog_lint_list(lint_list.clone()), ) .changed; @@ -217,7 +217,7 @@ fn update_lints(update_mode: &UpdateMode) { "begin deprecated lints", "end deprecated lints", false, - update_mode == &UpdateMode::Change, + update_mode == UpdateMode::Change, || gen_deprecated(&lint_list), ) .changed; @@ -227,7 +227,7 @@ fn update_lints(update_mode: &UpdateMode) { "begin register lints", "end register lints", false, - update_mode == &UpdateMode::Change, + update_mode == UpdateMode::Change, || gen_register_lint_list(&lint_list), ) .changed; @@ -237,7 +237,7 @@ fn update_lints(update_mode: &UpdateMode) { "begin lints modules", "end lints modules", false, - update_mode == &UpdateMode::Change, + update_mode == UpdateMode::Change, || gen_modules_list(lint_list.clone()), ) .changed; @@ -248,7 +248,7 @@ fn update_lints(update_mode: &UpdateMode) { r#"store.register_group\(true, "clippy::all""#, r#"\]\);"#, false, - update_mode == &UpdateMode::Change, + update_mode == UpdateMode::Change, || { // clippy::all should only include the following lint groups: let all_group_lints = usable_lints @@ -271,13 +271,13 @@ fn update_lints(update_mode: &UpdateMode) { &format!("store.register_group\\(true, \"clippy::{}\"", lint_group), r#"\]\);"#, false, - update_mode == &UpdateMode::Change, + update_mode == UpdateMode::Change, || gen_lint_group_list(lints.clone()), ) .changed; } - if update_mode == &UpdateMode::Check && file_change { + if update_mode == UpdateMode::Check && file_change { println!( "Not all lints defined properly. \ Please run `cargo dev update_lints` to make sure all lints are defined properly."