Skip to content

Commit b878225

Browse files
author
Michael Wright
committed
Fix clippy::too-many-arguments violation
1 parent da76c06 commit b878225

File tree

1 file changed

+14
-32
lines changed

1 file changed

+14
-32
lines changed

clippy_dev/src/new_lint.rs

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,7 @@ pub fn create(pass: Option<&str>, lint_name: Option<&str>, category: Option<&str
4545
}
4646

4747
fn create_lint(lint: &LintData<'_>, enable_msrv: bool) -> io::Result<()> {
48-
let (pass_type, pass_lifetimes, pass_import, context_import) = match lint.pass {
49-
"early" => ("EarlyLintPass", "", "use rustc_ast::ast::*;", "EarlyContext"),
50-
"late" => ("LateLintPass", "<'_>", "use rustc_hir::*;", "LateContext"),
51-
_ => {
52-
unreachable!("`pass_type` should only ever be `early` or `late`!");
53-
},
54-
};
55-
56-
let camel_case_name = to_camel_case(lint.name);
57-
let lint_contents = get_lint_file_contents(
58-
lint.pass,
59-
pass_type,
60-
pass_lifetimes,
61-
lint.name,
62-
&camel_case_name,
63-
lint.category,
64-
pass_import,
65-
context_import,
66-
enable_msrv,
67-
);
48+
let lint_contents = get_lint_file_contents(lint, enable_msrv);
6849

6950
let lint_path = format!("clippy_lints/src/{}.rs", lint.name);
7051
write_file(lint.project_root.join(&lint_path), lint_contents.as_bytes())
@@ -156,20 +137,21 @@ publish = false
156137
)
157138
}
158139

159-
fn get_lint_file_contents(
160-
pass_name: &str,
161-
pass_type: &str,
162-
pass_lifetimes: &str,
163-
lint_name: &str,
164-
camel_case_name: &str,
165-
category: &str,
166-
pass_import: &str,
167-
context_import: &str,
168-
enable_msrv: bool,
169-
) -> String {
140+
fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
170141
let mut result = String::new();
171142

172-
let name_camel = camel_case_name;
143+
let (pass_type, pass_lifetimes, pass_import, context_import) = match lint.pass {
144+
"early" => ("EarlyLintPass", "", "use rustc_ast::ast::*;", "EarlyContext"),
145+
"late" => ("LateLintPass", "<'_>", "use rustc_hir::*;", "LateContext"),
146+
_ => {
147+
unreachable!("`pass_type` should only ever be `early` or `late`!");
148+
},
149+
};
150+
151+
let lint_name = lint.name;
152+
let pass_name = lint.pass;
153+
let category = lint.category;
154+
let name_camel = to_camel_case(lint.name);
173155
let name_upper = lint_name.to_uppercase();
174156

175157
result.push_str(&if enable_msrv {

0 commit comments

Comments
 (0)