Remove use of ty_to_def_id

This commit is contained in:
Oliver Schneider 2018-07-15 02:04:23 +02:00
parent 1e9f076254
commit 5e085e4310

View File

@ -258,11 +258,10 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool {
let ty = &walk_ptrs_ty(cx.tables.expr_ty(expr)); let ty = &walk_ptrs_ty(cx.tables.expr_ty(expr));
match ty.sty { match ty.sty {
ty::TyDynamic(..) => cx.tcx ty::TyDynamic(ref tt, ..) => cx.tcx
.associated_items(ty.ty_to_def_id().expect("trait impl not found")) .associated_items(tt.principal().expect("trait impl not found").def_id())
.any(|item| is_is_empty(cx, &item)), .any(|item| is_is_empty(cx, &item)),
ty::TyProjection(_) => ty.ty_to_def_id() ty::TyProjection(ref proj) => has_is_empty_impl(cx, proj.item_def_id),
.map_or(false, |id| has_is_empty_impl(cx, id)),
ty::TyAdt(id, _) => has_is_empty_impl(cx, id.did), ty::TyAdt(id, _) => has_is_empty_impl(cx, id.did),
ty::TyArray(..) | ty::TySlice(..) | ty::TyStr => true, ty::TyArray(..) | ty::TySlice(..) | ty::TyStr => true,
_ => false, _ => false,