mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 13:18:47 +00:00
simplify
This commit is contained in:
parent
fcce07d2d1
commit
fbe60a2e28
2 changed files with 20 additions and 21 deletions
|
@ -322,9 +322,9 @@ pub struct ParamList {
|
|||
}
|
||||
impl ParamList {
|
||||
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
|
||||
pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
|
||||
pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
|
||||
pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) }
|
||||
pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
|
||||
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
|
@ -357,17 +357,6 @@ impl BlockExpr {
|
|||
pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Param {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl ast::AttrsOwner for Param {}
|
||||
impl ast::TypeAscriptionOwner for Param {}
|
||||
impl Param {
|
||||
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
|
||||
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
|
||||
pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct SelfParam {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
|
@ -383,6 +372,17 @@ impl SelfParam {
|
|||
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Param {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl ast::AttrsOwner for Param {}
|
||||
impl ast::TypeAscriptionOwner for Param {}
|
||||
impl Param {
|
||||
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
|
||||
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
|
||||
pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
|
||||
}
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct TypeBoundList {
|
||||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
|
@ -1724,8 +1724,8 @@ impl AstNode for BlockExpr {
|
|||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for Param {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM }
|
||||
impl AstNode for SelfParam {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
|
@ -1735,8 +1735,8 @@ impl AstNode for Param {
|
|||
}
|
||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||
}
|
||||
impl AstNode for SelfParam {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM }
|
||||
impl AstNode for Param {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM }
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
|
@ -3599,12 +3599,12 @@ impl std::fmt::Display for BlockExpr {
|
|||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for Param {
|
||||
impl std::fmt::Display for SelfParam {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
}
|
||||
impl std::fmt::Display for SelfParam {
|
||||
impl std::fmt::Display for Param {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(self.syntax(), f)
|
||||
}
|
||||
|
|
|
@ -54,9 +54,8 @@ Abi =
|
|||
|
||||
ParamList =
|
||||
'('(
|
||||
(Param (',' Param)* ','?)?
|
||||
| SelfParam ','?
|
||||
| SelfParam ',' (Param (',' Param)* ','?)
|
||||
SelfParam
|
||||
| (SelfParam ',')? (Param (',' Param)* ','?)?
|
||||
)')'
|
||||
|
||||
SelfParam =
|
||||
|
|
Loading…
Reference in a new issue