Skip to content

Commit 6bd0580

Browse files
committed
Auto merge of #5055 - krishna-veerareddy:fix-new-lint-generator-import, r=llogiq
Fix new lint generator import Fix `rustc_lint` import path and add lifetimes to `LateLintPass` in `new_lint` command. changelog: none
2 parents 8b72b72 + 9ebac16 commit 6bd0580

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

clippy_dev/src/new_lint.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ pub fn create(pass: Option<&str>, lint_name: Option<&str>, category: Option<&str
1111

1212
match open_files(lint_name) {
1313
Ok((mut test_file, mut lint_file)) => {
14-
let (pass_type, pass_import, context_import) = match pass {
15-
"early" => ("EarlyLintPass", "use syntax::ast::*;", "EarlyContext"),
16-
"late" => ("LateLintPass", "use rustc_hir::*;", "LateContext"),
14+
let (pass_type, pass_lifetimes, pass_import, context_import) = match pass {
15+
"early" => ("EarlyLintPass", "", "use syntax::ast::*;", "EarlyContext"),
16+
"late" => ("LateLintPass", "<'_, '_>", "use rustc_hir::*;", "LateContext"),
1717
_ => {
1818
unreachable!("`pass_type` should only ever be `early` or `late`!");
1919
},
@@ -31,6 +31,7 @@ pub fn create(pass: Option<&str>, lint_name: Option<&str>, category: Option<&str
3131
if let Err(e) = lint_file.write_all(
3232
get_lint_file_contents(
3333
pass_type,
34+
pass_lifetimes,
3435
lint_name,
3536
&camel_case_name,
3637
category,
@@ -125,14 +126,15 @@ fn main() {{
125126

126127
fn get_lint_file_contents(
127128
pass_type: &str,
129+
pass_lifetimes: &str,
128130
lint_name: &str,
129131
camel_case_name: &str,
130132
category: &str,
131133
pass_import: &str,
132134
context_import: &str,
133135
) -> String {
134136
format!(
135-
"use rustc::lint::{{LintArray, LintPass, {type}, {context_import}}};
137+
"use rustc_lint::{{LintArray, LintPass, {type}, {context_import}}};
136138
use rustc_session::{{declare_lint_pass, declare_tool_lint}};
137139
{pass_import}
138140
@@ -155,9 +157,10 @@ declare_clippy_lint! {{
155157
156158
declare_lint_pass!({name_camel} => [{name_upper}]);
157159
158-
impl {type} for {name_camel} {{}}
160+
impl {type}{lifetimes} for {name_camel} {{}}
159161
",
160162
type=pass_type,
163+
lifetimes=pass_lifetimes,
161164
name_upper=lint_name.to_uppercase(),
162165
name_camel=camel_case_name,
163166
category=category,

0 commit comments

Comments
 (0)