Skip to content

Commit fbe60a2

Browse files
committed
simplify
1 parent fcce07d commit fbe60a2

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

crates/ra_syntax/src/ast/generated/nodes.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,9 @@ pub struct ParamList {
322322
}
323323
impl ParamList {
324324
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
325-
pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
326325
pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) }
327326
pub fn comma_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![,]) }
327+
pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) }
328328
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
329329
}
330330
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -357,17 +357,6 @@ impl BlockExpr {
357357
pub fn r_curly_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['}']) }
358358
}
359359
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
360-
pub struct Param {
361-
pub(crate) syntax: SyntaxNode,
362-
}
363-
impl ast::AttrsOwner for Param {}
364-
impl ast::TypeAscriptionOwner for Param {}
365-
impl Param {
366-
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
367-
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
368-
pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
369-
}
370-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
371360
pub struct SelfParam {
372361
pub(crate) syntax: SyntaxNode,
373362
}
@@ -383,6 +372,17 @@ impl SelfParam {
383372
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
384373
}
385374
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
375+
pub struct Param {
376+
pub(crate) syntax: SyntaxNode,
377+
}
378+
impl ast::AttrsOwner for Param {}
379+
impl ast::TypeAscriptionOwner for Param {}
380+
impl Param {
381+
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
382+
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
383+
pub fn dotdotdot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![...]) }
384+
}
385+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
386386
pub struct TypeBoundList {
387387
pub(crate) syntax: SyntaxNode,
388388
}
@@ -1724,8 +1724,8 @@ impl AstNode for BlockExpr {
17241724
}
17251725
fn syntax(&self) -> &SyntaxNode { &self.syntax }
17261726
}
1727-
impl AstNode for Param {
1728-
fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM }
1727+
impl AstNode for SelfParam {
1728+
fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM }
17291729
fn cast(syntax: SyntaxNode) -> Option<Self> {
17301730
if Self::can_cast(syntax.kind()) {
17311731
Some(Self { syntax })
@@ -1735,8 +1735,8 @@ impl AstNode for Param {
17351735
}
17361736
fn syntax(&self) -> &SyntaxNode { &self.syntax }
17371737
}
1738-
impl AstNode for SelfParam {
1739-
fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM }
1738+
impl AstNode for Param {
1739+
fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM }
17401740
fn cast(syntax: SyntaxNode) -> Option<Self> {
17411741
if Self::can_cast(syntax.kind()) {
17421742
Some(Self { syntax })
@@ -3599,12 +3599,12 @@ impl std::fmt::Display for BlockExpr {
35993599
std::fmt::Display::fmt(self.syntax(), f)
36003600
}
36013601
}
3602-
impl std::fmt::Display for Param {
3602+
impl std::fmt::Display for SelfParam {
36033603
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36043604
std::fmt::Display::fmt(self.syntax(), f)
36053605
}
36063606
}
3607-
impl std::fmt::Display for SelfParam {
3607+
impl std::fmt::Display for Param {
36083608
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36093609
std::fmt::Display::fmt(self.syntax(), f)
36103610
}

xtask/src/codegen/rust.ungram

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ Abi =
5454

5555
ParamList =
5656
'('(
57-
(Param (',' Param)* ','?)?
58-
| SelfParam ','?
59-
| SelfParam ',' (Param (',' Param)* ','?)
57+
SelfParam
58+
| (SelfParam ',')? (Param (',' Param)* ','?)?
6059
)')'
6160

6261
SelfParam =

0 commit comments

Comments
 (0)