]> git.lizzy.rs Git - rust.git/blob - tests/ui/redundant_static_lifetimes.rs
Move MSRV tests into the lint specific test files
[rust.git] / tests / ui / redundant_static_lifetimes.rs
1 // run-rustfix
2
3 #![feature(custom_inner_attributes)]
4 #![allow(unused)]
5
6 #[derive(Debug)]
7 struct Foo;
8
9 const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static.
10
11 const VAR_TWO: &str = "Test constant #2"; // This line should not raise a warning.
12
13 const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static
14
15 const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static
16
17 const VAR_SIX: &'static u8 = &5;
18
19 const VAR_HEIGHT: &'static Foo = &Foo {};
20
21 const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR Consider removing 'static.
22
23 const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static.
24
25 const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static.
26
27 static STATIC_VAR_ONE: &'static str = "Test static #1"; // ERROR Consider removing 'static.
28
29 static STATIC_VAR_TWO: &str = "Test static #2"; // This line should not raise a warning.
30
31 static STATIC_VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static
32
33 static STATIC_VAR_SIX: &'static u8 = &5;
34
35 static STATIC_VAR_HEIGHT: &'static Foo = &Foo {};
36
37 static STATIC_VAR_SLICE: &'static [u8] = b"Test static #3"; // ERROR Consider removing 'static.
38
39 static STATIC_VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static.
40
41 static STATIC_VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static.
42
43 fn main() {
44     let false_positive: &'static str = "test";
45 }
46
47 trait Bar {
48     const TRAIT_VAR: &'static str;
49 }
50
51 impl Foo {
52     const IMPL_VAR: &'static str = "var";
53 }
54
55 impl Bar for Foo {
56     const TRAIT_VAR: &'static str = "foo";
57 }
58
59 fn msrv_1_16() {
60     #![clippy::msrv = "1.16"]
61
62     static V: &'static u8 = &16;
63 }
64
65 fn msrv_1_17() {
66     #![clippy::msrv = "1.17"]
67
68     static V: &'static u8 = &17;
69 }