2019-09-25 17:21:08 +00:00
|
|
|
// run-rustfix
|
|
|
|
|
|
|
|
#![allow(unused)]
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
2022-03-27 12:41:09 +00:00
|
|
|
struct Foo;
|
2019-09-25 17:21:08 +00:00
|
|
|
|
|
|
|
const VAR_ONE: &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: &[&str] = &["one", "two"]; // ERROR Consider removing 'static
|
|
|
|
|
|
|
|
const VAR_FOUR: (&str, (&str, &str), &str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static
|
|
|
|
|
|
|
|
const VAR_SIX: &u8 = &5;
|
|
|
|
|
|
|
|
const VAR_HEIGHT: &Foo = &Foo {};
|
|
|
|
|
|
|
|
const VAR_SLICE: &[u8] = b"Test constant #1"; // ERROR Consider removing 'static.
|
|
|
|
|
|
|
|
const VAR_TUPLE: &(u8, u8) = &(1, 2); // ERROR Consider removing 'static.
|
|
|
|
|
|
|
|
const VAR_ARRAY: &[u8; 1] = b"T"; // ERROR Consider removing 'static.
|
|
|
|
|
|
|
|
static STATIC_VAR_ONE: &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: &[&str] = &["one", "two"]; // ERROR Consider removing 'static
|
|
|
|
|
|
|
|
static STATIC_VAR_SIX: &u8 = &5;
|
|
|
|
|
|
|
|
static STATIC_VAR_HEIGHT: &Foo = &Foo {};
|
|
|
|
|
|
|
|
static STATIC_VAR_SLICE: &[u8] = b"Test static #3"; // ERROR Consider removing 'static.
|
|
|
|
|
|
|
|
static STATIC_VAR_TUPLE: &(u8, u8) = &(1, 2); // ERROR Consider removing 'static.
|
|
|
|
|
|
|
|
static STATIC_VAR_ARRAY: &[u8; 1] = b"T"; // ERROR Consider removing 'static.
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let false_positive: &'static str = "test";
|
|
|
|
}
|
|
|
|
|
|
|
|
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 21:35:39 +00:00
|
|
|
|
2022-11-19 12:50:02 +00:00
|
|
|
#[clippy::msrv = "1.16"]
|
2022-10-21 21:35:39 +00:00
|
|
|
fn msrv_1_16() {
|
|
|
|
static V: &'static u8 = &16;
|
|
|
|
}
|
|
|
|
|
2022-11-19 12:50:02 +00:00
|
|
|
#[clippy::msrv = "1.17"]
|
2022-10-21 21:35:39 +00:00
|
|
|
fn msrv_1_17() {
|
|
|
|
static V: &u8 = &17;
|
|
|
|
}
|