diff options
author | Aleksey Kladov <[email protected]> | 2020-03-12 14:40:53 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-12 14:40:53 +0000 |
commit | afd64ef4f75844ff61bc5967406f40ec90047348 (patch) | |
tree | b3a58cfdd1f4ca8dd78902351ed8a45cf1f7922d /xtask | |
parent | 05b4fc6d79060fc3120f92b01119e3a851c37829 (diff) | |
parent | 31eec5e80c1a9a263482dfc9601f4cfc61e9e24b (diff) |
Merge pull request #3562 from FireofGods/display_for_node
Add `std::fmt::Display` as a supertrait for `AstNode`
Diffstat (limited to 'xtask')
-rw-r--r-- | xtask/src/codegen/gen_syntax.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index db05dcebb..32afd47bc 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs | |||
@@ -68,6 +68,12 @@ fn generate_ast(grammar: AstSrc<'_>) -> Result<String> { | |||
68 | pub(crate) syntax: SyntaxNode, | 68 | pub(crate) syntax: SyntaxNode, |
69 | } | 69 | } |
70 | 70 | ||
71 | impl std::fmt::Display for #name { | ||
72 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
73 | std::fmt::Display::fmt(self.syntax(), f) | ||
74 | } | ||
75 | } | ||
76 | |||
71 | impl AstNode for #name { | 77 | impl AstNode for #name { |
72 | fn can_cast(kind: SyntaxKind) -> bool { | 78 | fn can_cast(kind: SyntaxKind) -> bool { |
73 | match kind { | 79 | match kind { |
@@ -114,6 +120,12 @@ fn generate_ast(grammar: AstSrc<'_>) -> Result<String> { | |||
114 | } | 120 | } |
115 | )* | 121 | )* |
116 | 122 | ||
123 | impl std::fmt::Display for #name { | ||
124 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
125 | std::fmt::Display::fmt(self.syntax(), f) | ||
126 | } | ||
127 | } | ||
128 | |||
117 | impl AstNode for #name { | 129 | impl AstNode for #name { |
118 | fn can_cast(kind: SyntaxKind) -> bool { | 130 | fn can_cast(kind: SyntaxKind) -> bool { |
119 | match kind { | 131 | match kind { |