diff options
-rw-r--r-- | crates/hir_ty/src/autoderef.rs | 10 | ||||
-rw-r--r-- | crates/hir_ty/src/lib.rs | 8 |
2 files changed, 9 insertions, 9 deletions
diff --git a/crates/hir_ty/src/autoderef.rs b/crates/hir_ty/src/autoderef.rs index 80e192a57..f8e9db9ae 100644 --- a/crates/hir_ty/src/autoderef.rs +++ b/crates/hir_ty/src/autoderef.rs | |||
@@ -35,13 +35,21 @@ pub(crate) fn deref( | |||
35 | krate: CrateId, | 35 | krate: CrateId, |
36 | ty: InEnvironment<&Canonical<Ty>>, | 36 | ty: InEnvironment<&Canonical<Ty>>, |
37 | ) -> Option<Canonical<Ty>> { | 37 | ) -> Option<Canonical<Ty>> { |
38 | if let Some(derefed) = ty.goal.value.builtin_deref() { | 38 | if let Some(derefed) = builtin_deref(&ty.goal.value) { |
39 | Some(Canonical { value: derefed, binders: ty.goal.binders.clone() }) | 39 | Some(Canonical { value: derefed, binders: ty.goal.binders.clone() }) |
40 | } else { | 40 | } else { |
41 | deref_by_trait(db, krate, ty) | 41 | deref_by_trait(db, krate, ty) |
42 | } | 42 | } |
43 | } | 43 | } |
44 | 44 | ||
45 | fn builtin_deref(ty: &Ty) -> Option<Ty> { | ||
46 | match ty.kind(&Interner) { | ||
47 | TyKind::Ref(.., ty) => Some(ty.clone()), | ||
48 | TyKind::Raw(.., ty) => Some(ty.clone()), | ||
49 | _ => None, | ||
50 | } | ||
51 | } | ||
52 | |||
45 | fn deref_by_trait( | 53 | fn deref_by_trait( |
46 | db: &dyn HirDatabase, | 54 | db: &dyn HirDatabase, |
47 | krate: CrateId, | 55 | krate: CrateId, |
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index 5c83a508d..ae3987752 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs | |||
@@ -199,14 +199,6 @@ impl Ty { | |||
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | fn builtin_deref(&self) -> Option<Ty> { | ||
203 | match self.kind(&Interner) { | ||
204 | TyKind::Ref(.., ty) => Some(ty.clone()), | ||
205 | TyKind::Raw(.., ty) => Some(ty.clone()), | ||
206 | _ => None, | ||
207 | } | ||
208 | } | ||
209 | |||
210 | /// Returns the type parameters of this type if it has some (i.e. is an ADT | 202 | /// Returns the type parameters of this type if it has some (i.e. is an ADT |
211 | /// or function); so if `self` is `Option<u32>`, this returns the `u32`. | 203 | /// or function); so if `self` is `Option<u32>`, this returns the `u32`. |
212 | pub fn substs(&self) -> Option<&Substitution> { | 204 | pub fn substs(&self) -> Option<&Substitution> { |