Skip to content

Commit 9faa588

Browse files
authored
Rollup merge of rust-lang#101501 - Jarcho:tcx_lint_passes, r=davidtwco
Allow lint passes to be bound by `TyCtxt` This will allow storing things like `Ty<'tcx>` inside late lint passes. It's already possible to store various id types so they're already implicitly bound to a specific `TyCtxt`. r? rust-lang/compiler
2 parents c3db185 + abd3e7e commit 9faa588

File tree

2 files changed

+211
-209
lines changed

2 files changed

+211
-209
lines changed

clippy_dev/src/new_lint.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,17 @@ fn add_lint(lint: &LintData<'_>, enable_msrv: bool) -> io::Result<()> {
120120

121121
let new_lint = if enable_msrv {
122122
format!(
123-
"store.register_{lint_pass}_pass(move || Box::new({module_name}::{camel_name}::new(msrv)));\n ",
123+
"store.register_{lint_pass}_pass(move |{ctor_arg}| Box::new({module_name}::{camel_name}::new(msrv)));\n ",
124124
lint_pass = lint.pass,
125+
ctor_arg = if lint.pass == "late" { "_" } else { "" },
125126
module_name = lint.name,
126127
camel_name = to_camel_case(lint.name),
127128
)
128129
} else {
129130
format!(
130-
"store.register_{lint_pass}_pass(|| Box::new({module_name}::{camel_name}));\n ",
131+
"store.register_{lint_pass}_pass(|{ctor_arg}| Box::new({module_name}::{camel_name}));\n ",
131132
lint_pass = lint.pass,
133+
ctor_arg = if lint.pass == "late" { "_" } else { "" },
132134
module_name = lint.name,
133135
camel_name = to_camel_case(lint.name),
134136
)

0 commit comments

Comments
 (0)