ok/jj
1
0
Fork 0
forked from mirrors/jj

revset: wrap pest error in a Box, to keep type small

A newer version of Clippy starts complianing that the type is too
large (>=184 bytes) otherwise.
This commit is contained in:
Martin von Zweigbergk 2022-10-09 10:25:09 -07:00 committed by Martin von Zweigbergk
parent af4d183c7e
commit d8c8283782

View file

@ -191,7 +191,7 @@ pub struct RevsetParser;
#[derive(Debug, Error, PartialEq, Eq)] #[derive(Debug, Error, PartialEq, Eq)]
pub enum RevsetParseError { pub enum RevsetParseError {
#[error("{0}")] #[error("{0}")]
SyntaxError(#[from] pest::error::Error<Rule>), SyntaxError(#[from] Box<pest::error::Error<Rule>>),
#[error("Revset function \"{0}\" doesn't exist")] #[error("Revset function \"{0}\" doesn't exist")]
NoSuchFunction(String), NoSuchFunction(String),
#[error("Invalid arguments to revset function \"{name}\": {message}")] #[error("Invalid arguments to revset function \"{name}\": {message}")]
@ -794,7 +794,8 @@ fn parse_function_argument_to_string(
} }
pub fn parse(revset_str: &str) -> Result<Rc<RevsetExpression>, RevsetParseError> { pub fn parse(revset_str: &str) -> Result<Rc<RevsetExpression>, RevsetParseError> {
let mut pairs = RevsetParser::parse(Rule::expression, revset_str)?; let mut pairs = RevsetParser::parse(Rule::expression, revset_str)
.map_err(|err| RevsetParseError::SyntaxError(Box::new(err)))?;
let first = pairs.next().unwrap(); let first = pairs.next().unwrap();
assert!(pairs.next().is_none()); assert!(pairs.next().is_none());
if first.as_span().end() != revset_str.len() { if first.as_span().end() != revset_str.len() {
@ -805,7 +806,7 @@ pub fn parse(revset_str: &str) -> Result<Rc<RevsetExpression>, RevsetParseError>
}, },
pos, pos,
); );
return Err(RevsetParseError::SyntaxError(err)); return Err(RevsetParseError::SyntaxError(Box::new(err)));
} }
parse_expression_rule(first.into_inner()) parse_expression_rule(first.into_inner())