aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs39
1 files changed, 37 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 07cc3e0db..90480b6ca 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -307,6 +307,33 @@ impl BlockExpr {
307 } 307 }
308} 308}
309#[derive(Debug, Clone, PartialEq, Eq, Hash)] 309#[derive(Debug, Clone, PartialEq, Eq, Hash)]
310pub struct BoxPat {
311 pub(crate) syntax: SyntaxNode,
312}
313impl AstNode for BoxPat {
314 fn can_cast(kind: SyntaxKind) -> bool {
315 match kind {
316 BOX_PAT => true,
317 _ => false,
318 }
319 }
320 fn cast(syntax: SyntaxNode) -> Option<Self> {
321 if Self::can_cast(syntax.kind()) {
322 Some(Self { syntax })
323 } else {
324 None
325 }
326 }
327 fn syntax(&self) -> &SyntaxNode {
328 &self.syntax
329 }
330}
331impl BoxPat {
332 pub fn pat(&self) -> Option<Pat> {
333 AstChildren::new(&self.syntax).next()
334 }
335}
336#[derive(Debug, Clone, PartialEq, Eq, Hash)]
310pub struct BreakExpr { 337pub struct BreakExpr {
311 pub(crate) syntax: SyntaxNode, 338 pub(crate) syntax: SyntaxNode,
312} 339}
@@ -2063,6 +2090,7 @@ impl ParenType {
2063#[derive(Debug, Clone, PartialEq, Eq, Hash)] 2090#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2064pub enum Pat { 2091pub enum Pat {
2065 RefPat(RefPat), 2092 RefPat(RefPat),
2093 BoxPat(BoxPat),
2066 BindPat(BindPat), 2094 BindPat(BindPat),
2067 PlaceholderPat(PlaceholderPat), 2095 PlaceholderPat(PlaceholderPat),
2068 PathPat(PathPat), 2096 PathPat(PathPat),
@@ -2078,6 +2106,11 @@ impl From<RefPat> for Pat {
2078 Pat::RefPat(node) 2106 Pat::RefPat(node)
2079 } 2107 }
2080} 2108}
2109impl From<BoxPat> for Pat {
2110 fn from(node: BoxPat) -> Pat {
2111 Pat::BoxPat(node)
2112 }
2113}
2081impl From<BindPat> for Pat { 2114impl From<BindPat> for Pat {
2082 fn from(node: BindPat) -> Pat { 2115 fn from(node: BindPat) -> Pat {
2083 Pat::BindPat(node) 2116 Pat::BindPat(node)
@@ -2126,14 +2159,15 @@ impl From<LiteralPat> for Pat {
2126impl AstNode for Pat { 2159impl AstNode for Pat {
2127 fn can_cast(kind: SyntaxKind) -> bool { 2160 fn can_cast(kind: SyntaxKind) -> bool {
2128 match kind { 2161 match kind {
2129 REF_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT 2162 REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | RECORD_PAT
2130 | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => true, 2163 | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => true,
2131 _ => false, 2164 _ => false,
2132 } 2165 }
2133 } 2166 }
2134 fn cast(syntax: SyntaxNode) -> Option<Self> { 2167 fn cast(syntax: SyntaxNode) -> Option<Self> {
2135 let res = match syntax.kind() { 2168 let res = match syntax.kind() {
2136 REF_PAT => Pat::RefPat(RefPat { syntax }), 2169 REF_PAT => Pat::RefPat(RefPat { syntax }),
2170 BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
2137 BIND_PAT => Pat::BindPat(BindPat { syntax }), 2171 BIND_PAT => Pat::BindPat(BindPat { syntax }),
2138 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), 2172 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
2139 PATH_PAT => Pat::PathPat(PathPat { syntax }), 2173 PATH_PAT => Pat::PathPat(PathPat { syntax }),
@@ -2150,6 +2184,7 @@ impl AstNode for Pat {
2150 fn syntax(&self) -> &SyntaxNode { 2184 fn syntax(&self) -> &SyntaxNode {
2151 match self { 2185 match self {
2152 Pat::RefPat(it) => &it.syntax, 2186 Pat::RefPat(it) => &it.syntax,
2187 Pat::BoxPat(it) => &it.syntax,
2153 Pat::BindPat(it) => &it.syntax, 2188 Pat::BindPat(it) => &it.syntax,
2154 Pat::PlaceholderPat(it) => &it.syntax, 2189 Pat::PlaceholderPat(it) => &it.syntax,
2155 Pat::PathPat(it) => &it.syntax, 2190 Pat::PathPat(it) => &it.syntax,