From 787043496aaa05be31162a8cdd0686a13da646cc Mon Sep 17 00:00:00 2001 From: Fireassember Date: Fri, 6 Mar 2020 19:29:30 +0200 Subject: added fmt::Display as a supertrait for AstNode and changed generation. --- xtask/src/codegen/gen_syntax.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'xtask') diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index db05dcebb..879f0243e 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 { pub(crate) syntax: SyntaxNode, } + impl std::fmt::Display for #name { + fn fmt(..) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax()) + } + } + impl AstNode for #name { fn can_cast(kind: SyntaxKind) -> bool { match kind { -- cgit v1.2.3 From 31eec5e80c1a9a263482dfc9601f4cfc61e9e24b Mon Sep 17 00:00:00 2001 From: Fireassember Date: Wed, 11 Mar 2020 22:54:24 +0200 Subject: implementing Display for enums too. --- xtask/src/codegen/gen_syntax.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'xtask') diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index 879f0243e..32afd47bc 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs @@ -69,8 +69,8 @@ fn generate_ast(grammar: AstSrc<'_>) -> Result { } impl std::fmt::Display for #name { - fn fmt(..) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax()) + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) } } @@ -120,6 +120,12 @@ fn generate_ast(grammar: AstSrc<'_>) -> Result { } )* + impl std::fmt::Display for #name { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } + } + impl AstNode for #name { fn can_cast(kind: SyntaxKind) -> bool { match kind { -- cgit v1.2.3