Skip to content

Commit d9c24d1

Browse files
committed
Auto merge of #11169 - y21:new_lint_unelide_lifetimes, r=xFrednet
don't hide lifetimes for `LateContext` Running `cargo dev new_lint --type methods` creates the lint file with hidden lifetimes for the `LateContext` parameter (i.e. `&LateContext`, when it should be `&LateContext<'_>`). This is already warned on with `#![warn(rust_2018_idioms)]`, so clippy should not use hidden lifetimes changelog: none
2 parents 1d33469 + 498db80 commit d9c24d1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

clippy_dev/src/new_lint.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ fn create_lint_for_ty(lint: &LintData<'_>, enable_msrv: bool, ty: &str) -> io::R
358358

359359
let mod_file_path = ty_dir.join("mod.rs");
360360
let context_import = setup_mod_file(&mod_file_path, lint)?;
361+
let pass_lifetimes = match context_import {
362+
"LateContext" => "<'_>",
363+
_ => "",
364+
};
361365

362366
let name_upper = lint.name.to_uppercase();
363367
let mut lint_file_contents = String::new();
@@ -372,7 +376,7 @@ fn create_lint_for_ty(lint: &LintData<'_>, enable_msrv: bool, ty: &str) -> io::R
372376
use super::{name_upper};
373377
374378
// TODO: Adjust the parameters as necessary
375-
pub(super) fn check(cx: &{context_import}, msrv: &Msrv) {{
379+
pub(super) fn check(cx: &{context_import}{pass_lifetimes}, msrv: &Msrv) {{
376380
if !msrv.meets(todo!("Add a new entry in `clippy_utils/src/msrvs`")) {{
377381
return;
378382
}}
@@ -389,7 +393,7 @@ fn create_lint_for_ty(lint: &LintData<'_>, enable_msrv: bool, ty: &str) -> io::R
389393
use super::{name_upper};
390394
391395
// TODO: Adjust the parameters as necessary
392-
pub(super) fn check(cx: &{context_import}) {{
396+
pub(super) fn check(cx: &{context_import}{pass_lifetimes}) {{
393397
todo!();
394398
}}
395399
"#

0 commit comments

Comments
 (0)