mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
Merge #3679
3679: Some miniscule refactorings r=matklad a=Veetaha Co-authored-by: veetaha <veetaha2@gmail.com>
This commit is contained in:
commit
655b4f16f0
@ -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`.
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user