mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Type the self parameter
This commit is contained in:
parent
ae9530addc
commit
111126ed3c
6 changed files with 116 additions and 9 deletions
|
@ -3488,6 +3488,43 @@ impl<'a> ReturnExpr<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
// SelfKw
|
||||
#[derive(Debug, Clone, Copy,)]
|
||||
pub struct SelfKwNode<R: TreeRoot<RaTypes> = OwnedRoot> {
|
||||
pub(crate) syntax: SyntaxNode<R>,
|
||||
}
|
||||
pub type SelfKw<'a> = SelfKwNode<RefRoot<'a>>;
|
||||
|
||||
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<SelfKwNode<R1>> for SelfKwNode<R2> {
|
||||
fn eq(&self, other: &SelfKwNode<R1>) -> bool { self.syntax == other.syntax }
|
||||
}
|
||||
impl<R: TreeRoot<RaTypes>> Eq for SelfKwNode<R> {}
|
||||
impl<R: TreeRoot<RaTypes>> Hash for SelfKwNode<R> {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
|
||||
}
|
||||
|
||||
impl<'a> AstNode<'a> for SelfKw<'a> {
|
||||
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
||||
match syntax.kind() {
|
||||
SELF_KW => Some(SelfKw { syntax }),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
||||
}
|
||||
|
||||
impl<R: TreeRoot<RaTypes>> SelfKwNode<R> {
|
||||
pub fn borrowed(&self) -> SelfKw {
|
||||
SelfKwNode { syntax: self.syntax.borrowed() }
|
||||
}
|
||||
pub fn owned(&self) -> SelfKwNode {
|
||||
SelfKwNode { syntax: self.syntax.owned() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl<'a> SelfKw<'a> {}
|
||||
|
||||
// SelfParam
|
||||
#[derive(Debug, Clone, Copy,)]
|
||||
pub struct SelfParamNode<R: TreeRoot<RaTypes> = OwnedRoot> {
|
||||
|
@ -3523,7 +3560,15 @@ impl<R: TreeRoot<RaTypes>> SelfParamNode<R> {
|
|||
}
|
||||
|
||||
|
||||
impl<'a> SelfParam<'a> {}
|
||||
impl<'a> SelfParam<'a> {
|
||||
pub fn type_ref(self) -> Option<TypeRef<'a>> {
|
||||
super::child_opt(self)
|
||||
}
|
||||
|
||||
pub fn self_kw(self) -> Option<SelfKw<'a>> {
|
||||
super::child_opt(self)
|
||||
}
|
||||
}
|
||||
|
||||
// SlicePat
|
||||
#[derive(Debug, Clone, Copy,)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue