aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs83
1 files changed, 76 insertions, 7 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 8a3669bd1..8eb240801 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -1,4 +1,4 @@
1//! Generated file, do not edit by hand, see `crate/ra_tools/src/codegen` 1//! Generated file, do not edit by hand, see `xtask/src/codegen`
2 2
3use crate::{ 3use crate::{
4 ast::{self, AstChildren, AstNode}, 4 ast::{self, AstChildren, AstNode},
@@ -1759,8 +1759,8 @@ impl AstNode for MatchArm {
1759} 1759}
1760impl ast::AttrsOwner for MatchArm {} 1760impl ast::AttrsOwner for MatchArm {}
1761impl MatchArm { 1761impl MatchArm {
1762 pub fn pats(&self) -> AstChildren<Pat> { 1762 pub fn pat(&self) -> Option<Pat> {
1763 AstChildren::new(&self.syntax) 1763 AstChildren::new(&self.syntax).next()
1764 } 1764 }
1765 pub fn guard(&self) -> Option<MatchGuard> { 1765 pub fn guard(&self) -> Option<MatchGuard> {
1766 AstChildren::new(&self.syntax).next() 1766 AstChildren::new(&self.syntax).next()
@@ -1887,6 +1887,60 @@ impl RecordField {
1887 } 1887 }
1888} 1888}
1889#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1889#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1890pub struct OrPat {
1891 pub(crate) syntax: SyntaxNode,
1892}
1893impl AstNode for OrPat {
1894 fn can_cast(kind: SyntaxKind) -> bool {
1895 match kind {
1896 OR_PAT => true,
1897 _ => false,
1898 }
1899 }
1900 fn cast(syntax: SyntaxNode) -> Option<Self> {
1901 if Self::can_cast(syntax.kind()) {
1902 Some(Self { syntax })
1903 } else {
1904 None
1905 }
1906 }
1907 fn syntax(&self) -> &SyntaxNode {
1908 &self.syntax
1909 }
1910}
1911impl OrPat {
1912 pub fn pats(&self) -> AstChildren<Pat> {
1913 AstChildren::new(&self.syntax)
1914 }
1915}
1916#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1917pub struct ParenPat {
1918 pub(crate) syntax: SyntaxNode,
1919}
1920impl AstNode for ParenPat {
1921 fn can_cast(kind: SyntaxKind) -> bool {
1922 match kind {
1923 PAREN_PAT => true,
1924 _ => false,
1925 }
1926 }
1927 fn cast(syntax: SyntaxNode) -> Option<Self> {
1928 if Self::can_cast(syntax.kind()) {
1929 Some(Self { syntax })
1930 } else {
1931 None
1932 }
1933 }
1934 fn syntax(&self) -> &SyntaxNode {
1935 &self.syntax
1936 }
1937}
1938impl ParenPat {
1939 pub fn pat(&self) -> Option<Pat> {
1940 AstChildren::new(&self.syntax).next()
1941 }
1942}
1943#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1890pub struct RefPat { 1944pub struct RefPat {
1891 pub(crate) syntax: SyntaxNode, 1945 pub(crate) syntax: SyntaxNode,
1892} 1946}
@@ -3904,6 +3958,8 @@ impl AstNode for Expr {
3904} 3958}
3905#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3959#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3906pub enum Pat { 3960pub enum Pat {
3961 OrPat(OrPat),
3962 ParenPat(ParenPat),
3907 RefPat(RefPat), 3963 RefPat(RefPat),
3908 BoxPat(BoxPat), 3964 BoxPat(BoxPat),
3909 BindPat(BindPat), 3965 BindPat(BindPat),
@@ -3917,6 +3973,16 @@ pub enum Pat {
3917 RangePat(RangePat), 3973 RangePat(RangePat),
3918 LiteralPat(LiteralPat), 3974 LiteralPat(LiteralPat),
3919} 3975}
3976impl From<OrPat> for Pat {
3977 fn from(node: OrPat) -> Pat {
3978 Pat::OrPat(node)
3979 }
3980}
3981impl From<ParenPat> for Pat {
3982 fn from(node: ParenPat) -> Pat {
3983 Pat::ParenPat(node)
3984 }
3985}
3920impl From<RefPat> for Pat { 3986impl From<RefPat> for Pat {
3921 fn from(node: RefPat) -> Pat { 3987 fn from(node: RefPat) -> Pat {
3922 Pat::RefPat(node) 3988 Pat::RefPat(node)
@@ -3980,15 +4046,16 @@ impl From<LiteralPat> for Pat {
3980impl AstNode for Pat { 4046impl AstNode for Pat {
3981 fn can_cast(kind: SyntaxKind) -> bool { 4047 fn can_cast(kind: SyntaxKind) -> bool {
3982 match kind { 4048 match kind {
3983 REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | PATH_PAT 4049 OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT
3984 | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => { 4050 | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT
3985 true 4051 | LITERAL_PAT => true,
3986 }
3987 _ => false, 4052 _ => false,
3988 } 4053 }
3989 } 4054 }
3990 fn cast(syntax: SyntaxNode) -> Option<Self> { 4055 fn cast(syntax: SyntaxNode) -> Option<Self> {
3991 let res = match syntax.kind() { 4056 let res = match syntax.kind() {
4057 OR_PAT => Pat::OrPat(OrPat { syntax }),
4058 PAREN_PAT => Pat::ParenPat(ParenPat { syntax }),
3992 REF_PAT => Pat::RefPat(RefPat { syntax }), 4059 REF_PAT => Pat::RefPat(RefPat { syntax }),
3993 BOX_PAT => Pat::BoxPat(BoxPat { syntax }), 4060 BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
3994 BIND_PAT => Pat::BindPat(BindPat { syntax }), 4061 BIND_PAT => Pat::BindPat(BindPat { syntax }),
@@ -4007,6 +4074,8 @@ impl AstNode for Pat {
4007 } 4074 }
4008 fn syntax(&self) -> &SyntaxNode { 4075 fn syntax(&self) -> &SyntaxNode {
4009 match self { 4076 match self {
4077 Pat::OrPat(it) => &it.syntax,
4078 Pat::ParenPat(it) => &it.syntax,
4010 Pat::RefPat(it) => &it.syntax, 4079 Pat::RefPat(it) => &it.syntax,
4011 Pat::BoxPat(it) => &it.syntax, 4080 Pat::BoxPat(it) => &it.syntax,
4012 Pat::BindPat(it) => &it.syntax, 4081 Pat::BindPat(it) => &it.syntax,