.iter()
.filter(|arg| {
if is_unit(cx.tables().expr_ty(arg)) && !is_unit_literal(arg) {
- if let ExprKind::Match(.., MatchSource::TryDesugar) = &arg.kind {
- false
- } else {
- true
- }
+ !matches!(&arg.kind, ExprKind::Match(.., MatchSource::TryDesugar))
} else {
false
}
}
fn is_unit(ty: Ty<'_>) -> bool {
- match ty.kind {
- ty::Tuple(slice) if slice.is_empty() => true,
- _ => false,
- }
+ matches!(ty.kind, ty::Tuple(slice) if slice.is_empty())
}
fn is_unit_literal(expr: &Expr<'_>) -> bool {
- match expr.kind {
- ExprKind::Tup(ref slice) if slice.is_empty() => true,
- _ => false,
- }
+ matches!(expr.kind, ExprKind::Tup(ref slice) if slice.is_empty())
}
declare_clippy_lint! {
}
fn is_isize_or_usize(typ: Ty<'_>) -> bool {
- match typ.kind {
- ty::Int(IntTy::Isize) | ty::Uint(UintTy::Usize) => true,
- _ => false,
- }
+ matches!(typ.kind, ty::Int(IntTy::Isize) | ty::Uint(UintTy::Usize))
}
fn span_precision_loss_lint(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, cast_to_f64: bool) {
TyKind::TraitObject(ref param_bounds, _) => {
let has_lifetime_parameters = param_bounds.iter().any(|bound| {
- bound.bound_generic_params.iter().any(|gen| match gen.kind {
- GenericParamKind::Lifetime { .. } => true,
- _ => false,
- })
+ bound
+ .bound_generic_params
+ .iter()
+ .any(|gen| matches!(gen.kind, GenericParamKind::Lifetime { .. }))
});
if has_lifetime_parameters {
// complex trait bounds like A<'a, 'b>