Skip to content

Commit 29c449e

Browse files
authored
Merge pull request #2578 from mikerite/fix_issue_2397_pr_2
Fix enum_glob_use false positives
2 parents b01b008 + 546d2fe commit 29c449e

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

clippy_lints/src/enum_glob_use.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! lint on `use`ing all variants of an enum
22
33
use rustc::hir::*;
4+
use rustc::hir::def::Def;
45
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
56
use syntax::ast::NodeId;
67
use syntax::codemap::Span;
@@ -12,8 +13,7 @@ use utils::span_lint;
1213
/// an enumeration variant, rather than importing variants.
1314
///
1415
/// **Known problems:** Old-style enumerations that prefix the variants are
15-
/// still around. May cause problems with modules that are not snake_case (see
16-
/// [#2397](https://github.com/rust-lang-nursery/rust-clippy/issues/2397))
16+
/// still around.
1717
///
1818
/// **Example:**
1919
/// ```rust
@@ -48,16 +48,13 @@ impl EnumGlobUse {
4848
return; // re-exports are fine
4949
}
5050
if let ItemUse(ref path, UseKind::Glob) = item.node {
51-
// FIXME: ask jseyfried why the qpath.def for `use std::cmp::Ordering::*;`
52-
// extracted through `ItemUse(ref qpath, UseKind::Glob)` is a `Mod` and not an
53-
// `Enum`
54-
// if let Def::Enum(_) = path.def {
55-
if path.segments
56-
.last()
57-
.and_then(|seg| seg.name.as_str().chars().next())
58-
.map_or(false, char::is_uppercase)
59-
{
60-
span_lint(cx, ENUM_GLOB_USE, item.span, "don't use glob imports for enum variants");
51+
if let Def::Enum(_) = path.def {
52+
span_lint(
53+
cx,
54+
ENUM_GLOB_USE,
55+
item.span,
56+
"don't use glob imports for enum variants",
57+
);
6158
}
6259
}
6360
}

tests/ui/enum_glob_use.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,10 @@ mod tests {
2323
use super::*;
2424
}
2525

26+
#[allow(non_snake_case)]
27+
mod CamelCaseName {
28+
}
29+
30+
use CamelCaseName::*;
31+
2632
fn main() {}

0 commit comments

Comments
 (0)