about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2019-01-05 08:21:56 +0100
committerMatthias Krüger <matthias.krueger@famsik.de>2019-01-05 08:21:56 +0100
commita4b99c6d6881b7e2149320d86794db0a9cdaed85 (patch)
tree1b72e29707ad906dff7d6268af96683534792d27
parent33ec4e5220b004e2d491cce7cc9ab95a5c140370 (diff)
downloadrust-a4b99c6d6881b7e2149320d86794db0a9cdaed85.tar.gz
rust-a4b99c6d6881b7e2149320d86794db0a9cdaed85.zip
rustup https://github.com/rust-lang/rust/pull/56837
-rw-r--r--clippy_lints/src/len_zero.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs
index 61aa228729c..233bea77e03 100644
--- a/clippy_lints/src/len_zero.rs
+++ b/clippy_lints/src/len_zero.rs
@@ -302,10 +302,15 @@ fn has_is_empty(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
 
     let ty = &walk_ptrs_ty(cx.tables.expr_ty(expr));
     match ty.sty {
-        ty::Dynamic(ref tt, ..) => cx
-            .tcx
-            .associated_items(tt.principal().def_id())
-            .any(|item| is_is_empty(cx, &item)),
+        ty::Dynamic(ref tt, ..) => {
+            if let Some(principal) = tt.principal() {
+                cx.tcx
+                    .associated_items(principal.def_id())
+                    .any(|item| is_is_empty(cx, &item))
+            } else {
+                false
+            }
+        },
         ty::Projection(ref proj) => has_is_empty_impl(cx, proj.item_def_id),
         ty::Adt(id, _) => has_is_empty_impl(cx, id.did),
         ty::Array(..) | ty::Slice(..) | ty::Str => true,