diff --git a/crates/hir_ty/src/autoderef.rs b/crates/hir_ty/src/autoderef.rs index 80e192a5750..f8e9db9ae5b 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, diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index 5c83a508d45..ae3987752b7 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs @@ -199,14 +199,6 @@ impl Ty { } } - fn builtin_deref(&self) -> Option { - match self.kind(&Interner) { - TyKind::Ref(.., ty) => Some(ty.clone()), - TyKind::Raw(.., ty) => Some(ty.clone()), - _ => None, - } - } - /// Returns the type parameters of this type if it has some (i.e. is an ADT /// or function); so if `self` is `Option`, this returns the `u32`. pub fn substs(&self) -> Option<&Substitution> {