diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-31 17:12:01 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-31 17:12:01 +0100 |
commit | 98975a772a85fa37efabb8d940bc07d4030ba49d (patch) | |
tree | e4243fc53feefa780ef0b1987ca5c92c6ea34090 /crates/ra_syntax/src | |
parent | c1e53d668f2f44656ffeca31f06b8ed380426b08 (diff) | |
parent | 7980a7e19a679e0bc128f2c142609f7f4a197bf6 (diff) |
Merge #5626
5626: Minor r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 130 |
1 files changed, 62 insertions, 68 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 158544fa2..e049548c9 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -624,6 +624,19 @@ impl CastExpr { | |||
624 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } | 624 | pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } |
625 | } | 625 | } |
626 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 626 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
627 | pub struct ClosureExpr { | ||
628 | pub(crate) syntax: SyntaxNode, | ||
629 | } | ||
630 | impl ast::AttrsOwner for ClosureExpr {} | ||
631 | impl ClosureExpr { | ||
632 | pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } | ||
633 | pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } | ||
634 | pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) } | ||
635 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | ||
636 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | ||
637 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
638 | } | ||
639 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
627 | pub struct ContinueExpr { | 640 | pub struct ContinueExpr { |
628 | pub(crate) syntax: SyntaxNode, | 641 | pub(crate) syntax: SyntaxNode, |
629 | } | 642 | } |
@@ -690,28 +703,6 @@ impl IndexExpr { | |||
690 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } | 703 | pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![']']) } |
691 | } | 704 | } |
692 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 705 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
693 | pub struct Label { | ||
694 | pub(crate) syntax: SyntaxNode, | ||
695 | } | ||
696 | impl Label { | ||
697 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | ||
698 | support::token(&self.syntax, T![lifetime]) | ||
699 | } | ||
700 | } | ||
701 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
702 | pub struct ClosureExpr { | ||
703 | pub(crate) syntax: SyntaxNode, | ||
704 | } | ||
705 | impl ast::AttrsOwner for ClosureExpr {} | ||
706 | impl ClosureExpr { | ||
707 | pub fn static_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![static]) } | ||
708 | pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) } | ||
709 | pub fn move_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![move]) } | ||
710 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | ||
711 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | ||
712 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
713 | } | ||
714 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
715 | pub struct LoopExpr { | 706 | pub struct LoopExpr { |
716 | pub(crate) syntax: SyntaxNode, | 707 | pub(crate) syntax: SyntaxNode, |
717 | } | 708 | } |
@@ -835,6 +826,15 @@ impl WhileExpr { | |||
835 | pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } | 826 | pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } |
836 | } | 827 | } |
837 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 828 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
829 | pub struct Label { | ||
830 | pub(crate) syntax: SyntaxNode, | ||
831 | } | ||
832 | impl Label { | ||
833 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | ||
834 | support::token(&self.syntax, T![lifetime]) | ||
835 | } | ||
836 | } | ||
837 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
838 | pub struct RecordExprFieldList { | 838 | pub struct RecordExprFieldList { |
839 | pub(crate) syntax: SyntaxNode, | 839 | pub(crate) syntax: SyntaxNode, |
840 | } | 840 | } |
@@ -1337,14 +1337,13 @@ pub enum Expr { | |||
1337 | BreakExpr(BreakExpr), | 1337 | BreakExpr(BreakExpr), |
1338 | CallExpr(CallExpr), | 1338 | CallExpr(CallExpr), |
1339 | CastExpr(CastExpr), | 1339 | CastExpr(CastExpr), |
1340 | ClosureExpr(ClosureExpr), | ||
1340 | ContinueExpr(ContinueExpr), | 1341 | ContinueExpr(ContinueExpr), |
1341 | EffectExpr(EffectExpr), | 1342 | EffectExpr(EffectExpr), |
1342 | FieldExpr(FieldExpr), | 1343 | FieldExpr(FieldExpr), |
1343 | ForExpr(ForExpr), | 1344 | ForExpr(ForExpr), |
1344 | IfExpr(IfExpr), | 1345 | IfExpr(IfExpr), |
1345 | IndexExpr(IndexExpr), | 1346 | IndexExpr(IndexExpr), |
1346 | Label(Label), | ||
1347 | ClosureExpr(ClosureExpr), | ||
1348 | Literal(Literal), | 1347 | Literal(Literal), |
1349 | LoopExpr(LoopExpr), | 1348 | LoopExpr(LoopExpr), |
1350 | MacroCall(MacroCall), | 1349 | MacroCall(MacroCall), |
@@ -2017,6 +2016,17 @@ impl AstNode for CastExpr { | |||
2017 | } | 2016 | } |
2018 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2017 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2019 | } | 2018 | } |
2019 | impl AstNode for ClosureExpr { | ||
2020 | fn can_cast(kind: SyntaxKind) -> bool { kind == CLOSURE_EXPR } | ||
2021 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2022 | if Self::can_cast(syntax.kind()) { | ||
2023 | Some(Self { syntax }) | ||
2024 | } else { | ||
2025 | None | ||
2026 | } | ||
2027 | } | ||
2028 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2029 | } | ||
2020 | impl AstNode for ContinueExpr { | 2030 | impl AstNode for ContinueExpr { |
2021 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR } | 2031 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR } |
2022 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2032 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2083,28 +2093,6 @@ impl AstNode for IndexExpr { | |||
2083 | } | 2093 | } |
2084 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2094 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2085 | } | 2095 | } |
2086 | impl AstNode for Label { | ||
2087 | fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL } | ||
2088 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2089 | if Self::can_cast(syntax.kind()) { | ||
2090 | Some(Self { syntax }) | ||
2091 | } else { | ||
2092 | None | ||
2093 | } | ||
2094 | } | ||
2095 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2096 | } | ||
2097 | impl AstNode for ClosureExpr { | ||
2098 | fn can_cast(kind: SyntaxKind) -> bool { kind == CLOSURE_EXPR } | ||
2099 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2100 | if Self::can_cast(syntax.kind()) { | ||
2101 | Some(Self { syntax }) | ||
2102 | } else { | ||
2103 | None | ||
2104 | } | ||
2105 | } | ||
2106 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2107 | } | ||
2108 | impl AstNode for LoopExpr { | 2096 | impl AstNode for LoopExpr { |
2109 | fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR } | 2097 | fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR } |
2110 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2098 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -2248,6 +2236,17 @@ impl AstNode for WhileExpr { | |||
2248 | } | 2236 | } |
2249 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2237 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2250 | } | 2238 | } |
2239 | impl AstNode for Label { | ||
2240 | fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL } | ||
2241 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2242 | if Self::can_cast(syntax.kind()) { | ||
2243 | Some(Self { syntax }) | ||
2244 | } else { | ||
2245 | None | ||
2246 | } | ||
2247 | } | ||
2248 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2249 | } | ||
2251 | impl AstNode for RecordExprFieldList { | 2250 | impl AstNode for RecordExprFieldList { |
2252 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD_LIST } | 2251 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD_LIST } |
2253 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 2252 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
@@ -3086,6 +3085,9 @@ impl From<CallExpr> for Expr { | |||
3086 | impl From<CastExpr> for Expr { | 3085 | impl From<CastExpr> for Expr { |
3087 | fn from(node: CastExpr) -> Expr { Expr::CastExpr(node) } | 3086 | fn from(node: CastExpr) -> Expr { Expr::CastExpr(node) } |
3088 | } | 3087 | } |
3088 | impl From<ClosureExpr> for Expr { | ||
3089 | fn from(node: ClosureExpr) -> Expr { Expr::ClosureExpr(node) } | ||
3090 | } | ||
3089 | impl From<ContinueExpr> for Expr { | 3091 | impl From<ContinueExpr> for Expr { |
3090 | fn from(node: ContinueExpr) -> Expr { Expr::ContinueExpr(node) } | 3092 | fn from(node: ContinueExpr) -> Expr { Expr::ContinueExpr(node) } |
3091 | } | 3093 | } |
@@ -3104,12 +3106,6 @@ impl From<IfExpr> for Expr { | |||
3104 | impl From<IndexExpr> for Expr { | 3106 | impl From<IndexExpr> for Expr { |
3105 | fn from(node: IndexExpr) -> Expr { Expr::IndexExpr(node) } | 3107 | fn from(node: IndexExpr) -> Expr { Expr::IndexExpr(node) } |
3106 | } | 3108 | } |
3107 | impl From<Label> for Expr { | ||
3108 | fn from(node: Label) -> Expr { Expr::Label(node) } | ||
3109 | } | ||
3110 | impl From<ClosureExpr> for Expr { | ||
3111 | fn from(node: ClosureExpr) -> Expr { Expr::ClosureExpr(node) } | ||
3112 | } | ||
3113 | impl From<Literal> for Expr { | 3109 | impl From<Literal> for Expr { |
3114 | fn from(node: Literal) -> Expr { Expr::Literal(node) } | 3110 | fn from(node: Literal) -> Expr { Expr::Literal(node) } |
3115 | } | 3111 | } |
@@ -3159,8 +3155,8 @@ impl AstNode for Expr { | |||
3159 | fn can_cast(kind: SyntaxKind) -> bool { | 3155 | fn can_cast(kind: SyntaxKind) -> bool { |
3160 | match kind { | 3156 | match kind { |
3161 | ARRAY_EXPR | AWAIT_EXPR | BIN_EXPR | BLOCK_EXPR | BOX_EXPR | BREAK_EXPR | CALL_EXPR | 3157 | ARRAY_EXPR | AWAIT_EXPR | BIN_EXPR | BLOCK_EXPR | BOX_EXPR | BREAK_EXPR | CALL_EXPR |
3162 | | CAST_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR | IF_EXPR | 3158 | | CAST_EXPR | CLOSURE_EXPR | CONTINUE_EXPR | EFFECT_EXPR | FIELD_EXPR | FOR_EXPR |
3163 | | INDEX_EXPR | LABEL | CLOSURE_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR | 3159 | | IF_EXPR | INDEX_EXPR | LITERAL | LOOP_EXPR | MACRO_CALL | MATCH_EXPR |
3164 | | METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR | 3160 | | METHOD_CALL_EXPR | PAREN_EXPR | PATH_EXPR | PREFIX_EXPR | RANGE_EXPR |
3165 | | RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR => true, | 3161 | | RECORD_EXPR | REF_EXPR | RETURN_EXPR | TRY_EXPR | TUPLE_EXPR | WHILE_EXPR => true, |
3166 | _ => false, | 3162 | _ => false, |
@@ -3176,14 +3172,13 @@ impl AstNode for Expr { | |||
3176 | BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }), | 3172 | BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }), |
3177 | CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), | 3173 | CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), |
3178 | CAST_EXPR => Expr::CastExpr(CastExpr { syntax }), | 3174 | CAST_EXPR => Expr::CastExpr(CastExpr { syntax }), |
3175 | CLOSURE_EXPR => Expr::ClosureExpr(ClosureExpr { syntax }), | ||
3179 | CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }), | 3176 | CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }), |
3180 | EFFECT_EXPR => Expr::EffectExpr(EffectExpr { syntax }), | 3177 | EFFECT_EXPR => Expr::EffectExpr(EffectExpr { syntax }), |
3181 | FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }), | 3178 | FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }), |
3182 | FOR_EXPR => Expr::ForExpr(ForExpr { syntax }), | 3179 | FOR_EXPR => Expr::ForExpr(ForExpr { syntax }), |
3183 | IF_EXPR => Expr::IfExpr(IfExpr { syntax }), | 3180 | IF_EXPR => Expr::IfExpr(IfExpr { syntax }), |
3184 | INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), | 3181 | INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), |
3185 | LABEL => Expr::Label(Label { syntax }), | ||
3186 | CLOSURE_EXPR => Expr::ClosureExpr(ClosureExpr { syntax }), | ||
3187 | LITERAL => Expr::Literal(Literal { syntax }), | 3182 | LITERAL => Expr::Literal(Literal { syntax }), |
3188 | LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }), | 3183 | LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }), |
3189 | MACRO_CALL => Expr::MacroCall(MacroCall { syntax }), | 3184 | MACRO_CALL => Expr::MacroCall(MacroCall { syntax }), |
@@ -3213,14 +3208,13 @@ impl AstNode for Expr { | |||
3213 | Expr::BreakExpr(it) => &it.syntax, | 3208 | Expr::BreakExpr(it) => &it.syntax, |
3214 | Expr::CallExpr(it) => &it.syntax, | 3209 | Expr::CallExpr(it) => &it.syntax, |
3215 | Expr::CastExpr(it) => &it.syntax, | 3210 | Expr::CastExpr(it) => &it.syntax, |
3211 | Expr::ClosureExpr(it) => &it.syntax, | ||
3216 | Expr::ContinueExpr(it) => &it.syntax, | 3212 | Expr::ContinueExpr(it) => &it.syntax, |
3217 | Expr::EffectExpr(it) => &it.syntax, | 3213 | Expr::EffectExpr(it) => &it.syntax, |
3218 | Expr::FieldExpr(it) => &it.syntax, | 3214 | Expr::FieldExpr(it) => &it.syntax, |
3219 | Expr::ForExpr(it) => &it.syntax, | 3215 | Expr::ForExpr(it) => &it.syntax, |
3220 | Expr::IfExpr(it) => &it.syntax, | 3216 | Expr::IfExpr(it) => &it.syntax, |
3221 | Expr::IndexExpr(it) => &it.syntax, | 3217 | Expr::IndexExpr(it) => &it.syntax, |
3222 | Expr::Label(it) => &it.syntax, | ||
3223 | Expr::ClosureExpr(it) => &it.syntax, | ||
3224 | Expr::Literal(it) => &it.syntax, | 3218 | Expr::Literal(it) => &it.syntax, |
3225 | Expr::LoopExpr(it) => &it.syntax, | 3219 | Expr::LoopExpr(it) => &it.syntax, |
3226 | Expr::MacroCall(it) => &it.syntax, | 3220 | Expr::MacroCall(it) => &it.syntax, |
@@ -3715,6 +3709,11 @@ impl std::fmt::Display for CastExpr { | |||
3715 | std::fmt::Display::fmt(self.syntax(), f) | 3709 | std::fmt::Display::fmt(self.syntax(), f) |
3716 | } | 3710 | } |
3717 | } | 3711 | } |
3712 | impl std::fmt::Display for ClosureExpr { | ||
3713 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3714 | std::fmt::Display::fmt(self.syntax(), f) | ||
3715 | } | ||
3716 | } | ||
3718 | impl std::fmt::Display for ContinueExpr { | 3717 | impl std::fmt::Display for ContinueExpr { |
3719 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3718 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3720 | std::fmt::Display::fmt(self.syntax(), f) | 3719 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3745,16 +3744,6 @@ impl std::fmt::Display for IndexExpr { | |||
3745 | std::fmt::Display::fmt(self.syntax(), f) | 3744 | std::fmt::Display::fmt(self.syntax(), f) |
3746 | } | 3745 | } |
3747 | } | 3746 | } |
3748 | impl std::fmt::Display for Label { | ||
3749 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3750 | std::fmt::Display::fmt(self.syntax(), f) | ||
3751 | } | ||
3752 | } | ||
3753 | impl std::fmt::Display for ClosureExpr { | ||
3754 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3755 | std::fmt::Display::fmt(self.syntax(), f) | ||
3756 | } | ||
3757 | } | ||
3758 | impl std::fmt::Display for LoopExpr { | 3747 | impl std::fmt::Display for LoopExpr { |
3759 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3748 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3760 | std::fmt::Display::fmt(self.syntax(), f) | 3749 | std::fmt::Display::fmt(self.syntax(), f) |
@@ -3820,6 +3809,11 @@ impl std::fmt::Display for WhileExpr { | |||
3820 | std::fmt::Display::fmt(self.syntax(), f) | 3809 | std::fmt::Display::fmt(self.syntax(), f) |
3821 | } | 3810 | } |
3822 | } | 3811 | } |
3812 | impl std::fmt::Display for Label { | ||
3813 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
3814 | std::fmt::Display::fmt(self.syntax(), f) | ||
3815 | } | ||
3816 | } | ||
3823 | impl std::fmt::Display for RecordExprFieldList { | 3817 | impl std::fmt::Display for RecordExprFieldList { |
3824 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3818 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3825 | std::fmt::Display::fmt(self.syntax(), f) | 3819 | std::fmt::Display::fmt(self.syntax(), f) |