From f7993f0fe9ecdba1927737f1c53ac06732f0c248 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sat, 28 Jan 2023 19:02:07 +0900 Subject: [PATCH] templater: eliminate whitespace nodes from parse tree --- src/template.pest | 2 +- src/template_parser.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/template.pest b/src/template.pest index 12cccf553..34dbb83ee 100644 --- a/src/template.pest +++ b/src/template.pest @@ -17,7 +17,7 @@ // predecessors % ("predecessor: " commit_id) // parents % (commit_id " is a parent of " super.commit_id) -whitespace = { " " | "\n" } +whitespace = _{ " " | "\n" } escape = @{ "\\" ~ ("n" | "\"" | "\\") } literal_char = @{ !("\"" | "\\") ~ ANY } diff --git a/src/template_parser.rs b/src/template_parser.rs index 494e0d748..348868495 100644 --- a/src/template_parser.rs +++ b/src/template_parser.rs @@ -374,7 +374,7 @@ fn parse_commit_template_rule<'a>( } Box::new(ListTemplate(formatters)) } - _ => Box::new(Literal(String::new())), + other => panic!("unexpected template rule: {other:?}"), } }