Skip to content

Commit 637e92d

Browse files
krkflip1995
authored andcommitted
Rename const_static_lifetime to redundant_static_lifetime.
1 parent b38ce08 commit 637e92d

File tree

5 files changed

+37
-38
lines changed

5 files changed

+37
-38
lines changed

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,6 @@ All notable changes to this project will be documented in this file.
881881
[`cmp_owned`]: https://rust-lang.github.io/rust-clippy/master/index.html#cmp_owned
882882
[`cognitive_complexity`]: https://rust-lang.github.io/rust-clippy/master/index.html#cognitive_complexity
883883
[`collapsible_if`]: https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
884-
[`const_static_lifetime`]: https://rust-lang.github.io/rust-clippy/master/index.html#const_static_lifetime
885884
[`copy_iterator`]: https://rust-lang.github.io/rust-clippy/master/index.html#copy_iterator
886885
[`crosspointer_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#crosspointer_transmute
887886
[`dbg_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#dbg_macro
@@ -1068,6 +1067,7 @@ All notable changes to this project will be documented in this file.
10681067
[`redundant_field_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
10691068
[`redundant_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern
10701069
[`redundant_pattern_matching`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
1070+
[`redundant_static_lifetime`]: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetime
10711071
[`ref_in_deref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_in_deref
10721072
[`regex_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#regex_macro
10731073
[`replace_consts`]: https://rust-lang.github.io/rust-clippy/master/index.html#replace_consts
@@ -1088,7 +1088,6 @@ All notable changes to this project will be documented in this file.
10881088
[`single_match`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_match
10891089
[`single_match_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#single_match_else
10901090
[`slow_vector_initialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#slow_vector_initialization
1091-
[`static_static_lifetime`]: https://rust-lang.github.io/rust-clippy/master/index.html#static_static_lifetime
10921091
[`str_to_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#str_to_string
10931092
[`string_add`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_add
10941093
[`string_add_assign`]: https://rust-lang.github.io/rust-clippy/master/index.html#string_add_assign

clippy_lints/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ pub mod cargo_common_metadata;
157157
pub mod checked_conversions;
158158
pub mod cognitive_complexity;
159159
pub mod collapsible_if;
160-
pub mod const_static_lifetime;
161160
pub mod copies;
162161
pub mod copy_iterator;
163162
pub mod dbg_macro;
@@ -249,6 +248,7 @@ pub mod ranges;
249248
pub mod redundant_clone;
250249
pub mod redundant_field_names;
251250
pub mod redundant_pattern_matching;
251+
pub mod redundant_static_lifetime;
252252
pub mod reference;
253253
pub mod regex;
254254
pub mod replace_consts;
@@ -553,7 +553,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
553553
reg.register_late_lint_pass(box invalid_ref::InvalidRef);
554554
reg.register_late_lint_pass(box identity_conversion::IdentityConversion::default());
555555
reg.register_late_lint_pass(box types::ImplicitHasher);
556-
reg.register_early_lint_pass(box const_static_lifetime::StaticConst);
556+
reg.register_early_lint_pass(box redundant_static_lifetime::RedundantStaticLifetime);
557557
reg.register_late_lint_pass(box fallible_impl_from::FallibleImplFrom);
558558
reg.register_late_lint_pass(box replace_consts::ReplaceConsts);
559559
reg.register_late_lint_pass(box types::UnitArg);
@@ -686,7 +686,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
686686
bytecount::NAIVE_BYTECOUNT,
687687
cognitive_complexity::COGNITIVE_COMPLEXITY,
688688
collapsible_if::COLLAPSIBLE_IF,
689-
const_static_lifetime::CONST_STATIC_LIFETIME,
690689
copies::IFS_SAME_COND,
691690
copies::IF_SAME_THEN_ELSE,
692691
derive::DERIVE_HASH_XOR_EQ,
@@ -834,6 +833,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
834833
ranges::RANGE_ZIP_WITH_LEN,
835834
redundant_field_names::REDUNDANT_FIELD_NAMES,
836835
redundant_pattern_matching::REDUNDANT_PATTERN_MATCHING,
836+
redundant_static_lifetime::REDUNDANT_STATIC_LIFETIME,
837837
reference::DEREF_ADDROF,
838838
reference::REF_IN_DEREF,
839839
regex::INVALID_REGEX,
@@ -901,7 +901,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
901901
block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
902902
block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
903903
collapsible_if::COLLAPSIBLE_IF,
904-
const_static_lifetime::CONST_STATIC_LIFETIME,
905904
enum_variants::ENUM_VARIANT_NAMES,
906905
enum_variants::MODULE_INCEPTION,
907906
eq_op::OP_REF,
@@ -957,6 +956,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
957956
question_mark::QUESTION_MARK,
958957
redundant_field_names::REDUNDANT_FIELD_NAMES,
959958
redundant_pattern_matching::REDUNDANT_PATTERN_MATCHING,
959+
redundant_static_lifetime::REDUNDANT_STATIC_LIFETIME,
960960
regex::REGEX_MACRO,
961961
regex::TRIVIAL_REGEX,
962962
returns::LET_AND_RETURN,

clippy_lints/src/const_static_lifetime.rs renamed to clippy_lints/src/redundant_static_lifetime.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ declare_clippy_lint! {
2424
/// const FOO: &[(&str, &str, fn(&Bar) -> bool)] = &[...]
2525
/// static FOO: &[(&str, &str, fn(&Bar) -> bool)] = &[...]
2626
/// ```
27-
pub CONST_STATIC_LIFETIME,
27+
pub REDUNDANT_STATIC_LIFETIME,
2828
style,
2929
"Using explicit `'static` lifetime for constants or statics when elision rules would allow omitting them."
3030
}
3131

32-
declare_lint_pass!(StaticConst => [CONST_STATIC_LIFETIME]);
32+
declare_lint_pass!(RedundantStaticLifetime => [REDUNDANT_STATIC_LIFETIME]);
3333

34-
impl StaticConst {
34+
impl RedundantStaticLifetime {
3535
// Recursively visit types
3636
pub fn visit_type(&mut self, ty: &Ty, cx: &EarlyContext<'_>, reason: &str) {
3737
match ty.node {
@@ -53,7 +53,7 @@ impl StaticConst {
5353
if lifetime.ident.name == syntax::symbol::kw::StaticLifetime {
5454
let snip = snippet(cx, borrow_type.ty.span, "<type>");
5555
let sugg = format!("&{}", snip);
56-
span_lint_and_then(cx, CONST_STATIC_LIFETIME, lifetime.ident.span, reason, |db| {
56+
span_lint_and_then(cx, REDUNDANT_STATIC_LIFETIME, lifetime.ident.span, reason, |db| {
5757
db.span_suggestion(
5858
ty.span,
5959
"consider removing `'static`",
@@ -76,7 +76,7 @@ impl StaticConst {
7676
}
7777
}
7878

79-
impl EarlyLintPass for StaticConst {
79+
impl EarlyLintPass for RedundantStaticLifetime {
8080
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
8181
if !in_macro_or_desugar(item.span) {
8282
if let ItemKind::Const(ref var_type, _) = item.node {

tests/ui/const_static_lifetime.stderr renamed to tests/ui/redundant_static_lifetime.stderr

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,157 +1,157 @@
11
error: Constants have by default a `'static` lifetime
2-
--> $DIR/const_static_lifetime.rs:4:17
2+
--> $DIR/redundant_static_lifetime.rs:4:17
33
|
44
LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static.
55
| -^^^^^^^---- help: consider removing `'static`: `&str`
66
|
7-
= note: `-D clippy::const-static-lifetime` implied by `-D warnings`
7+
= note: `-D clippy::redundant-static-lifetime` implied by `-D warnings`
88

99
error: Constants have by default a `'static` lifetime
10-
--> $DIR/const_static_lifetime.rs:8:21
10+
--> $DIR/redundant_static_lifetime.rs:8:21
1111
|
1212
LL | const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static
1313
| -^^^^^^^---- help: consider removing `'static`: `&str`
1414

1515
error: Constants have by default a `'static` lifetime
16-
--> $DIR/const_static_lifetime.rs:10:32
16+
--> $DIR/redundant_static_lifetime.rs:10:32
1717
|
1818
LL | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static
1919
| -^^^^^^^---- help: consider removing `'static`: `&str`
2020

2121
error: Constants have by default a `'static` lifetime
22-
--> $DIR/const_static_lifetime.rs:10:47
22+
--> $DIR/redundant_static_lifetime.rs:10:47
2323
|
2424
LL | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static
2525
| -^^^^^^^---- help: consider removing `'static`: `&str`
2626

2727
error: Constants have by default a `'static` lifetime
28-
--> $DIR/const_static_lifetime.rs:12:18
28+
--> $DIR/redundant_static_lifetime.rs:12:18
2929
|
3030
LL | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static
3131
| -^^^^^^^------------------ help: consider removing `'static`: `&[&[&'static str]]`
3232

3333
error: Constants have by default a `'static` lifetime
34-
--> $DIR/const_static_lifetime.rs:12:30
34+
--> $DIR/redundant_static_lifetime.rs:12:30
3535
|
3636
LL | const VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static
3737
| -^^^^^^^---- help: consider removing `'static`: `&str`
3838

3939
error: Constants have by default a `'static` lifetime
40-
--> $DIR/const_static_lifetime.rs:14:17
40+
--> $DIR/redundant_static_lifetime.rs:14:17
4141
|
4242
LL | const VAR_SIX: &'static u8 = &5;
4343
| -^^^^^^^--- help: consider removing `'static`: `&u8`
4444

4545
error: Constants have by default a `'static` lifetime
46-
--> $DIR/const_static_lifetime.rs:16:29
46+
--> $DIR/redundant_static_lifetime.rs:16:29
4747
|
4848
LL | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])];
4949
| -^^^^^^^--------------- help: consider removing `'static`: `&[&'static str]`
5050

5151
error: Constants have by default a `'static` lifetime
52-
--> $DIR/const_static_lifetime.rs:16:39
52+
--> $DIR/redundant_static_lifetime.rs:16:39
5353
|
5454
LL | const VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])];
5555
| -^^^^^^^---- help: consider removing `'static`: `&str`
5656

5757
error: Constants have by default a `'static` lifetime
58-
--> $DIR/const_static_lifetime.rs:18:20
58+
--> $DIR/redundant_static_lifetime.rs:18:20
5959
|
6060
LL | const VAR_HEIGHT: &'static Foo = &Foo {};
6161
| -^^^^^^^---- help: consider removing `'static`: `&Foo`
6262

6363
error: Constants have by default a `'static` lifetime
64-
--> $DIR/const_static_lifetime.rs:20:19
64+
--> $DIR/redundant_static_lifetime.rs:20:19
6565
|
6666
LL | const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR Consider removing 'static.
6767
| -^^^^^^^----- help: consider removing `'static`: `&[u8]`
6868

6969
error: Constants have by default a `'static` lifetime
70-
--> $DIR/const_static_lifetime.rs:22:19
70+
--> $DIR/redundant_static_lifetime.rs:22:19
7171
|
7272
LL | const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static.
7373
| -^^^^^^^--------- help: consider removing `'static`: `&(u8, u8)`
7474

7575
error: Constants have by default a `'static` lifetime
76-
--> $DIR/const_static_lifetime.rs:24:19
76+
--> $DIR/redundant_static_lifetime.rs:24:19
7777
|
7878
LL | const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static.
7979
| -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]`
8080

8181
error: Statics have by default a `'static` lifetime
82-
--> $DIR/const_static_lifetime.rs:26:25
82+
--> $DIR/redundant_static_lifetime.rs:26:25
8383
|
8484
LL | static STATIC_VAR_ONE: &'static str = "Test static #1"; // ERROR Consider removing 'static.
8585
| -^^^^^^^---- help: consider removing `'static`: `&str`
8686

8787
error: Statics have by default a `'static` lifetime
88-
--> $DIR/const_static_lifetime.rs:30:29
88+
--> $DIR/redundant_static_lifetime.rs:30:29
8989
|
9090
LL | static STATIC_VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static
9191
| -^^^^^^^---- help: consider removing `'static`: `&str`
9292

9393
error: Statics have by default a `'static` lifetime
94-
--> $DIR/const_static_lifetime.rs:32:40
94+
--> $DIR/redundant_static_lifetime.rs:32:40
9595
|
9696
LL | static STATIC_VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static
9797
| -^^^^^^^---- help: consider removing `'static`: `&str`
9898

9999
error: Statics have by default a `'static` lifetime
100-
--> $DIR/const_static_lifetime.rs:32:55
100+
--> $DIR/redundant_static_lifetime.rs:32:55
101101
|
102102
LL | static STATIC_VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static
103103
| -^^^^^^^---- help: consider removing `'static`: `&str`
104104

105105
error: Statics have by default a `'static` lifetime
106-
--> $DIR/const_static_lifetime.rs:34:26
106+
--> $DIR/redundant_static_lifetime.rs:34:26
107107
|
108108
LL | static STATIC_VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static
109109
| -^^^^^^^------------------ help: consider removing `'static`: `&[&[&'static str]]`
110110

111111
error: Statics have by default a `'static` lifetime
112-
--> $DIR/const_static_lifetime.rs:34:38
112+
--> $DIR/redundant_static_lifetime.rs:34:38
113113
|
114114
LL | static STATIC_VAR_FIVE: &'static [&[&'static str]] = &[&["test"], &["other one"]]; // ERROR Consider removing 'static
115115
| -^^^^^^^---- help: consider removing `'static`: `&str`
116116

117117
error: Statics have by default a `'static` lifetime
118-
--> $DIR/const_static_lifetime.rs:36:25
118+
--> $DIR/redundant_static_lifetime.rs:36:25
119119
|
120120
LL | static STATIC_VAR_SIX: &'static u8 = &5;
121121
| -^^^^^^^--- help: consider removing `'static`: `&u8`
122122

123123
error: Statics have by default a `'static` lifetime
124-
--> $DIR/const_static_lifetime.rs:38:37
124+
--> $DIR/redundant_static_lifetime.rs:38:37
125125
|
126126
LL | static STATIC_VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])];
127127
| -^^^^^^^--------------- help: consider removing `'static`: `&[&'static str]`
128128

129129
error: Statics have by default a `'static` lifetime
130-
--> $DIR/const_static_lifetime.rs:38:47
130+
--> $DIR/redundant_static_lifetime.rs:38:47
131131
|
132132
LL | static STATIC_VAR_SEVEN: &[&(&str, &'static [&'static str])] = &[&("one", &["other one"])];
133133
| -^^^^^^^---- help: consider removing `'static`: `&str`
134134

135135
error: Statics have by default a `'static` lifetime
136-
--> $DIR/const_static_lifetime.rs:40:28
136+
--> $DIR/redundant_static_lifetime.rs:40:28
137137
|
138138
LL | static STATIC_VAR_HEIGHT: &'static Foo = &Foo {};
139139
| -^^^^^^^---- help: consider removing `'static`: `&Foo`
140140

141141
error: Statics have by default a `'static` lifetime
142-
--> $DIR/const_static_lifetime.rs:42:27
142+
--> $DIR/redundant_static_lifetime.rs:42:27
143143
|
144144
LL | static STATIC_VAR_SLICE: &'static [u8] = b"Test static #3"; // ERROR Consider removing 'static.
145145
| -^^^^^^^----- help: consider removing `'static`: `&[u8]`
146146

147147
error: Statics have by default a `'static` lifetime
148-
--> $DIR/const_static_lifetime.rs:44:27
148+
--> $DIR/redundant_static_lifetime.rs:44:27
149149
|
150150
LL | static STATIC_VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static.
151151
| -^^^^^^^--------- help: consider removing `'static`: `&(u8, u8)`
152152

153153
error: Statics have by default a `'static` lifetime
154-
--> $DIR/const_static_lifetime.rs:46:27
154+
--> $DIR/redundant_static_lifetime.rs:46:27
155155
|
156156
LL | static STATIC_VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static.
157157
| -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]`

0 commit comments

Comments
 (0)