aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/autoderef.rs
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-04-07 12:06:48 +0100
committerLukas Wirth <[email protected]>2021-04-07 12:06:48 +0100
commite3a5c15d18492f5b9f0c606f988b914918d29ef5 (patch)
treea07655d6998f941dd56960744fc009e0414e68c6 /crates/hir_ty/src/autoderef.rs
parenta8f1e41f0f15fee02a73850db559752a9124d014 (diff)
Move Ty::builtin_deref
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,