From e75e2ae5b6b6b1364368ceb3d4081b6508b2f001 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 28 Jun 2020 04:02:03 +0300 Subject: Simlify with matches!() --- crates/ra_hir_ty/src/infer/expr.rs | 6 +----- crates/ra_hir_ty/src/lib.rs | 10 ++-------- 2 files changed, 3 insertions(+), 13 deletions(-) (limited to 'crates/ra_hir_ty/src') diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index 61af5f064..22884522a 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs @@ -785,11 +785,7 @@ impl<'a> InferenceContext<'a> { for &check_closures in &[false, true] { let param_iter = param_tys.iter().cloned().chain(repeat(Ty::Unknown)); for (&arg, param_ty) in args.iter().zip(param_iter) { - let is_closure = match &self.body[arg] { - Expr::Lambda { .. } => true, - _ => false, - }; - + let is_closure = matches!(&self.body[arg], Expr::Lambda { .. }); if is_closure != check_closures { continue; } diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 414158139..c9513b752 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs @@ -620,17 +620,11 @@ pub enum GenericPredicate { impl GenericPredicate { pub fn is_error(&self) -> bool { - match self { - GenericPredicate::Error => true, - _ => false, - } + matches!(self, GenericPredicate::Error) } pub fn is_implemented(&self) -> bool { - match self { - GenericPredicate::Implemented(_) => true, - _ => false, - } + matches!(self, GenericPredicate::Implemented(_)) } pub fn trait_ref(&self, db: &dyn HirDatabase) -> Option { -- cgit v1.2.3