mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 03:38:29 +00:00
dev: Make UpdateMode a copy type
This commit is contained in:
parent
729f943c53
commit
344603afce
@ -8,7 +8,7 @@ mod fmt;
|
|||||||
mod new_lint;
|
mod new_lint;
|
||||||
mod stderr_length_check;
|
mod stderr_length_check;
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
enum UpdateMode {
|
enum UpdateMode {
|
||||||
Check,
|
Check,
|
||||||
Change,
|
Change,
|
||||||
@ -113,9 +113,9 @@ fn main() {
|
|||||||
if matches.is_present("print-only") {
|
if matches.is_present("print-only") {
|
||||||
print_lints();
|
print_lints();
|
||||||
} else if matches.is_present("check") {
|
} else if matches.is_present("check") {
|
||||||
update_lints(&UpdateMode::Check);
|
update_lints(UpdateMode::Check);
|
||||||
} else {
|
} else {
|
||||||
update_lints(&UpdateMode::Change);
|
update_lints(UpdateMode::Change);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
("new_lint", Some(matches)) => {
|
("new_lint", Some(matches)) => {
|
||||||
@ -124,7 +124,7 @@ fn main() {
|
|||||||
matches.value_of("name"),
|
matches.value_of("name"),
|
||||||
matches.value_of("category"),
|
matches.value_of("category"),
|
||||||
) {
|
) {
|
||||||
Ok(_) => update_lints(&UpdateMode::Change),
|
Ok(_) => update_lints(UpdateMode::Change),
|
||||||
Err(e) => eprintln!("Unable to create lint: {}", e),
|
Err(e) => eprintln!("Unable to create lint: {}", e),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -161,7 +161,7 @@ fn print_lints() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[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 lint_list: Vec<Lint> = gather_all().collect();
|
||||||
|
|
||||||
let usable_lints: Vec<Lint> = Lint::usable_lints(lint_list.clone().into_iter()).collect();
|
let usable_lints: Vec<Lint> = Lint::usable_lints(lint_list.clone().into_iter()).collect();
|
||||||
@ -175,7 +175,7 @@ fn update_lints(update_mode: &UpdateMode) {
|
|||||||
"begin lint list",
|
"begin lint list",
|
||||||
"end lint list",
|
"end lint list",
|
||||||
false,
|
false,
|
||||||
update_mode == &UpdateMode::Change,
|
update_mode == UpdateMode::Change,
|
||||||
|| {
|
|| {
|
||||||
format!(
|
format!(
|
||||||
"pub const ALL_LINTS: [Lint; {}] = {:#?};",
|
"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\)"#,
|
r#"\[There are \d+ lints included in this crate!\]\(https://rust-lang.github.io/rust-clippy/master/index.html\)"#,
|
||||||
"",
|
"",
|
||||||
true,
|
true,
|
||||||
update_mode == &UpdateMode::Change,
|
update_mode == UpdateMode::Change,
|
||||||
|| {
|
|| {
|
||||||
vec", lint_count)
|
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) {
|
|||||||
"<!-- begin autogenerated links to lint list -->",
|
"<!-- begin autogenerated links to lint list -->",
|
||||||
"<!-- end autogenerated links to lint list -->",
|
"<!-- end autogenerated links to lint list -->",
|
||||||
false,
|
false,
|
||||||
update_mode == &UpdateMode::Change,
|
update_mode == UpdateMode::Change,
|
||||||
|| gen_changelog_lint_list(lint_list.clone()),
|
|| gen_changelog_lint_list(lint_list.clone()),
|
||||||
)
|
)
|
||||||
.changed;
|
.changed;
|
||||||
@ -217,7 +217,7 @@ fn update_lints(update_mode: &UpdateMode) {
|
|||||||
"begin deprecated lints",
|
"begin deprecated lints",
|
||||||
"end deprecated lints",
|
"end deprecated lints",
|
||||||
false,
|
false,
|
||||||
update_mode == &UpdateMode::Change,
|
update_mode == UpdateMode::Change,
|
||||||
|| gen_deprecated(&lint_list),
|
|| gen_deprecated(&lint_list),
|
||||||
)
|
)
|
||||||
.changed;
|
.changed;
|
||||||
@ -227,7 +227,7 @@ fn update_lints(update_mode: &UpdateMode) {
|
|||||||
"begin register lints",
|
"begin register lints",
|
||||||
"end register lints",
|
"end register lints",
|
||||||
false,
|
false,
|
||||||
update_mode == &UpdateMode::Change,
|
update_mode == UpdateMode::Change,
|
||||||
|| gen_register_lint_list(&lint_list),
|
|| gen_register_lint_list(&lint_list),
|
||||||
)
|
)
|
||||||
.changed;
|
.changed;
|
||||||
@ -237,7 +237,7 @@ fn update_lints(update_mode: &UpdateMode) {
|
|||||||
"begin lints modules",
|
"begin lints modules",
|
||||||
"end lints modules",
|
"end lints modules",
|
||||||
false,
|
false,
|
||||||
update_mode == &UpdateMode::Change,
|
update_mode == UpdateMode::Change,
|
||||||
|| gen_modules_list(lint_list.clone()),
|
|| gen_modules_list(lint_list.clone()),
|
||||||
)
|
)
|
||||||
.changed;
|
.changed;
|
||||||
@ -248,7 +248,7 @@ fn update_lints(update_mode: &UpdateMode) {
|
|||||||
r#"store.register_group\(true, "clippy::all""#,
|
r#"store.register_group\(true, "clippy::all""#,
|
||||||
r#"\]\);"#,
|
r#"\]\);"#,
|
||||||
false,
|
false,
|
||||||
update_mode == &UpdateMode::Change,
|
update_mode == UpdateMode::Change,
|
||||||
|| {
|
|| {
|
||||||
// clippy::all should only include the following lint groups:
|
// clippy::all should only include the following lint groups:
|
||||||
let all_group_lints = usable_lints
|
let all_group_lints = usable_lints
|
||||||
@ -271,13 +271,13 @@ fn update_lints(update_mode: &UpdateMode) {
|
|||||||
&format!("store.register_group\\(true, \"clippy::{}\"", lint_group),
|
&format!("store.register_group\\(true, \"clippy::{}\"", lint_group),
|
||||||
r#"\]\);"#,
|
r#"\]\);"#,
|
||||||
false,
|
false,
|
||||||
update_mode == &UpdateMode::Change,
|
update_mode == UpdateMode::Change,
|
||||||
|| gen_lint_group_list(lints.clone()),
|
|| gen_lint_group_list(lints.clone()),
|
||||||
)
|
)
|
||||||
.changed;
|
.changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if update_mode == &UpdateMode::Check && file_change {
|
if update_mode == UpdateMode::Check && file_change {
|
||||||
println!(
|
println!(
|
||||||
"Not all lints defined properly. \
|
"Not all lints defined properly. \
|
||||||
Please run `cargo dev update_lints` to make sure all lints are defined properly."
|
Please run `cargo dev update_lints` to make sure all lints are defined properly."
|
||||||
|
Loading…
Reference in New Issue
Block a user