Skip to content

Commit

Permalink
Merge pull request #2443 from goodmanjonathan/fix-2438
Browse files Browse the repository at this point in the history
Don't suggest eliding 'static on associated consts
  • Loading branch information
oli-obk authored Feb 6, 2018
2 parents b835877 + 73f2ba5 commit 81b2565
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
18 changes: 1 addition & 17 deletions clippy_lints/src/const_static_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,5 @@ impl EarlyLintPass for StaticConst {
}
}

fn check_trait_item(&mut self, cx: &EarlyContext, item: &TraitItem) {
if !in_macro(item.span) {
// Match only constants...
if let TraitItemKind::Const(ref var_type, _) = item.node {
self.visit_type(var_type, cx);
}
}
}

fn check_impl_item(&mut self, cx: &EarlyContext, item: &ImplItem) {
if !in_macro(item.span) {
// Match only constants...
if let ImplItemKind::Const(ref var_type, _) = item.node {
self.visit_type(var_type, cx);
}
}
}
// Don't check associated consts because `'static` cannot be elided on those (issue #2438)
}
20 changes: 1 addition & 19 deletions tests/ui/const_static_lifetime.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,5 @@ error: Constants have by default a `'static` lifetime
24 | const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static.
| -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]`

error: Constants have by default a `'static` lifetime
--> $DIR/const_static_lifetime.rs:40:23
|
40 | const TRAIT_VAR: &'static str;
| -^^^^^^^---- help: consider removing `'static`: `&str`

error: Constants have by default a `'static` lifetime
--> $DIR/const_static_lifetime.rs:44:22
|
44 | const IMPL_VAR: &'static str = "var";
| -^^^^^^^---- help: consider removing `'static`: `&str`

error: Constants have by default a `'static` lifetime
--> $DIR/const_static_lifetime.rs:48:23
|
48 | const TRAIT_VAR: &'static str = "foo";
| -^^^^^^^---- help: consider removing `'static`: `&str`

error: aborting due to 16 previous errors
error: aborting due to 13 previous errors

0 comments on commit 81b2565

Please sign in to comment.