aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
authoruHOOCCOOHu <[email protected]>2019-09-11 16:53:41 +0100
committeruHOOCCOOHu <[email protected]>2019-09-11 19:35:09 +0100
commit8c078a01641518a6b093922d4b1d27d1a98bad08 (patch)
tree25060debb1bd0b5905d77a6b4d5f80de07588f94 /crates/ra_syntax/src/ast
parent6ce6744e18f25ebcde387178125d820686692df5 (diff)
Infer box expression
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs40
1 files changed, 37 insertions, 3 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index d274b6fbc..a8a231ef3 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 BoxExpr {
311 pub(crate) syntax: SyntaxNode,
312}
313impl AstNode for BoxExpr {
314 fn can_cast(kind: SyntaxKind) -> bool {
315 match kind {
316 BOX_EXPR => 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 BoxExpr {
332 pub fn expr(&self) -> Option<Expr> {
333 AstChildren::new(&self.syntax).next()
334 }
335}
336#[derive(Debug, Clone, PartialEq, Eq, Hash)]
310pub struct BoxPat { 337pub struct BoxPat {
311 pub(crate) syntax: SyntaxNode, 338 pub(crate) syntax: SyntaxNode,
312} 339}
@@ -649,6 +676,7 @@ pub enum Expr {
649 BinExpr(BinExpr), 676 BinExpr(BinExpr),
650 Literal(Literal), 677 Literal(Literal),
651 MacroCall(MacroCall), 678 MacroCall(MacroCall),
679 BoxExpr(BoxExpr),
652} 680}
653impl From<TupleExpr> for Expr { 681impl From<TupleExpr> for Expr {
654 fn from(node: TupleExpr) -> Expr { 682 fn from(node: TupleExpr) -> Expr {
@@ -800,6 +828,11 @@ impl From<MacroCall> for Expr {
800 Expr::MacroCall(node) 828 Expr::MacroCall(node)
801 } 829 }
802} 830}
831impl From<BoxExpr> for Expr {
832 fn from(node: BoxExpr) -> Expr {
833 Expr::BoxExpr(node)
834 }
835}
803impl AstNode for Expr { 836impl AstNode for Expr {
804 fn can_cast(kind: SyntaxKind) -> bool { 837 fn can_cast(kind: SyntaxKind) -> bool {
805 match kind { 838 match kind {
@@ -807,9 +840,8 @@ impl AstNode for Expr {
807 | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL 840 | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL
808 | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR 841 | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR
809 | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR 842 | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR
810 | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL => { 843 | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL
811 true 844 | BOX_EXPR => true,
812 }
813 _ => false, 845 _ => false,
814 } 846 }
815 } 847 }
@@ -845,6 +877,7 @@ impl AstNode for Expr {
845 BIN_EXPR => Expr::BinExpr(BinExpr { syntax }), 877 BIN_EXPR => Expr::BinExpr(BinExpr { syntax }),
846 LITERAL => Expr::Literal(Literal { syntax }), 878 LITERAL => Expr::Literal(Literal { syntax }),
847 MACRO_CALL => Expr::MacroCall(MacroCall { syntax }), 879 MACRO_CALL => Expr::MacroCall(MacroCall { syntax }),
880 BOX_EXPR => Expr::BoxExpr(BoxExpr { syntax }),
848 _ => return None, 881 _ => return None,
849 }; 882 };
850 Some(res) 883 Some(res)
@@ -881,6 +914,7 @@ impl AstNode for Expr {
881 Expr::BinExpr(it) => &it.syntax, 914 Expr::BinExpr(it) => &it.syntax,
882 Expr::Literal(it) => &it.syntax, 915 Expr::Literal(it) => &it.syntax,
883 Expr::MacroCall(it) => &it.syntax, 916 Expr::MacroCall(it) => &it.syntax,
917 Expr::BoxExpr(it) => &it.syntax,
884 } 918 }
885 } 919 }
886} 920}