From a74bf89df52f184b689fab204c35fccde11b6183 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Wed, 17 Apr 2024 22:14:12 +0900 Subject: [PATCH] revset: reuse parse_symbol_rule_as_literal() to parse string symbol For the same reason as the previous commit. Single-quoted string literal will be handled there. --- lib/src/revset.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/src/revset.rs b/lib/src/revset.rs index 9b2006e07..3e62c6b67 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -1082,10 +1082,10 @@ fn parse_string_pattern_rule( /// Parses symbol to expression, expands aliases as needed. fn parse_symbol_rule( - mut pairs: Pairs, + pairs: Pairs, state: ParseState, ) -> Result, RevsetParseError> { - let first = pairs.next().unwrap(); + let first = pairs.peek().unwrap(); match first.as_rule() { Rule::identifier => { let name = first.as_str(); @@ -1101,11 +1101,9 @@ fn parse_symbol_rule( Ok(RevsetExpression::symbol(name.to_owned())) } } - Rule::string_literal => Ok(RevsetExpression::symbol( - STRING_LITERAL_PARSER.parse(first.into_inner()), - )), _ => { - panic!("unexpected symbol parse rule: {:?}", first.as_str()); + let text = parse_symbol_rule_as_literal(pairs); + Ok(RevsetExpression::symbol(text)) } } }