]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/redundant_static_lifetimes.rs
Rollup merge of #95820 - OliverMD:95150, r=lcnr
[rust.git] / src / tools / clippy / tests / ui / redundant_static_lifetimes.rs
1 // run-rustfix
2
3 #![allow(unused)]
4
5 #[derive(Debug)]
6 struct Foo;
7
8 const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static.
9
10 const VAR_TWO: &str = "Test constant #2"; // This line should not raise a warning.
11
12 const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static
13
14 const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static
15
16 const VAR_SIX: &'static u8 = &5;
17
18 const VAR_HEIGHT: &'static Foo = &Foo {};
19
20 const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR Consider removing 'static.
21
22 const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static.
23
24 const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static.
25
26 static STATIC_VAR_ONE: &'static str = "Test static #1"; // ERROR Consider removing 'static.
27
28 static STATIC_VAR_TWO: &str = "Test static #2"; // This line should not raise a warning.
29
30 static STATIC_VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static
31
32 static STATIC_VAR_SIX: &'static u8 = &5;
33
34 static STATIC_VAR_HEIGHT: &'static Foo = &Foo {};
35
36 static STATIC_VAR_SLICE: &'static [u8] = b"Test static #3"; // ERROR Consider removing 'static.
37
38 static STATIC_VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static.
39
40 static STATIC_VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static.
41
42 fn main() {
43     let false_positive: &'static str = "test";
44 }
45
46 trait Bar {
47     const TRAIT_VAR: &'static str;
48 }
49
50 impl Foo {
51     const IMPL_VAR: &'static str = "var";
52 }
53
54 impl Bar for Foo {
55     const TRAIT_VAR: &'static str = "foo";
56 }