Open
Description
What it does
Given a function that returns a borrow to a lifetime that isn't used in any parameter, give and explanation and suggest removing the named lifetime and making it 'static
, as it is the only effective lifetime that will work:
fn foo<'a>() -> &'a str { todo!() }
Lint Name
hidden_static_lifetime
Category
suspicious, style, pedantic
Advantage
It makes the code easier to follow and is a good thing to teach users about.
Drawbacks
No response
Example
fn foo<'a>() -> &'a str { todo!() }
Could be written as:
fn foo() -> &'static str { todo!() }