Satisfy clippy

This commit is contained in:
Joscha 2023-02-11 21:50:38 +01:00
parent f3792fae64
commit 64c41b1073
3 changed files with 8 additions and 7 deletions

View file

@ -13,7 +13,8 @@ fn from_str_via_parse<P, R>(s: &str, rule: Rule, parse: P) -> result::Result<R,
where
P: FnOnce(Pair<'_, Rule>) -> Result<R>,
{
let mut pairs = TodayfileParser::parse(rule, s).map_err(|e| ParseError::new((), e))?;
let mut pairs =
TodayfileParser::parse(rule, s).map_err(|e| ParseError::new((), Box::new(e)))?;
let p = pairs.next().unwrap();
assert_eq!(pairs.next(), None);

View file

@ -15,11 +15,11 @@ use super::{parse, FileSource, Files};
#[error("{error}")]
pub struct ParseError<S> {
file: S,
error: parse::Error,
error: Box<parse::Error>,
}
impl<S> ParseError<S> {
pub fn new(file: S, error: parse::Error) -> Self {
pub fn new(file: S, error: Box<parse::Error>) -> Self {
Self { file, error }
}
@ -104,7 +104,7 @@ pub enum Error {
#[error("{error}")]
Parse {
file: FileSource,
error: parse::Error,
error: Box<parse::Error>,
},
#[error("Conflicting time zones {tz1} and {tz2}")]
TzConflict {

View file

@ -18,7 +18,7 @@ use super::primitives::{Spanned, Time, Weekday};
pub struct TodayfileParser;
pub type Error = pest::error::Error<Rule>;
pub type Result<T> = result::Result<T, Error>;
pub type Result<T> = result::Result<T, Box<Error>>;
fn error<S: Into<String>>(span: Span<'_>, message: S) -> Error {
Error::new_from_span(
@ -30,7 +30,7 @@ fn error<S: Into<String>>(span: Span<'_>, message: S) -> Error {
}
fn fail<S: Into<String>, T>(span: Span<'_>, message: S) -> Result<T> {
Err(error(span, message))
Err(Box::new(error(span, message)))
}
fn parse_include(p: Pair<'_, Rule>) -> Spanned<String> {
@ -851,5 +851,5 @@ pub fn parse(path: &Path, input: &str) -> Result<File> {
let file_pair = pairs.next().unwrap();
assert_eq!(pairs.next(), None);
parse_file(file_pair).map_err(|e| e.with_path(&pathstr))
parse_file(file_pair).map_err(|e| Box::new(e.with_path(&pathstr)))
}