RS.CLIPPY.REDUNDANT_STATIC_LIFETIMES

Using explicit `'static` lifetime for constants or statics when elision rules 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: redundant_static_lifetimes. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for constants and statics with an explicit \'static lifetime.

Why is this bad?

Adding \'static to every reference can create very complicated types.

Example

const FOO: &\'static [(&\'static str, &\'static str, fn(&Bar) -> bool)] =
&[...]
static FOO: &\'static [(&\'static str, &\'static str, fn(&Bar) -> bool)] =
&[...]

This code can be rewritten as

 const FOO: &[(&str, &str, fn(&Bar) -> bool)] = &[...]
 static FOO: &[(&str, &str, fn(&Bar) -> bool)] = &[...]

Past names

  • const_static_lifetime

Configuration

  • msrv: The minimum rust version that the project supports. Defaults to the rust-version field in Cargo.toml

    (default: current version)