Skip to content

Commit e3a5c15

Browse files
committed
Move Ty::builtin_deref
1 parent a8f1e41 commit e3a5c15

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

crates/hir_ty/src/autoderef.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,21 @@ pub(crate) fn deref(
3535
krate: CrateId,
3636
ty: InEnvironment<&Canonical<Ty>>,
3737
) -> Option<Canonical<Ty>> {
38-
if let Some(derefed) = ty.goal.value.builtin_deref() {
38+
if let Some(derefed) = builtin_deref(&ty.goal.value) {
3939
Some(Canonical { value: derefed, binders: ty.goal.binders.clone() })
4040
} else {
4141
deref_by_trait(db, krate, ty)
4242
}
4343
}
4444

45+
fn 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+
4553
fn deref_by_trait(
4654
db: &dyn HirDatabase,
4755
krate: CrateId,

crates/hir_ty/src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,6 @@ impl Ty {
199199
}
200200
}
201201

202-
fn builtin_deref(&self) -> Option<Ty> {
203-
match self.kind(&Interner) {
204-
TyKind::Ref(.., ty) => Some(ty.clone()),
205-
TyKind::Raw(.., ty) => Some(ty.clone()),
206-
_ => None,
207-
}
208-
}
209-
210202
/// Returns the type parameters of this type if it has some (i.e. is an ADT
211203
/// or function); so if `self` is `Option<u32>`, this returns the `u32`.
212204
pub fn substs(&self) -> Option<&Substitution> {

0 commit comments

Comments
 (0)