Skip to content

Commit

Permalink
refactor(parser): Rely on ErrMode implementing traits
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jul 10, 2023
1 parent e77ba0e commit dde0404
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
7 changes: 1 addition & 6 deletions crates/toml_edit/src/parser/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use winnow::combinator::eof;
use winnow::combinator::opt;
use winnow::combinator::peek;
use winnow::combinator::repeat;
use winnow::error::FromExternalError;
use winnow::token::any;
use winnow::token::one_of;

Expand Down Expand Up @@ -57,11 +56,7 @@ pub(crate) fn document(input: Input<'_>) -> IResult<Input<'_>, Document, Context
.into_document()
.map(|document| (i, document))
.map_err(|err| {
winnow::error::ErrMode::Backtrack(ContextError::from_external_error(
i,
winnow::error::ErrorKind::Verify,
err,
))
winnow::error::ErrMode::from_external_error(i, winnow::error::ErrorKind::Verify, err)
})
}

Expand Down
11 changes: 5 additions & 6 deletions crates/toml_edit/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ pub(crate) mod prelude {
pub(crate) use super::errors::StrContext;
pub(crate) use super::errors::StrContextValue;
pub(crate) use winnow::combinator::dispatch;
pub(crate) use winnow::error::FromExternalError;
pub(crate) use winnow::IResult;
pub(crate) use winnow::Parser;

Expand Down Expand Up @@ -120,12 +121,10 @@ pub(crate) mod prelude {
if self.current < 128 {
Ok(self)
} else {
Err(winnow::error::ErrMode::Backtrack(
winnow::error::FromExternalError::from_external_error(
input,
winnow::error::ErrorKind::Eof,
super::errors::CustomError::RecursionLimitExceeded,
),
Err(winnow::error::ErrMode::from_external_error(
input,
winnow::error::ErrorKind::Eof,
super::errors::CustomError::RecursionLimitExceeded,
))
}
}
Expand Down

0 comments on commit dde0404

Please sign in to comment.