Skip to content

Commit b3de32b

Browse files
committed
Add rename_lint command
1 parent d5ef542 commit b3de32b

File tree

8 files changed

+523
-218
lines changed

8 files changed

+523
-218
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
@@ -18,9 +18,9 @@ fn main() {
1818
if matches.is_present("print-only") {
1919
update_lints::print_lints();
2020
} else if matches.is_present("check") {
21-
update_lints::run(update_lints::UpdateMode::Check);
21+
update_lints::update(update_lints::UpdateMode::Check);
2222
} else {
23-
update_lints::run(update_lints::UpdateMode::Change);
23+
update_lints::update(update_lints::UpdateMode::Change);
2424
}
2525
},
2626
("new_lint", Some(matches)) => {
@@ -30,7 +30,7 @@ fn main() {
3030
matches.value_of("category"),
3131
matches.is_present("msrv"),
3232
) {
33-
Ok(_) => update_lints::run(update_lints::UpdateMode::Change),
33+
Ok(_) => update_lints::update(update_lints::UpdateMode::Change),
3434
Err(e) => eprintln!("Unable to create lint: {}", e),
3535
}
3636
},
@@ -59,6 +59,12 @@ fn main() {
5959
let filename = matches.value_of("filename").unwrap();
6060
lint::run(filename);
6161
},
62+
("rename_lint", Some(matches)) => {
63+
let old_name = matches.value_of("old_name").unwrap();
64+
let new_name = matches.value_of("new_name").unwrap_or(old_name);
65+
let uplift = matches.is_present("uplift");
66+
update_lints::rename(old_name, new_name, uplift);
67+
},
6268
_ => {},
6369
}
6470
}
@@ -232,5 +238,26 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
232238
.help("The path to a file to lint"),
233239
),
234240
)
241+
.subcommand(
242+
SubCommand::with_name("rename_lint")
243+
.about("Renames the given lint")
244+
.arg(
245+
Arg::with_name("old_name")
246+
.index(1)
247+
.required(true)
248+
.help("The name of the lint to rename"),
249+
)
250+
.arg(
251+
Arg::with_name("new_name")
252+
.index(2)
253+
.required_unless("uplift")
254+
.help("The new name of the lint"),
255+
)
256+
.arg(
257+
Arg::with_name("uplift")
258+
.long("uplift")
259+
.help("This lint will be uplifted into rustc"),
260+
),
261+
)
235262
.get_matches()
236263
}

0 commit comments

Comments
 (0)