From a8e5da8a70c0487d3325573596219f14a6baa7aa Mon Sep 17 00:00:00 2001 From: veetaha Date: Sun, 22 Mar 2020 15:44:38 +0200 Subject: ra_hir_ty: fix formatting --- crates/ra_hir_ty/src/method_resolution.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs index 69c059ac8..533c6ccfb 100644 --- a/crates/ra_hir_ty/src/method_resolution.rs +++ b/crates/ra_hir_ty/src/method_resolution.rs @@ -95,14 +95,14 @@ impl Ty { // Types like slice can have inherent impls in several crates, (core and alloc). // The corresponding impls are marked with lang items, so we can use them to find the required crates. macro_rules! lang_item_crate { - ($($name:expr),+ $(,)?) => {{ - let mut v = ArrayVec::<[LangItemTarget; 2]>::new(); - $( - v.extend(db.lang_item(cur_crate, $name.into())); - )+ - v - }}; - } + ($($name:expr),+ $(,)?) => {{ + let mut v = ArrayVec::<[LangItemTarget; 2]>::new(); + $( + v.extend(db.lang_item(cur_crate, $name.into())); + )+ + v + }}; + } let lang_item_targets = match self { Ty::Apply(a_ty) => match a_ty.ctor { -- cgit v1.2.3 From bfb6e3fd836650dd477c55e6642d831028f30b22 Mon Sep 17 00:00:00 2001 From: veetaha Date: Sun, 22 Mar 2020 15:45:32 +0200 Subject: ra_hir: migrate some stuff to matches!() --- crates/ra_hir/src/code_model.rs | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 45e31095c..4b150ef06 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -1042,30 +1042,18 @@ impl Type { } pub fn is_bool(&self) -> bool { - match &self.ty.value { - Ty::Apply(a_ty) => match a_ty.ctor { - TypeCtor::Bool => true, - _ => false, - }, - _ => false, - } + matches!(self.ty.value, Ty::Apply(ApplicationTy { ctor: TypeCtor::Bool, .. })) } pub fn is_mutable_reference(&self) -> bool { - match &self.ty.value { - Ty::Apply(a_ty) => match a_ty.ctor { - TypeCtor::Ref(Mutability::Mut) => true, - _ => false, - }, - _ => false, - } + matches!( + self.ty.value, + Ty::Apply(ApplicationTy { ctor: TypeCtor::Ref(Mutability::Mut), .. }) + ) } pub fn is_unknown(&self) -> bool { - match &self.ty.value { - Ty::Unknown => true, - _ => false, - } + matches!(self.ty.value, Ty::Unknown) } /// Checks that particular type `ty` implements `std::future::Future`. -- cgit v1.2.3