2023-04-20 09:37:15 -05:00
|
|
|
//@run-rustfix
|
2019-09-25 12:21:08 -05:00
|
|
|
|
|
|
|
#![allow(unused)]
|
|
|
|
|
2017-10-20 08:51:35 -05:00
|
|
|
#[derive(Debug)]
|
2022-03-27 07:41:09 -05:00
|
|
|
struct Foo;
|
2017-10-20 08:51:35 -05:00
|
|
|
|
|
|
|
const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static.
|
|
|
|
|
|
|
|
const VAR_TWO: &str = "Test constant #2"; // This line should not raise a warning.
|
|
|
|
|
|
|
|
const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static
|
|
|
|
|
|
|
|
const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static
|
|
|
|
|
|
|
|
const VAR_SIX: &'static u8 = &5;
|
|
|
|
|
|
|
|
const VAR_HEIGHT: &'static Foo = &Foo {};
|
|
|
|
|
2017-11-18 09:10:28 -06:00
|
|
|
const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR Consider removing 'static.
|
|
|
|
|
|
|
|
const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static.
|
|
|
|
|
|
|
|
const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static.
|
|
|
|
|
2019-06-11 14:32:38 -05:00
|
|
|
static STATIC_VAR_ONE: &'static str = "Test static #1"; // ERROR Consider removing 'static.
|
|
|
|
|
|
|
|
static STATIC_VAR_TWO: &str = "Test static #2"; // This line should not raise a warning.
|
|
|
|
|
|
|
|
static STATIC_VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static
|
|
|
|
|
|
|
|
static STATIC_VAR_SIX: &'static u8 = &5;
|
|
|
|
|
|
|
|
static STATIC_VAR_HEIGHT: &'static Foo = &Foo {};
|
|
|
|
|
|
|
|
static STATIC_VAR_SLICE: &'static [u8] = b"Test static #3"; // ERROR Consider removing 'static.
|
|
|
|
|
|
|
|
static STATIC_VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static.
|
|
|
|
|
|
|
|
static STATIC_VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static.
|
|
|
|
|
2022-11-30 20:29:48 -06:00
|
|
|
static mut STATIC_MUT_SLICE: &'static mut [u32] = &mut [0];
|
|
|
|
|
2017-10-20 08:51:35 -05:00
|
|
|
fn main() {
|
|
|
|
let false_positive: &'static str = "test";
|
2022-11-30 20:29:48 -06:00
|
|
|
|
|
|
|
unsafe {
|
|
|
|
STATIC_MUT_SLICE[0] = 0;
|
|
|
|
}
|
2017-10-20 08:51:35 -05:00
|
|
|
}
|
2018-02-02 01:03:21 -06:00
|
|
|
|
|
|
|
trait Bar {
|
|
|
|
const TRAIT_VAR: &'static str;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Foo {
|
|
|
|
const IMPL_VAR: &'static str = "var";
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Bar for Foo {
|
|
|
|
const TRAIT_VAR: &'static str = "foo";
|
|
|
|
}
|
2022-10-21 16:35:39 -05:00
|
|
|
|
2022-11-19 06:50:02 -06:00
|
|
|
#[clippy::msrv = "1.16"]
|
2022-10-21 16:35:39 -05:00
|
|
|
fn msrv_1_16() {
|
|
|
|
static V: &'static u8 = &16;
|
|
|
|
}
|
|
|
|
|
2022-11-19 06:50:02 -06:00
|
|
|
#[clippy::msrv = "1.17"]
|
2022-10-21 16:35:39 -05:00
|
|
|
fn msrv_1_17() {
|
|
|
|
static V: &'static u8 = &17;
|
|
|
|
}
|