Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr committed Jan 5, 2019
1 parent 33ec4e5 commit a4b99c6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a4b99c6

Please sign in to comment.