mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Move Ty::builtin_deref
This commit is contained in:
parent
a8f1e41f0f
commit
e3a5c15d18
2 changed files with 9 additions and 9 deletions
|
@ -35,13 +35,21 @@ pub(crate) fn deref(
|
||||||
krate: CrateId,
|
krate: CrateId,
|
||||||
ty: InEnvironment<&Canonical<Ty>>,
|
ty: InEnvironment<&Canonical<Ty>>,
|
||||||
) -> Option<Canonical<Ty>> {
|
) -> Option<Canonical<Ty>> {
|
||||||
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() })
|
Some(Canonical { value: derefed, binders: ty.goal.binders.clone() })
|
||||||
} else {
|
} else {
|
||||||
deref_by_trait(db, krate, ty)
|
deref_by_trait(db, krate, ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn builtin_deref(ty: &Ty) -> Option<Ty> {
|
||||||
|
match ty.kind(&Interner) {
|
||||||
|
TyKind::Ref(.., ty) => Some(ty.clone()),
|
||||||
|
TyKind::Raw(.., ty) => Some(ty.clone()),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn deref_by_trait(
|
fn deref_by_trait(
|
||||||
db: &dyn HirDatabase,
|
db: &dyn HirDatabase,
|
||||||
krate: CrateId,
|
krate: CrateId,
|
||||||
|
|
|
@ -199,14 +199,6 @@ impl Ty {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn builtin_deref(&self) -> Option<Ty> {
|
|
||||||
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
|
/// Returns the type parameters of this type if it has some (i.e. is an ADT
|
||||||
/// or function); so if `self` is `Option<u32>`, this returns the `u32`.
|
/// or function); so if `self` is `Option<u32>`, this returns the `u32`.
|
||||||
pub fn substs(&self) -> Option<&Substitution> {
|
pub fn substs(&self) -> Option<&Substitution> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue