]> git.lizzy.rs Git - rust.git/blob - src/docs/redundant_static_lifetimes.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / redundant_static_lifetimes.txt
1 ### What it does
2 Checks for constants and statics with an explicit `'static` lifetime.
3
4 ### Why is this bad?
5 Adding `'static` to every reference can create very
6 complicated types.
7
8 ### Example
9 ```
10 const FOO: &'static [(&'static str, &'static str, fn(&Bar) -> bool)] =
11 &[...]
12 static FOO: &'static [(&'static str, &'static str, fn(&Bar) -> bool)] =
13 &[...]
14 ```
15 This code can be rewritten as
16 ```
17  const FOO: &[(&str, &str, fn(&Bar) -> bool)] = &[...]
18  static FOO: &[(&str, &str, fn(&Bar) -> bool)] = &[...]
19 ```