Merge pull request #701 from mcarton/fix-700

Fix ICE with match_def_path
This commit is contained in:
Martin Carton 2016-02-22 20:04:31 +01:00
commit f38be64afc
2 changed files with 14 additions and 1 deletions

View file

@ -133,8 +133,12 @@ pub fn in_external_macro<T: LintContext>(cx: &T, span: Span) -> bool {
/// ```
pub fn match_def_path(cx: &LateContext, def_id: DefId, path: &[&str]) -> bool {
cx.tcx.with_path(def_id, |iter| {
iter.zip(path)
let mut len = 0;
iter.inspect(|_| len += 1)
.zip(path)
.all(|(nm, p)| nm.name().as_str() == *p)
&& len == path.len()
})
}

9
tests/run-pass/ice-700.rs Executable file
View file

@ -0,0 +1,9 @@
#![feature(plugin)]
#![plugin(clippy)]
#![deny(clippy)]
fn core() {}
fn main() {
core();
}