Satisfy clippy
This commit is contained in:
parent
f3792fae64
commit
64c41b1073
3 changed files with 8 additions and 7 deletions
|
|
@ -13,7 +13,8 @@ fn from_str_via_parse<P, R>(s: &str, rule: Rule, parse: P) -> result::Result<R,
|
||||||
where
|
where
|
||||||
P: FnOnce(Pair<'_, Rule>) -> Result<R>,
|
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();
|
let p = pairs.next().unwrap();
|
||||||
assert_eq!(pairs.next(), None);
|
assert_eq!(pairs.next(), None);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ use super::{parse, FileSource, Files};
|
||||||
#[error("{error}")]
|
#[error("{error}")]
|
||||||
pub struct ParseError<S> {
|
pub struct ParseError<S> {
|
||||||
file: S,
|
file: S,
|
||||||
error: parse::Error,
|
error: Box<parse::Error>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S> ParseError<S> {
|
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 }
|
Self { file, error }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,7 +104,7 @@ pub enum Error {
|
||||||
#[error("{error}")]
|
#[error("{error}")]
|
||||||
Parse {
|
Parse {
|
||||||
file: FileSource,
|
file: FileSource,
|
||||||
error: parse::Error,
|
error: Box<parse::Error>,
|
||||||
},
|
},
|
||||||
#[error("Conflicting time zones {tz1} and {tz2}")]
|
#[error("Conflicting time zones {tz1} and {tz2}")]
|
||||||
TzConflict {
|
TzConflict {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ use super::primitives::{Spanned, Time, Weekday};
|
||||||
pub struct TodayfileParser;
|
pub struct TodayfileParser;
|
||||||
|
|
||||||
pub type Error = pest::error::Error<Rule>;
|
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 {
|
fn error<S: Into<String>>(span: Span<'_>, message: S) -> Error {
|
||||||
Error::new_from_span(
|
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> {
|
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> {
|
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();
|
let file_pair = pairs.next().unwrap();
|
||||||
assert_eq!(pairs.next(), None);
|
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)))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue