mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 23:24:24 +00:00
prevent panic in enum glob import lint if a crate's elements are glob imported
fixes #639
This commit is contained in:
parent
4d5cd7255d
commit
672beb4138
3 changed files with 14 additions and 4 deletions
|
@ -3,7 +3,7 @@
|
|||
use rustc::lint::{LateLintPass, LintPass, LateContext, LintArray, LintContext};
|
||||
use rustc_front::hir::*;
|
||||
use rustc::front::map::Node::NodeItem;
|
||||
use rustc::front::map::PathElem::PathName;
|
||||
use rustc::front::map::definitions::DefPathData;
|
||||
use rustc::middle::ty::TyEnum;
|
||||
use utils::span_lint;
|
||||
use syntax::codemap::Span;
|
||||
|
@ -49,9 +49,11 @@ impl EnumGlobUse {
|
|||
span_lint(cx, ENUM_GLOB_USE, item.span, "don't use glob imports for enum variants");
|
||||
}
|
||||
} else {
|
||||
if let Some(&PathName(_)) = cx.sess().cstore.item_path(def.def_id()).last() {
|
||||
if let TyEnum(..) = cx.sess().cstore.item_type(&cx.tcx, def.def_id()).ty.sty {
|
||||
span_lint(cx, ENUM_GLOB_USE, item.span, "don't use glob imports for enum variants");
|
||||
if let Some(dp) = cx.sess().cstore.def_path(def.def_id()).last() {
|
||||
if let DefPathData::Type(_) = dp.data {
|
||||
if let TyEnum(..) = cx.sess().cstore.item_type(&cx.tcx, def.def_id()).ty.sty {
|
||||
span_lint(cx, ENUM_GLOB_USE, item.span, "don't use glob imports for enum variants");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,5 +21,6 @@ fn run_mode(mode: &'static str) {
|
|||
|
||||
#[test]
|
||||
fn compile_test() {
|
||||
run_mode("run-pass");
|
||||
run_mode("compile-fail");
|
||||
}
|
||||
|
|
7
tests/run-pass/enum-glob-import-crate.rs
Normal file
7
tests/run-pass/enum-glob-import-crate.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
#![deny(clippy)]
|
||||
|
||||
use std::*;
|
||||
|
||||
fn main() { }
|
Loading…
Reference in a new issue