From e3a5c15d18492f5b9f0c606f988b914918d29ef5 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 7 Apr 2021 13:06:48 +0200 Subject: Move Ty::builtin_deref --- crates/hir_ty/src/autoderef.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'crates/hir_ty/src/autoderef.rs') 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( krate: CrateId, ty: InEnvironment<&Canonical>, ) -> Option> { - if let Some(derefed) = ty.goal.value.builtin_deref() { + if let Some(derefed) = builtin_deref(&ty.goal.value) { Some(Canonical { value: derefed, binders: ty.goal.binders.clone() }) } else { deref_by_trait(db, krate, ty) } } +fn builtin_deref(ty: &Ty) -> Option { + match ty.kind(&Interner) { + TyKind::Ref(.., ty) => Some(ty.clone()), + TyKind::Raw(.., ty) => Some(ty.clone()), + _ => None, + } +} + fn deref_by_trait( db: &dyn HirDatabase, krate: CrateId, -- cgit v1.2.3