Skip to content

Commit a4b99c6

Browse files
committed
rustup #56837
1 parent 33ec4e5 commit a4b99c6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

clippy_lints/src/len_zero.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,15 @@ fn has_is_empty(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
302302

303303
let ty = &walk_ptrs_ty(cx.tables.expr_ty(expr));
304304
match ty.sty {
305-
ty::Dynamic(ref tt, ..) => cx
306-
.tcx
307-
.associated_items(tt.principal().def_id())
308-
.any(|item| is_is_empty(cx, &item)),
305+
ty::Dynamic(ref tt, ..) => {
306+
if let Some(principal) = tt.principal() {
307+
cx.tcx
308+
.associated_items(principal.def_id())
309+
.any(|item| is_is_empty(cx, &item))
310+
} else {
311+
false
312+
}
313+
},
309314
ty::Projection(ref proj) => has_is_empty_impl(cx, proj.item_def_id),
310315
ty::Adt(id, _) => has_is_empty_impl(cx, id.did),
311316
ty::Array(..) | ty::Slice(..) | ty::Str => true,

0 commit comments

Comments
 (0)