Skip to content

Commit ff3b49c

Browse files
committed
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`
2 parents e986b64 + 46808be commit ff3b49c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

clippy_dev/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn main() {
3535
},
3636
Some(("new_lint", matches)) => {
3737
match new_lint::create(
38-
matches.get_one::<String>("pass"),
38+
matches.get_one::<String>("pass").unwrap(),
3939
matches.get_one::<String>("name"),
4040
matches.get_one::<String>("category").map(String::as_str),
4141
matches.get_one::<String>("type").map(String::as_str),
@@ -176,7 +176,7 @@ fn get_clap_config() -> ArgMatches {
176176
.help("Specify whether the lint runs during the early or late pass")
177177
.value_parser(["early", "late"])
178178
.conflicts_with("type")
179-
.required_unless_present("type"),
179+
.default_value("late"),
180180
Arg::new("name")
181181
.short('n')
182182
.long("name")

clippy_dev/src/new_lint.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<T> Context for io::Result<T> {
3737
///
3838
/// This function errors out if the files couldn't be created or written to.
3939
pub fn create(
40-
pass: Option<&String>,
40+
pass: &String,
4141
lint_name: Option<&String>,
4242
category: Option<&str>,
4343
mut ty: Option<&str>,
@@ -49,7 +49,7 @@ pub fn create(
4949
}
5050

5151
let lint = LintData {
52-
pass: pass.map_or("", String::as_str),
52+
pass,
5353
name: lint_name.expect("`name` argument is validated by clap"),
5454
category: category.expect("`category` argument is validated by clap"),
5555
ty,
@@ -63,6 +63,14 @@ pub fn create(
6363
add_lint(&lint, msrv).context("Unable to add lint to clippy_lints/src/lib.rs")?;
6464
}
6565

66+
if pass == "early" {
67+
println!(
68+
"\n\
69+
NOTE: Use a late pass unless you need something specific from\
70+
an early pass, as they lack many features and utilities"
71+
);
72+
}
73+
6674
Ok(())
6775
}
6876

0 commit comments

Comments
 (0)