Skip to content

Commit

Permalink
Update derive_more requirement to 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb committed Aug 17, 2024
1 parent 58f4d28 commit 78aba71
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ rustdoc-args = ["--cfg", "docsrs"]
into-regex = ["dep:either", "dep:regex", "dep:regex-syntax"]

[dependencies]
derive_more = { version = "0.99.17", features = ["as_ref", "deref", "deref_mut", "display", "error", "from", "into"], default-features = false }
derive_more = { version = "1.0", features = ["as_ref", "deref", "deref_mut", "display", "error", "from", "into"] }
nom = "7.0"
nom_locate = "4.0"

Expand Down
16 changes: 8 additions & 8 deletions src/expand/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub mod parameters;

use std::{fmt, iter, str, vec};

use derive_more::{Display, Error, From};
use derive_more::{Display, Error as DeriveError, From};
use either::Either;
use nom::{AsChar, InputIter};
use regex::Regex;
Expand Down Expand Up @@ -140,37 +140,37 @@ impl<'s> Expression<Spanned<'s>> {
/// [Cucumber Expression][0] and expanding it into a [`Regex`].
///
/// [0]: https://github.com/cucumber/cucumber-expressions#readme
#[derive(Clone, Debug, Display, Error, From)]
#[derive(Clone, Debug, Display, DeriveError, From)]
pub enum Error<Input>
where
Input: fmt::Display,
{
/// Parsing error.
#[display(fmt = "Parsing failed: {}", _0)]
#[display("Parsing failed: {}", _0)]
Parsing(parse::Error<Input>),

/// Expansion error.
#[display(fmt = "Failed to expand regex: {}", _0)]
#[display("Failed to expand regex: {}", _0)]
Expansion(ParameterError<Input>),

/// [`Regex`] creation error.
#[display(fmt = "Regex creation failed: {}", _0)]
#[display("Regex creation failed: {}", _0)]
Regex(regex::Error),
}

/// Possible [`Parameter`] errors being used in an [`Expression`].
#[derive(Clone, Debug, Display, Error)]
#[derive(Clone, Debug, Display, DeriveError)]
pub enum ParameterError<Input>
where
Input: fmt::Display,
{
/// [`Parameter`] not found.
#[display(fmt = "Parameter `{}` not found.", _0)]
#[display("Parameter `{}` not found.", _0)]
NotFound(Input),

/// Failed to rename [`Regex`] capturing group.
#[display(
fmt = "Failed to rename capturing groups in regex `{}` of \
"Failed to rename capturing groups in regex `{}` of \
parameter `{}`: {}",
re,
parameter,
Expand Down
34 changes: 17 additions & 17 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use std::{fmt::Display, ops::RangeFrom};

use derive_more::{Display, Error};
use derive_more::{Display as DeriveDisplay, Error as DeriveError};
use nom::{
branch::alt,
bytes::complete::{tag, take_while, take_while1},
Expand Down Expand Up @@ -623,14 +623,14 @@ where
}

/// Possible parsing errors.
#[derive(Clone, Copy, Debug, Display, Error, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, DeriveDisplay, DeriveError, Eq, PartialEq)]
pub enum Error<Input>
where
Input: Display,
{
/// Nested [`Parameter`]s.
#[display(
fmt = "{}\n\
"{}\n\
A parameter may not contain an other parameter.\n\
If you did not mean to use an optional type you can use '\\{{' \
to escape the '{{'. For more complicated expressions consider \
Expand All @@ -641,7 +641,7 @@ where

/// [`Optional`] inside a [`Parameter`].
#[display(
fmt = "{}\n\
"{}\n\
A parameter may not contain an optional.\n\
If you did not mean to use an parameter type you can use '\\(' \
to escape the '('.",
Expand All @@ -651,7 +651,7 @@ where

/// Unfinished [`Parameter`].
#[display(
fmt = "{}\n\
"{}\n\
The '{{' does not have a matching '}}'.\n\
If you did not intend to use a parameter you can use '\\{{' to \
escape the '{{'.",
Expand All @@ -661,7 +661,7 @@ where

/// Nested [`Optional`].
#[display(
fmt = "{}\n\
"{}\n\
An optional may not contain an other optional.\n\
If you did not mean to use an optional type you can use '\\(' \
to escape the '('. For more complicated expressions consider \
Expand All @@ -672,7 +672,7 @@ where

/// [`Parameter`] inside an [`Optional`].
#[display(
fmt = "{}\n\
"{}\n\
An optional may not contain a parameter.\n\
If you did not mean to use an parameter type you can use \
'\\{{' to escape the '{{'.",
Expand All @@ -682,7 +682,7 @@ where

/// Empty [`Optional`].
#[display(
fmt = "{}\n\
"{}\n\
An optional must contain some text.\n\
If you did not mean to use an optional you can use '\\(' to \
escape the '('.",
Expand All @@ -692,7 +692,7 @@ where

/// [`Alternation`] inside an [`Optional`].
#[display(
fmt = "{}\n\
"{}\n\
An alternation can not be used inside an optional.\n\
You can use '\\/' to escape the '/'.",
_0
Expand All @@ -701,7 +701,7 @@ where

/// Unfinished [`Optional`].
#[display(
fmt = "{}\n\
"{}\n\
The '(' does not have a matching ')'.\n\
If you did not intend to use an optional you can use '\\(' to \
escape the '('.",
Expand All @@ -711,7 +711,7 @@ where

/// Empty [`Alternation`].
#[display(
fmt = "{}\n\
"{}\n\
An alternation can not be empty.\n\
If you did not mean to use an alternative you can use '\\/' to \
escape the '/'.",
Expand All @@ -721,7 +721,7 @@ where

/// Only [`Optional`] inside [`Alternation`].
#[display(
fmt = "{}\n\
"{}\n\
An alternation may not exclusively contain optionals.\n\
If you did not mean to use an optional you can use '\\(' to \
escape the '('.",
Expand All @@ -731,7 +731,7 @@ where

/// Unescaped [`RESERVED_CHARS`].
#[display(
fmt = "{}\n\
"{}\n\
Unescaped reserved character.\n\
You can use an '\\' to escape it.",
_0
Expand All @@ -740,7 +740,7 @@ where

/// Escaped non-[`RESERVED_CHARS`].
#[display(
fmt = "{}\n\
"{}\n\
Only the characters '{{', '}}', '(', ')', '\\', '/' and \
whitespace can be escaped.\n\
If you did mean to use an '\\' you can use '\\\\' to escape it.",
Expand All @@ -750,7 +750,7 @@ where

/// Escaped EOL.
#[display(
fmt = "{}\n\
"{}\n\
The end of line can not be escaped.\n\
You can use '\\' to escape the the '\'.",
_0
Expand All @@ -759,15 +759,15 @@ where

/// Unknown error.
#[display(
fmt = "{}\n\
"{}\n\
Unknown parsing error.",
_0
)]
Other(#[error(not(source))] Input, ErrorKind),

/// Parsing requires more data.
#[display(
fmt = "{}",
"{}",
"match _0 {\
Needed::Size(n) => format!(\"Parsing requires {n} bytes/chars\"),\
Needed::Unknown => \"Parsing requires more data\".to_owned(),\
Expand Down

0 comments on commit 78aba71

Please sign in to comment.