aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/autoderef.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-04-07 12:18:20 +0100
committerGitHub <[email protected]>2021-04-07 12:18:20 +0100
commit45510ae23da9090027a80c4ff88dc8e7d9f29dbb (patch)
treecb2e469e3a80aaf8dae2f4dbaf3a8bbfb538894f /crates/hir_ty/src/autoderef.rs
parenta8f1e41f0f15fee02a73850db559752a9124d014 (diff)
parentc3c8e8225ff0a7a741f24777b5ee7a9c3e91eeb7 (diff)
Merge #8396
8396: Uncouple Ty::builtin_deref and Ty::def_crates from Ty r=Veykril a=Veykril bors r+ CC #8313 Co-authored-by: Lukas Wirth <[email protected]>
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,