aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/autoderef.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/autoderef.rs')
-rw-r--r--crates/hir_ty/src/autoderef.rs10
1 files changed, 9 insertions, 1 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
45fn 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
45fn deref_by_trait( 53fn deref_by_trait(
46 db: &dyn HirDatabase, 54 db: &dyn HirDatabase,
47 krate: CrateId, 55 krate: CrateId,