From 3b783152ccff54f3bf1e54db424dc476e36b1b31 Mon Sep 17 00:00:00 2001
From: mcarton <cartonmartin+git@gmail.com>
Date: Mon, 22 Feb 2016 20:00:51 +0100
Subject: [PATCH] Fix ICE with match_def_path

---
 src/utils/mod.rs          | 6 +++++-
 tests/run-pass/ice-700.rs | 9 +++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100755 tests/run-pass/ice-700.rs

diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index 68137fbbf2a..b9dd9359c66 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -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()
     })
 }
 
diff --git a/tests/run-pass/ice-700.rs b/tests/run-pass/ice-700.rs
new file mode 100755
index 00000000000..a7ff78eac14
--- /dev/null
+++ b/tests/run-pass/ice-700.rs
@@ -0,0 +1,9 @@
+#![feature(plugin)]
+#![plugin(clippy)]
+#![deny(clippy)]
+
+fn core() {}
+
+fn main() {
+    core();
+}