aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan MacKenzie <[email protected]>2019-09-15 01:05:12 +0100
committerDylan MacKenzie <[email protected]>2019-09-15 01:08:22 +0100
commit426112c97e587dfdaa79bcec0d4a37bef3c6b474 (patch)
tree6c97a93330a26f587482b32d5a95c2a292f7972a
parent211171ffe6a4e8cbf31b9513972e59a8b9bdc811 (diff)
Add `DotDotPat` to AST
This is modeled on `PlaceholderPat`.
-rw-r--r--crates/ra_hir/src/expr/lower.rs1
-rw-r--r--crates/ra_parser/src/syntax_kind/generated.rs1
-rw-r--r--crates/ra_syntax/src/ast/generated.rs37
-rw-r--r--crates/ra_syntax/src/grammar.ron3
4 files changed, 40 insertions, 2 deletions
diff --git a/crates/ra_hir/src/expr/lower.rs b/crates/ra_hir/src/expr/lower.rs
index 2be6f5421..61535d24f 100644
--- a/crates/ra_hir/src/expr/lower.rs
+++ b/crates/ra_hir/src/expr/lower.rs
@@ -573,6 +573,7 @@ where
573 } 573 }
574 574
575 // FIXME: implement 575 // FIXME: implement
576 ast::Pat::DotDotPat(_) => Pat::Missing,
576 ast::Pat::BoxPat(_) => Pat::Missing, 577 ast::Pat::BoxPat(_) => Pat::Missing,
577 ast::Pat::LiteralPat(_) => Pat::Missing, 578 ast::Pat::LiteralPat(_) => Pat::Missing,
578 ast::Pat::SlicePat(_) | ast::Pat::RangePat(_) => Pat::Missing, 579 ast::Pat::SlicePat(_) | ast::Pat::RangePat(_) => Pat::Missing,
diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs
index 8ba29ebf8..23eb3c9cb 100644
--- a/crates/ra_parser/src/syntax_kind/generated.rs
+++ b/crates/ra_parser/src/syntax_kind/generated.rs
@@ -152,6 +152,7 @@ pub enum SyntaxKind {
152 BOX_PAT, 152 BOX_PAT,
153 BIND_PAT, 153 BIND_PAT,
154 PLACEHOLDER_PAT, 154 PLACEHOLDER_PAT,
155 DOT_DOT_PAT,
155 PATH_PAT, 156 PATH_PAT,
156 RECORD_PAT, 157 RECORD_PAT,
157 RECORD_FIELD_PAT_LIST, 158 RECORD_FIELD_PAT_LIST,
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index a8a231ef3..591ac8ca3 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -532,6 +532,29 @@ impl AstNode for ContinueExpr {
532} 532}
533impl ContinueExpr {} 533impl ContinueExpr {}
534#[derive(Debug, Clone, PartialEq, Eq, Hash)] 534#[derive(Debug, Clone, PartialEq, Eq, Hash)]
535pub struct DotDotPat {
536 pub(crate) syntax: SyntaxNode,
537}
538impl AstNode for DotDotPat {
539 fn can_cast(kind: SyntaxKind) -> bool {
540 match kind {
541 DOT_DOT_PAT => true,
542 _ => false,
543 }
544 }
545 fn cast(syntax: SyntaxNode) -> Option<Self> {
546 if Self::can_cast(syntax.kind()) {
547 Some(Self { syntax })
548 } else {
549 None
550 }
551 }
552 fn syntax(&self) -> &SyntaxNode {
553 &self.syntax
554 }
555}
556impl DotDotPat {}
557#[derive(Debug, Clone, PartialEq, Eq, Hash)]
535pub struct DynTraitType { 558pub struct DynTraitType {
536 pub(crate) syntax: SyntaxNode, 559 pub(crate) syntax: SyntaxNode,
537} 560}
@@ -2128,6 +2151,7 @@ pub enum Pat {
2128 BoxPat(BoxPat), 2151 BoxPat(BoxPat),
2129 BindPat(BindPat), 2152 BindPat(BindPat),
2130 PlaceholderPat(PlaceholderPat), 2153 PlaceholderPat(PlaceholderPat),
2154 DotDotPat(DotDotPat),
2131 PathPat(PathPat), 2155 PathPat(PathPat),
2132 RecordPat(RecordPat), 2156 RecordPat(RecordPat),
2133 TupleStructPat(TupleStructPat), 2157 TupleStructPat(TupleStructPat),
@@ -2156,6 +2180,11 @@ impl From<PlaceholderPat> for Pat {
2156 Pat::PlaceholderPat(node) 2180 Pat::PlaceholderPat(node)
2157 } 2181 }
2158} 2182}
2183impl From<DotDotPat> for Pat {
2184 fn from(node: DotDotPat) -> Pat {
2185 Pat::DotDotPat(node)
2186 }
2187}
2159impl From<PathPat> for Pat { 2188impl From<PathPat> for Pat {
2160 fn from(node: PathPat) -> Pat { 2189 fn from(node: PathPat) -> Pat {
2161 Pat::PathPat(node) 2190 Pat::PathPat(node)
@@ -2194,8 +2223,10 @@ impl From<LiteralPat> for Pat {
2194impl AstNode for Pat { 2223impl AstNode for Pat {
2195 fn can_cast(kind: SyntaxKind) -> bool { 2224 fn can_cast(kind: SyntaxKind) -> bool {
2196 match kind { 2225 match kind {
2197 REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | RECORD_PAT 2226 REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | PATH_PAT
2198 | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => true, 2227 | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => {
2228 true
2229 }
2199 _ => false, 2230 _ => false,
2200 } 2231 }
2201 } 2232 }
@@ -2205,6 +2236,7 @@ impl AstNode for Pat {
2205 BOX_PAT => Pat::BoxPat(BoxPat { syntax }), 2236 BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
2206 BIND_PAT => Pat::BindPat(BindPat { syntax }), 2237 BIND_PAT => Pat::BindPat(BindPat { syntax }),
2207 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), 2238 PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
2239 DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }),
2208 PATH_PAT => Pat::PathPat(PathPat { syntax }), 2240 PATH_PAT => Pat::PathPat(PathPat { syntax }),
2209 RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), 2241 RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
2210 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), 2242 TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
@@ -2222,6 +2254,7 @@ impl AstNode for Pat {
2222 Pat::BoxPat(it) => &it.syntax, 2254 Pat::BoxPat(it) => &it.syntax,
2223 Pat::BindPat(it) => &it.syntax, 2255 Pat::BindPat(it) => &it.syntax,
2224 Pat::PlaceholderPat(it) => &it.syntax, 2256 Pat::PlaceholderPat(it) => &it.syntax,
2257 Pat::DotDotPat(it) => &it.syntax,
2225 Pat::PathPat(it) => &it.syntax, 2258 Pat::PathPat(it) => &it.syntax,
2226 Pat::RecordPat(it) => &it.syntax, 2259 Pat::RecordPat(it) => &it.syntax,
2227 Pat::TupleStructPat(it) => &it.syntax, 2260 Pat::TupleStructPat(it) => &it.syntax,
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index 8f064711d..08cc6eeea 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -161,6 +161,7 @@ Grammar(
161 "BOX_PAT", 161 "BOX_PAT",
162 "BIND_PAT", 162 "BIND_PAT",
163 "PLACEHOLDER_PAT", 163 "PLACEHOLDER_PAT",
164 "DOT_DOT_PAT",
164 "PATH_PAT", 165 "PATH_PAT",
165 "RECORD_PAT", 166 "RECORD_PAT",
166 "RECORD_FIELD_PAT_LIST", 167 "RECORD_FIELD_PAT_LIST",
@@ -532,6 +533,7 @@ Grammar(
532 traits: ["NameOwner"] 533 traits: ["NameOwner"]
533 ), 534 ),
534 "PlaceholderPat": (), 535 "PlaceholderPat": (),
536 "DotDotPat": (),
535 "PathPat": ( options: [ "Path" ] ), 537 "PathPat": ( options: [ "Path" ] ),
536 "RecordPat": ( options: ["RecordFieldPatList", "Path"] ), 538 "RecordPat": ( options: ["RecordFieldPatList", "Path"] ),
537 "RecordFieldPatList": ( 539 "RecordFieldPatList": (
@@ -559,6 +561,7 @@ Grammar(
559 "BoxPat", 561 "BoxPat",
560 "BindPat", 562 "BindPat",
561 "PlaceholderPat", 563 "PlaceholderPat",
564 "DotDotPat",
562 "PathPat", 565 "PathPat",
563 "RecordPat", 566 "RecordPat",
564 "TupleStructPat", 567 "TupleStructPat",