diff options
| author | bors <bors@rust-lang.org> | 2023-06-10 18:29:29 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-06-10 18:29:29 +0000 |
| commit | ff3b49cfcb7f226d2d8dd4ab9e36fa3363e46b96 (patch) | |
| tree | 177ecd4648979ec69bbb849be06f939add6341da | |
| parent | e986b6444ef7e3f9d5bb59785e697d747034b2ec (diff) | |
| parent | 46808be16f38c3c09e9b7af5d08e9b8abb7cab13 (diff) | |
| download | rust-ff3b49cfcb7f226d2d8dd4ab9e36fa3363e46b96.tar.gz rust-ff3b49cfcb7f226d2d8dd4ab9e36fa3363e46b96.zip | |
Auto merge of #10907 - Alexendoo:dev-new-lint-late-passes, r=Jarcho
Direct towards late passes in `cargo dev new_lint` changelog: none This would be the tooling part of #9311 - `--pass late` is now the default - It prints a message recommending the use of a late pass if you choose `--pass early`
| -rw-r--r-- | clippy_dev/src/main.rs | 4 | ||||
| -rw-r--r-- | clippy_dev/src/new_lint.rs | 12 |
2 files changed, 12 insertions, 4 deletions
diff --git a/clippy_dev/src/main.rs b/clippy_dev/src/main.rs index c03fbe9d275..97d6a8353a0 100644 --- a/clippy_dev/src/main.rs +++ b/clippy_dev/src/main.rs @@ -35,7 +35,7 @@ fn main() { }, Some(("new_lint", matches)) => { match new_lint::create( - matches.get_one::<String>("pass"), + matches.get_one::<String>("pass").unwrap(), matches.get_one::<String>("name"), matches.get_one::<String>("category").map(String::as_str), matches.get_one::<String>("type").map(String::as_str), @@ -176,7 +176,7 @@ fn get_clap_config() -> ArgMatches { .help("Specify whether the lint runs during the early or late pass") .value_parser(["early", "late"]) .conflicts_with("type") - .required_unless_present("type"), + .default_value("late"), Arg::new("name") .short('n') .long("name") diff --git a/clippy_dev/src/new_lint.rs b/clippy_dev/src/new_lint.rs index 13a27703427..f970a32726b 100644 --- a/clippy_dev/src/new_lint.rs +++ b/clippy_dev/src/new_lint.rs @@ -37,7 +37,7 @@ impl<T> Context for io::Result<T> { /// /// This function errors out if the files couldn't be created or written to. pub fn create( - pass: Option<&String>, + pass: &String, lint_name: Option<&String>, category: Option<&str>, mut ty: Option<&str>, @@ -49,7 +49,7 @@ pub fn create( } let lint = LintData { - pass: pass.map_or("", String::as_str), + pass, name: lint_name.expect("`name` argument is validated by clap"), category: category.expect("`category` argument is validated by clap"), ty, @@ -63,6 +63,14 @@ pub fn create( add_lint(&lint, msrv).context("Unable to add lint to clippy_lints/src/lib.rs")?; } + if pass == "early" { + println!( + "\n\ + NOTE: Use a late pass unless you need something specific from\ + an early pass, as they lack many features and utilities" + ); + } + Ok(()) } |
