This commit is contained in:
Krishna Sai Veera Reddy 2020-02-20 21:20:49 -08:00
parent f5b4acccf7
commit ce896ae96d
2 changed files with 9 additions and 13 deletions

View File

@ -147,7 +147,7 @@ fn check_trait_items(cx: &LateContext<'_, '_>, visited_trait: &Item<'_>, trait_i
let is_empty_method_found = current_and_super_traits
.iter()
.flat_map(|&i| cx.tcx.associated_items(i))
.flat_map(|&i| cx.tcx.associated_items(i).in_definition_order())
.any(|i| {
i.kind == ty::AssocKind::Method
&& i.method_has_self_argument
@ -276,10 +276,12 @@ fn has_is_empty(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> bool {
/// Checks the inherent impl's items for an `is_empty(self)` method.
fn has_is_empty_impl(cx: &LateContext<'_, '_>, id: DefId) -> bool {
cx.tcx
.inherent_impls(id)
.iter()
.any(|imp| cx.tcx.associated_items(*imp).iter().any(|item| is_is_empty(cx, &item)))
cx.tcx.inherent_impls(id).iter().any(|imp| {
cx.tcx
.associated_items(*imp)
.in_definition_order()
.any(|item| is_is_empty(cx, &item))
})
}
let ty = &walk_ptrs_ty(cx.tables.expr_ty(expr));
@ -288,7 +290,7 @@ fn has_is_empty(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> bool {
if let Some(principal) = tt.principal() {
cx.tcx
.associated_items(principal.def_id())
.iter()
.in_definition_order()
.any(|item| is_is_empty(cx, &item))
} else {
false

View File

@ -125,13 +125,7 @@ fn check_trait_method_impl_decl<'a, 'tcx>(
let trait_method = cx
.tcx
.associated_items(impl_trait_ref.def_id)
.iter()
.find(|assoc_item| {
assoc_item.kind == ty::AssocKind::Method
&& cx
.tcx
.hygienic_eq(impl_item.ident, assoc_item.ident, impl_trait_ref.def_id)
})
.find_by_name_and_kind(cx.tcx, impl_item.ident, ty::AssocKind::Method, impl_trait_ref.def_id)
.expect("impl method matches a trait method");
let trait_method_sig = cx.tcx.fn_sig(trait_method.def_id);