Skip to content

Commit 5e085e4

Browse files
committed
Remove use of ty_to_def_id
1 parent 1e9f076 commit 5e085e4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

clippy_lints/src/len_zero.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,10 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool {
258258

259259
let ty = &walk_ptrs_ty(cx.tables.expr_ty(expr));
260260
match ty.sty {
261-
ty::TyDynamic(..) => cx.tcx
262-
.associated_items(ty.ty_to_def_id().expect("trait impl not found"))
261+
ty::TyDynamic(ref tt, ..) => cx.tcx
262+
.associated_items(tt.principal().expect("trait impl not found").def_id())
263263
.any(|item| is_is_empty(cx, &item)),
264-
ty::TyProjection(_) => ty.ty_to_def_id()
265-
.map_or(false, |id| has_is_empty_impl(cx, id)),
264+
ty::TyProjection(ref proj) => has_is_empty_impl(cx, proj.item_def_id),
266265
ty::TyAdt(id, _) => has_is_empty_impl(cx, id.did),
267266
ty::TyArray(..) | ty::TySlice(..) | ty::TyStr => true,
268267
_ => false,

0 commit comments

Comments
 (0)