From 73f2ba5ded4452839d2025f6fe6eb0818685fa2a Mon Sep 17 00:00:00 2001 From: Jonathan Goodman Date: Tue, 6 Feb 2018 12:22:34 -0600 Subject: [PATCH] don't suggest eliding 'static on associated consts --- clippy_lints/src/const_static_lifetime.rs | 18 +----------------- tests/ui/const_static_lifetime.stderr | 20 +------------------- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/clippy_lints/src/const_static_lifetime.rs b/clippy_lints/src/const_static_lifetime.rs index 2872cb12729..66a1634ebce 100644 --- a/clippy_lints/src/const_static_lifetime.rs +++ b/clippy_lints/src/const_static_lifetime.rs @@ -87,21 +87,5 @@ fn check_item(&mut self, cx: &EarlyContext, item: &Item) { } } - 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) } diff --git a/tests/ui/const_static_lifetime.stderr b/tests/ui/const_static_lifetime.stderr index b1059d2ef01..db33744c7a9 100644 --- a/tests/ui/const_static_lifetime.stderr +++ b/tests/ui/const_static_lifetime.stderr @@ -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