RS.CLIPPY.NEEDLESS_LIFETIMES
Would allow omitting them
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: needless_lifetimes. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for lifetime annotations which can be removed by relying on lifetime elision.
Why is this bad?
The additional lifetimes make the code look more complicated, while there is nothing out of the ordinary going on. Removing them leads to more readable code.
Known problems
This lint ignores functions with where clauses that reference
lifetimes to prevent false positives.
Example
// Unnecessary lifetime annotations
fn in_and_out<\'a>(x: &\'a u8, y: u8) -> &\'a u8 {
x
}
Use instead:
fn elided(x: &u8, y: u8) -> &u8 {
x
}