Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
krishna-veerareddy committed Feb 21, 2020
1 parent f5b4acc commit ea3525d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/use_self.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn check_trait_method_impl_decl<'a, 'tcx>(
let trait_method = cx
.tcx
.associated_items(impl_trait_ref.def_id)
.iter()
.in_definition_order()
.find(|assoc_item| {
assoc_item.kind == ty::AssocKind::Method
&& cx
Expand Down

0 comments on commit ea3525d

Please sign in to comment.