Add lint to detect lifetime parameters that could be replaced by 'static
#120344
Labels
A-lifetimes
Area: Lifetimes / regions
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
Code
Current output
Desired output
Rationale and extra context
In some cases lifetime parameters might as well be
'static
because of subtyping. Using a'static
lifetime can simplify the signature by avoiding generics and help teach beginners that the only reason this works is because of static promotion. Adding something about static promotion to the warning could also make sense. I'm not too happy with my "desired output".This is also related to the
unused_lifetimes
lint, but that doesn't catch this either and it's not exactly "unused".Credit goes to @estebank for the suggestion in #48998 (comment)
Other cases
No response
Rust Version
Anything else?
No response
The text was updated successfully, but these errors were encountered: