mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-15 09:27:25 +00:00
Auto merge of #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
This commit is contained in:
commit
b6284f05b9
1 changed files with 3 additions and 1 deletions
|
@ -5,6 +5,7 @@
|
|||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
use clippy_dev::{bless, dogfood, fmt, lint, new_lint, serve, setup, update_lints};
|
||||
use indoc::indoc;
|
||||
use std::convert::Infallible;
|
||||
|
||||
fn main() {
|
||||
let matches = get_clap_config();
|
||||
|
@ -180,7 +181,8 @@ fn get_clap_config() -> ArgMatches {
|
|||
.short('n')
|
||||
.long("name")
|
||||
.help("Name of the new lint in snake case, ex: fn_too_long")
|
||||
.required(true),
|
||||
.required(true)
|
||||
.value_parser(|name: &str| Ok::<_, Infallible>(name.replace('-', "_"))),
|
||||
Arg::new("category")
|
||||
.short('c')
|
||||
.long("category")
|
||||
|
|
Loading…
Reference in a new issue