Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir_ty/src/chalk_ext.rs')
-rw-r--r--crates/hir_ty/src/chalk_ext.rs52
1 files changed, 26 insertions, 26 deletions
diff --git a/crates/hir_ty/src/chalk_ext.rs b/crates/hir_ty/src/chalk_ext.rs
index 97d1ad0f9c..bd5aab1b3d 100644
--- a/crates/hir_ty/src/chalk_ext.rs
+++ b/crates/hir_ty/src/chalk_ext.rs
@@ -46,30 +46,30 @@ pub trait TyExt {
impl TyExt for Ty {
fn is_unit(&self) -> bool {
- matches!(self.kind(&Interner), TyKind::Tuple(0, _))
+ matches!(self.kind(Interner), TyKind::Tuple(0, _))
}
fn is_never(&self) -> bool {
- matches!(self.kind(&Interner), TyKind::Never)
+ matches!(self.kind(Interner), TyKind::Never)
}
fn is_unknown(&self) -> bool {
- matches!(self.kind(&Interner), TyKind::Error)
+ matches!(self.kind(Interner), TyKind::Error)
}
fn is_ty_var(&self) -> bool {
- matches!(self.kind(&Interner), TyKind::InferenceVar(_, _))
+ matches!(self.kind(Interner), TyKind::InferenceVar(_, _))
}
fn as_adt(&self) -> Option<(hir_def::AdtId, &Substitution)> {
- match self.kind(&Interner) {
+ match self.kind(Interner) {
TyKind::Adt(AdtId(adt), parameters) => Some((*adt, parameters)),
_ => None,
}
}
fn as_builtin(&self) -> Option<BuiltinType> {
- match self.kind(&Interner) {
+ match self.kind(Interner) {
TyKind::Str => Some(BuiltinType::Str),
TyKind::Scalar(Scalar::Bool) => Some(BuiltinType::Bool),
TyKind::Scalar(Scalar::Char) => Some(BuiltinType::Char),
@@ -98,7 +98,7 @@ impl TyExt for Ty {
}
fn as_tuple(&self) -> Option<&Substitution> {
- match self.kind(&Interner) {
+ match self.kind(Interner) {
TyKind::Tuple(_, substs) => Some(substs),
_ => None,
}
@@ -111,14 +111,14 @@ impl TyExt for Ty {
}
}
fn as_reference(&self) -> Option<(&Ty, Lifetime, Mutability)> {
- match self.kind(&Interner) {
+ match self.kind(Interner) {
TyKind::Ref(mutability, lifetime, ty) => Some((ty, lifetime.clone(), *mutability)),
_ => None,
}
}
fn as_reference_or_ptr(&self) -> Option<(&Ty, Rawness, Mutability)> {
- match self.kind(&Interner) {
+ match self.kind(Interner) {
TyKind::Ref(mutability, _, ty) => Some((ty, Rawness::Ref, *mutability)),
TyKind::Raw(mutability, ty) => Some((ty, Rawness::RawPtr, *mutability)),
_ => None,
@@ -126,7 +126,7 @@ impl TyExt for Ty {
}
fn as_generic_def(&self, db: &dyn HirDatabase) -> Option<GenericDefId> {
- match *self.kind(&Interner) {
+ match *self.kind(Interner) {
TyKind::Adt(AdtId(adt), ..) => Some(adt.into()),
TyKind::FnDef(callable, ..) => {
Some(db.lookup_intern_callable_def(callable.into()).into())
@@ -138,22 +138,22 @@ impl TyExt for Ty {
}
fn callable_def(&self, db: &dyn HirDatabase) -> Option<CallableDefId> {
- match self.kind(&Interner) {
+ match self.kind(Interner) {
&TyKind::FnDef(def, ..) => Some(db.lookup_intern_callable_def(def.into())),
_ => None,
}
}
fn callable_sig(&self, db: &dyn HirDatabase) -> Option<CallableSig> {
- match self.kind(&Interner) {
+ match self.kind(Interner) {
TyKind::Function(fn_ptr) => Some(CallableSig::from_fn_ptr(fn_ptr)),
TyKind::FnDef(def, parameters) => {
let callable_def = db.lookup_intern_callable_def((*def).into());
let sig = db.callable_item_signature(callable_def);
- Some(sig.substitute(&Interner, &parameters))
+ Some(sig.substitute(Interner, &parameters))
}
TyKind::Closure(.., substs) => {
- let sig_param = substs.at(&Interner, 0).assert_ty_ref(&Interner);
+ let sig_param = substs.at(Interner, 0).assert_ty_ref(Interner);
sig_param.callable_sig(db)
}
_ => None,
@@ -161,7 +161,7 @@ impl TyExt for Ty {
}
fn dyn_trait(&self) -> Option<TraitId> {
- let trait_ref = match self.kind(&Interner) {
+ let trait_ref = match self.kind(Interner) {
TyKind::Dyn(dyn_ty) => dyn_ty.bounds.skip_binders().interned().get(0).and_then(|b| {
match b.skip_binders() {
WhereClause::Implemented(trait_ref) => Some(trait_ref),
@@ -175,14 +175,14 @@ impl TyExt for Ty {
fn strip_references(&self) -> &Ty {
let mut t: &Ty = self;
- while let TyKind::Ref(_mutability, _lifetime, ty) = t.kind(&Interner) {
+ while let TyKind::Ref(_mutability, _lifetime, ty) = t.kind(Interner) {
t = ty;
}
t
}
fn impl_trait_bounds(&self, db: &dyn HirDatabase) -> Option<Vec<QuantifiedWhereClause>> {
- match self.kind(&Interner) {
+ match self.kind(Interner) {
TyKind::OpaqueType(opaque_ty_id, subst) => {
match db.lookup_intern_impl_trait_id((*opaque_ty_id).into()) {
ImplTraitId::AsyncBlockTypeImplTrait(def, _expr) => {
@@ -195,10 +195,10 @@ impl TyExt for Ty {
// Parameters will be walked outside, and projection predicate is not used.
// So just provide the Future trait.
let impl_bound = Binders::empty(
- &Interner,
+ Interner,
WhereClause::Implemented(TraitRef {
trait_id: to_chalk_trait_id(future_trait),
- substitution: Substitution::empty(&Interner),
+ substitution: Substitution::empty(Interner),
}),
);
Some(vec![impl_bound])
@@ -211,7 +211,7 @@ impl TyExt for Ty {
let data = (*it)
.as_ref()
.map(|rpit| rpit.impl_traits[idx as usize].bounds.clone());
- data.substitute(&Interner, &subst).into_value_and_skipped_binders().0
+ data.substitute(Interner, &subst).into_value_and_skipped_binders().0
})
}
}
@@ -224,7 +224,7 @@ impl TyExt for Ty {
let data = (*it)
.as_ref()
.map(|rpit| rpit.impl_traits[idx as usize].bounds.clone());
- data.substitute(&Interner, &opaque_ty.substitution)
+ data.substitute(Interner, &opaque_ty.substitution)
})
}
// It always has an parameter for Future::Output type.
@@ -243,15 +243,15 @@ impl TyExt for Ty {
let predicates = db
.generic_predicates(id.parent)
.iter()
- .map(|pred| pred.clone().substitute(&Interner, &substs))
+ .map(|pred| pred.clone().substitute(Interner, &substs))
.filter(|wc| match &wc.skip_binders() {
WhereClause::Implemented(tr) => {
- &tr.self_type_parameter(&Interner) == self
+ &tr.self_type_parameter(Interner) == self
}
WhereClause::AliasEq(AliasEq {
alias: AliasTy::Projection(proj),
ty: _,
- }) => &proj.self_type_parameter(&Interner) == self,
+ }) => &proj.self_type_parameter(Interner) == self,
_ => false,
})
.collect::<Vec<_>>();
@@ -266,7 +266,7 @@ impl TyExt for Ty {
}
fn associated_type_parent_trait(&self, db: &dyn HirDatabase) -> Option<TraitId> {
- match self.kind(&Interner) {
+ match self.kind(Interner) {
TyKind::AssociatedType(id, ..) => {
match from_assoc_type_id(*id).lookup(db.upcast()).container {
ItemContainerId::TraitId(trait_id) => Some(trait_id),
@@ -287,7 +287,7 @@ impl TyExt for Ty {
}
fn equals_ctor(&self, other: &Ty) -> bool {
- match (self.kind(&Interner), other.kind(&Interner)) {
+ match (self.kind(Interner), other.kind(Interner)) {
(TyKind::Adt(adt, ..), TyKind::Adt(adt2, ..)) => adt == adt2,
(TyKind::Slice(_), TyKind::Slice(_)) | (TyKind::Array(_, _), TyKind::Array(_, _)) => {
true