Skip to content

Commit

Permalink
dev: Make UpdateMode a copy type
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed Feb 7, 2020
1 parent 44af8ee commit f901a61
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions clippy_dev/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod fmt;
mod new_lint;
mod stderr_length_check;

#[derive(PartialEq)]
#[derive(Clone, Copy, PartialEq)]
enum UpdateMode {
Check,
Change,
Expand Down Expand Up @@ -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)) => {
Expand All @@ -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),
}
},
Expand Down Expand Up @@ -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<Lint> = gather_all().collect();

let usable_lints: Vec<Lint> = Lint::usable_lints(lint_list.clone().into_iter()).collect();
Expand All @@ -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; {}] = {:#?};",
Expand All @@ -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)
Expand All @@ -207,7 +207,7 @@ fn update_lints(update_mode: &UpdateMode) {
"<!-- begin autogenerated links to lint list -->",
"<!-- end autogenerated links to lint list -->",
false,
update_mode == &UpdateMode::Change,
update_mode == UpdateMode::Change,
|| gen_changelog_lint_list(lint_list.clone()),
)
.changed;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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."
Expand Down

0 comments on commit f901a61

Please sign in to comment.