diff options
| author | Michael Wright <mikerite@lavabit.com> | 2021-10-09 05:58:05 +0200 |
|---|---|---|
| committer | Michael Wright <mikerite@lavabit.com> | 2021-10-09 05:58:05 +0200 |
| commit | b8782257ae54674101b08caeee59c0d51ff760c6 (patch) | |
| tree | 442879a515ca27c6f1d45d98674a35d802f70de8 | |
| parent | da76c06209451fa01d5248374869b689116ae05e (diff) | |
| download | rust-b8782257ae54674101b08caeee59c0d51ff760c6.tar.gz rust-b8782257ae54674101b08caeee59c0d51ff760c6.zip | |
Fix `clippy::too-many-arguments` violation
| -rw-r--r-- | clippy_dev/src/new_lint.rs | 46 |
1 files changed, 14 insertions, 32 deletions
diff --git a/clippy_dev/src/new_lint.rs b/clippy_dev/src/new_lint.rs index ebbe26c46f7..50297efde21 100644 --- a/clippy_dev/src/new_lint.rs +++ b/clippy_dev/src/new_lint.rs @@ -45,26 +45,7 @@ pub fn create(pass: Option<&str>, lint_name: Option<&str>, category: Option<&str } fn create_lint(lint: &LintData<'_>, enable_msrv: bool) -> io::Result<()> { - let (pass_type, pass_lifetimes, pass_import, context_import) = match lint.pass { - "early" => ("EarlyLintPass", "", "use rustc_ast::ast::*;", "EarlyContext"), - "late" => ("LateLintPass", "<'_>", "use rustc_hir::*;", "LateContext"), - _ => { - unreachable!("`pass_type` should only ever be `early` or `late`!"); - }, - }; - - let camel_case_name = to_camel_case(lint.name); - let lint_contents = get_lint_file_contents( - lint.pass, - pass_type, - pass_lifetimes, - lint.name, - &camel_case_name, - lint.category, - pass_import, - context_import, - enable_msrv, - ); + let lint_contents = get_lint_file_contents(lint, enable_msrv); let lint_path = format!("clippy_lints/src/{}.rs", lint.name); write_file(lint.project_root.join(&lint_path), lint_contents.as_bytes()) @@ -156,20 +137,21 @@ publish = false ) } -fn get_lint_file_contents( - pass_name: &str, - pass_type: &str, - pass_lifetimes: &str, - lint_name: &str, - camel_case_name: &str, - category: &str, - pass_import: &str, - context_import: &str, - enable_msrv: bool, -) -> String { +fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String { let mut result = String::new(); - let name_camel = camel_case_name; + let (pass_type, pass_lifetimes, pass_import, context_import) = match lint.pass { + "early" => ("EarlyLintPass", "", "use rustc_ast::ast::*;", "EarlyContext"), + "late" => ("LateLintPass", "<'_>", "use rustc_hir::*;", "LateContext"), + _ => { + unreachable!("`pass_type` should only ever be `early` or `late`!"); + }, + }; + + let lint_name = lint.name; + let pass_name = lint.pass; + let category = lint.category; + let name_camel = to_camel_case(lint.name); let name_upper = lint_name.to_uppercase(); result.push_str(&if enable_msrv { |
