]> git.lizzy.rs Git - rust.git/commitdiff
enum detection by style convention
authorOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>
Fri, 2 Dec 2016 18:30:00 +0000 (19:30 +0100)
committerOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>
Fri, 2 Dec 2016 18:30:00 +0000 (19:30 +0100)
clippy_lints/src/enum_glob_use.rs

index 7992c4966b2a34cbddd1cae6316df09182e9d1b7..a47426b03ef5604dc043756fa77ed238086e31ea 100644 (file)
@@ -1,7 +1,6 @@
 //! lint on `use`ing all variants of an enum
 
 use rustc::hir::*;
-use rustc::hir::def::Def;
 use rustc::lint::{LateLintPass, LintPass, LateContext, LintArray};
 use syntax::ast::NodeId;
 use syntax::codemap::Span;
@@ -50,7 +49,8 @@ fn lint_item(&self, cx: &LateContext, item: &Item) {
         if let ItemUse(ref path, UseKind::Glob) = item.node {
             // FIXME: ask jseyfried why the qpath.def for `use std::cmp::Ordering::*;`
             // extracted through `ItemUse(ref qpath, UseKind::Glob)` is a `Mod` and not an `Enum`
-            if let Def::Enum(_) = path.def {
+            //if let Def::Enum(_) = path.def {
+            if path.segments.last().and_then(|seg| seg.name.as_str().chars().next()).map_or(false, char::is_uppercase) {
                 span_lint(cx, ENUM_GLOB_USE, item.span, "don't use glob imports for enum variants");
             }
         }