mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-23 04:14:28 +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,7 +3,7 @@
|
|||||||
use rustc::lint::{LateLintPass, LintPass, LateContext, LintArray, LintContext};
|
use rustc::lint::{LateLintPass, LintPass, LateContext, LintArray, LintContext};
|
||||||
use rustc_front::hir::*;
|
use rustc_front::hir::*;
|
||||||
use rustc::front::map::Node::NodeItem;
|
use rustc::front::map::Node::NodeItem;
|
||||||
use rustc::front::map::PathElem::PathName;
|
use rustc::front::map::definitions::DefPathData;
|
||||||
use rustc::middle::ty::TyEnum;
|
use rustc::middle::ty::TyEnum;
|
||||||
use utils::span_lint;
|
use utils::span_lint;
|
||||||
use syntax::codemap::Span;
|
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");
|
span_lint(cx, ENUM_GLOB_USE, item.span, "don't use glob imports for enum variants");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if let Some(&PathName(_)) = cx.sess().cstore.item_path(def.def_id()).last() {
|
if let Some(dp) = cx.sess().cstore.def_path(def.def_id()).last() {
|
||||||
if let TyEnum(..) = cx.sess().cstore.item_type(&cx.tcx, def.def_id()).ty.sty {
|
if let DefPathData::Type(_) = dp.data {
|
||||||
span_lint(cx, ENUM_GLOB_USE, item.span, "don't use glob imports for enum variants");
|
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]
|
#[test]
|
||||||
fn compile_test() {
|
fn compile_test() {
|
||||||
|
run_mode("run-pass");
|
||||||
run_mode("compile-fail");
|
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 New Issue
Block a user