Skip to content

Commit

Permalink
Fix clippy: match expression looks like matches! macro
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwe authored and emilio committed Mar 8, 2023
1 parent fb1fdc8 commit ee2223f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
5 changes: 1 addition & 4 deletions src/bindgen/cdecl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ enum CDeclarator {

impl CDeclarator {
fn is_ptr(&self) -> bool {
match self {
CDeclarator::Ptr { .. } | CDeclarator::Func { .. } => true,
_ => false,
}
matches!(self, CDeclarator::Ptr { .. } | CDeclarator::Func { .. })
}
}

Expand Down
10 changes: 2 additions & 8 deletions src/bindgen/ir/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,7 @@ impl PrimitiveType {
}

fn can_cmp_order(&self) -> bool {
match *self {
PrimitiveType::Bool => false,
_ => true,
}
!matches!(*self, PrimitiveType::Bool)
}

fn can_cmp_eq(&self) -> bool {
Expand Down Expand Up @@ -551,10 +548,7 @@ impl Type {
pub fn is_primitive_or_ptr_primitive(&self) -> bool {
match *self {
Type::Primitive(..) => true,
Type::Ptr { ref ty, .. } => match ty.as_ref() {
Type::Primitive(..) => true,
_ => false,
},
Type::Ptr { ref ty, .. } => matches!(ty.as_ref(), Type::Primitive(..)),
_ => false,
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/bindgen/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,10 @@ impl Parse {
self.load_syn_ty(crate_name, mod_cfg, item);
}
syn::Item::Impl(ref item_impl) => {
let has_assoc_const = item_impl.items.iter().any(|item| match item {
syn::ImplItem::Const(_) => true,
_ => false,
});
let has_assoc_const = item_impl
.items
.iter()
.any(|item| matches!(item, syn::ImplItem::Const(_)));
if has_assoc_const {
impls_with_assoc_consts.push(item_impl);
}
Expand Down

0 comments on commit ee2223f

Please sign in to comment.