Skip to content

Commit b6284f0

Browse files
committed
Auto merge of rust-lang#10817 - y21:validate-lint-name, r=flip1995
validate lint name in `clippy_dev` This PR adds a little bit of validation to `cargo dev new_lint`. I've had it happen a few times where I wanted to add a new lint, but forgot that lint names cannot contain `-`. If you try to do it anyway, `clippy_dev` will generate illegal syntax (like adding `mod test-lint;` to clippy_lints/src/lib.rs for the module declaration). Maybe having it error out early would be helpful to others too. changelog: none
2 parents 5187e92 + c70f2a2 commit b6284f0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

clippy_dev/src/main.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use clap::{Arg, ArgAction, ArgMatches, Command};
66
use clippy_dev::{bless, dogfood, fmt, lint, new_lint, serve, setup, update_lints};
77
use indoc::indoc;
8+
use std::convert::Infallible;
89

910
fn main() {
1011
let matches = get_clap_config();
@@ -180,7 +181,8 @@ fn get_clap_config() -> ArgMatches {
180181
.short('n')
181182
.long("name")
182183
.help("Name of the new lint in snake case, ex: fn_too_long")
183-
.required(true),
184+
.required(true)
185+
.value_parser(|name: &str| Ok::<_, Infallible>(name.replace('-', "_"))),
184186
Arg::new("category")
185187
.short('c')
186188
.long("category")

0 commit comments

Comments
 (0)