fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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