Skip to content

Commit 655b4f1

Browse files
bors[bot]Veetaha
andauthored
Merge #3679
3679: Some miniscule refactorings r=matklad a=Veetaha Co-authored-by: veetaha <veetaha2@gmail.com>
2 parents 6fe9564 + bfb6e3f commit 655b4f1

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

crates/ra_hir/src/code_model.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,30 +1042,18 @@ impl Type {
10421042
}
10431043

10441044
pub fn is_bool(&self) -> bool {
1045-
match &self.ty.value {
1046-
Ty::Apply(a_ty) => match a_ty.ctor {
1047-
TypeCtor::Bool => true,
1048-
_ => false,
1049-
},
1050-
_ => false,
1051-
}
1045+
matches!(self.ty.value, Ty::Apply(ApplicationTy { ctor: TypeCtor::Bool, .. }))
10521046
}
10531047

10541048
pub fn is_mutable_reference(&self) -> bool {
1055-
match &self.ty.value {
1056-
Ty::Apply(a_ty) => match a_ty.ctor {
1057-
TypeCtor::Ref(Mutability::Mut) => true,
1058-
_ => false,
1059-
},
1060-
_ => false,
1061-
}
1049+
matches!(
1050+
self.ty.value,
1051+
Ty::Apply(ApplicationTy { ctor: TypeCtor::Ref(Mutability::Mut), .. })
1052+
)
10621053
}
10631054

10641055
pub fn is_unknown(&self) -> bool {
1065-
match &self.ty.value {
1066-
Ty::Unknown => true,
1067-
_ => false,
1068-
}
1056+
matches!(self.ty.value, Ty::Unknown)
10691057
}
10701058

10711059
/// Checks that particular type `ty` implements `std::future::Future`.

crates/ra_hir_ty/src/method_resolution.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ impl Ty {
9595
// Types like slice can have inherent impls in several crates, (core and alloc).
9696
// The corresponding impls are marked with lang items, so we can use them to find the required crates.
9797
macro_rules! lang_item_crate {
98-
($($name:expr),+ $(,)?) => {{
99-
let mut v = ArrayVec::<[LangItemTarget; 2]>::new();
100-
$(
101-
v.extend(db.lang_item(cur_crate, $name.into()));
102-
)+
103-
v
104-
}};
105-
}
98+
($($name:expr),+ $(,)?) => {{
99+
let mut v = ArrayVec::<[LangItemTarget; 2]>::new();
100+
$(
101+
v.extend(db.lang_item(cur_crate, $name.into()));
102+
)+
103+
v
104+
}};
105+
}
106106

107107
let lang_item_targets = match self {
108108
Ty::Apply(a_ty) => match a_ty.ctor {

0 commit comments

Comments
 (0)