diff options
author | Florian Diebold <[email protected]> | 2021-04-07 19:08:50 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-04-07 19:08:50 +0100 |
commit | 4c35df47e84b0eff51faa95b4c9636bb5f3da5eb (patch) | |
tree | 5c8162da0bd04ddf319ca27226b5f55c4665d5e6 /crates/hir_ty/src/lib.rs | |
parent | eb248d85a0eb91bae7bafcd69ffe4dfed3e32fce (diff) |
Move `equals_ctor` to `TyExt`
I'd prefer getting rid of it, but it's used in the impl search and not
super easy to replace there (I think ideally the impl search would do
proper unification, but that's a bit more complicated).
Diffstat (limited to 'crates/hir_ty/src/lib.rs')
-rw-r--r-- | crates/hir_ty/src/lib.rs | 32 |
1 files changed, 1 insertions, 31 deletions
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index 84645c435..2e851d3e0 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs | |||
@@ -168,37 +168,7 @@ impl CallableSig { | |||
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
171 | impl Ty { | 171 | impl Ty {} |
172 | pub fn equals_ctor(&self, other: &Ty) -> bool { | ||
173 | match (self.kind(&Interner), other.kind(&Interner)) { | ||
174 | (TyKind::Adt(adt, ..), TyKind::Adt(adt2, ..)) => adt == adt2, | ||
175 | (TyKind::Slice(_), TyKind::Slice(_)) | (TyKind::Array(_, _), TyKind::Array(_, _)) => { | ||
176 | true | ||
177 | } | ||
178 | (TyKind::FnDef(def_id, ..), TyKind::FnDef(def_id2, ..)) => def_id == def_id2, | ||
179 | (TyKind::OpaqueType(ty_id, ..), TyKind::OpaqueType(ty_id2, ..)) => ty_id == ty_id2, | ||
180 | (TyKind::AssociatedType(ty_id, ..), TyKind::AssociatedType(ty_id2, ..)) => { | ||
181 | ty_id == ty_id2 | ||
182 | } | ||
183 | (TyKind::Foreign(ty_id, ..), TyKind::Foreign(ty_id2, ..)) => ty_id == ty_id2, | ||
184 | (TyKind::Closure(id1, _), TyKind::Closure(id2, _)) => id1 == id2, | ||
185 | (TyKind::Ref(mutability, ..), TyKind::Ref(mutability2, ..)) | ||
186 | | (TyKind::Raw(mutability, ..), TyKind::Raw(mutability2, ..)) => { | ||
187 | mutability == mutability2 | ||
188 | } | ||
189 | ( | ||
190 | TyKind::Function(FnPointer { num_binders, sig, .. }), | ||
191 | TyKind::Function(FnPointer { num_binders: num_binders2, sig: sig2, .. }), | ||
192 | ) => num_binders == num_binders2 && sig == sig2, | ||
193 | (TyKind::Tuple(cardinality, _), TyKind::Tuple(cardinality2, _)) => { | ||
194 | cardinality == cardinality2 | ||
195 | } | ||
196 | (TyKind::Str, TyKind::Str) | (TyKind::Never, TyKind::Never) => true, | ||
197 | (TyKind::Scalar(scalar), TyKind::Scalar(scalar2)) => scalar == scalar2, | ||
198 | _ => false, | ||
199 | } | ||
200 | } | ||
201 | } | ||
202 | 172 | ||
203 | #[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] | 173 | #[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)] |
204 | pub enum ImplTraitId { | 174 | pub enum ImplTraitId { |