Skip to content

Commit 32fe476

Browse files
committed
Auto merge of #8625 - Jarcho:rename_lint, r=xFrednet
Add `cargo dev rename_lint` fixes #7799 changelog: None
2 parents ec46992 + b3de32b commit 32fe476

File tree

11 files changed

+646
-267
lines changed

11 files changed

+646
-267
lines changed

clippy_dev/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version = "0.0.1"
44
edition = "2021"
55

66
[dependencies]
7+
aho-corasick = "0.7"
78
clap = "2.33"
89
indoc = "1.0"
910
itertools = "0.10.1"

clippy_dev/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(let_chains)]
12
#![feature(let_else)]
23
#![feature(once_cell)]
34
#![feature(rustc_private)]

clippy_dev/src/main.rs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ fn main() {
1919
if matches.is_present("print-only") {
2020
update_lints::print_lints();
2121
} else if matches.is_present("check") {
22-
update_lints::run(update_lints::UpdateMode::Check);
22+
update_lints::update(update_lints::UpdateMode::Check);
2323
} else {
24-
update_lints::run(update_lints::UpdateMode::Change);
24+
update_lints::update(update_lints::UpdateMode::Change);
2525
}
2626
},
2727
("new_lint", Some(matches)) => {
@@ -31,7 +31,7 @@ fn main() {
3131
matches.value_of("category"),
3232
matches.is_present("msrv"),
3333
) {
34-
Ok(_) => update_lints::run(update_lints::UpdateMode::Change),
34+
Ok(_) => update_lints::update(update_lints::UpdateMode::Change),
3535
Err(e) => eprintln!("Unable to create lint: {}", e),
3636
}
3737
},
@@ -78,6 +78,12 @@ fn main() {
7878
let path = matches.value_of("path").unwrap();
7979
lint::run(path);
8080
},
81+
("rename_lint", Some(matches)) => {
82+
let old_name = matches.value_of("old_name").unwrap();
83+
let new_name = matches.value_of("new_name").unwrap_or(old_name);
84+
let uplift = matches.is_present("uplift");
85+
update_lints::rename(old_name, new_name, uplift);
86+
},
8187
_ => {},
8288
}
8389
}
@@ -279,5 +285,26 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
279285
.help("The path to a file or package directory to lint"),
280286
),
281287
)
288+
.subcommand(
289+
SubCommand::with_name("rename_lint")
290+
.about("Renames the given lint")
291+
.arg(
292+
Arg::with_name("old_name")
293+
.index(1)
294+
.required(true)
295+
.help("The name of the lint to rename"),
296+
)
297+
.arg(
298+
Arg::with_name("new_name")
299+
.index(2)
300+
.required_unless("uplift")
301+
.help("The new name of the lint"),
302+
)
303+
.arg(
304+
Arg::with_name("uplift")
305+
.long("uplift")
306+
.help("This lint will be uplifted into rustc"),
307+
),
308+
)
282309
.get_matches()
283310
}

0 commit comments

Comments
 (0)