Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update derive_more requirement to 1.0 #13

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
strategy:
fail-fast: false
matrix:
msrv: ["1.65.0"]
msrv: ["1.75.0"]
os: ["ubuntu", "macOS", "windows"]
runs-on: ${{ matrix.os }}-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ All user visible changes to `cucumber-expressions` crate will be documented in t

### BC Breaks

- Bumped up [MSRV] to 1.65 because of newer dependencies versions.
- Bumped up [MSRV] to 1.75 because of newer dependencies versions.



Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "cucumber-expressions"
version = "0.3.0"
edition = "2021"
rust-version = "1.65"
rust-version = "1.75"
description = "Cucumber Expressions AST and parser."
license = "MIT OR Apache-2.0"
authors = [
Expand All @@ -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", "debug", "deref", "deref_mut", "display", "error", "from", "into"] }
nom = "7.0"
nom_locate = "4.0"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
===============================

[![crates.io](https://img.shields.io/crates/v/cucumber-expressions.svg?maxAge=2592000 "crates.io")](https://crates.io/crates/cucumber-expressions)
[![Rust 1.65+](https://img.shields.io/badge/rustc-1.65+-lightgray.svg "Rust 1.65+")](https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html)
[![Rust 1.75+](https://img.shields.io/badge/rustc-1.75+-lightgray.svg "Rust 1.75+")](https://blog.rust-lang.org/2023/12/28/Rust-1.75.0.html)
[![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg "Unsafe forbidden")](https://github.com/rust-secure-code/safety-dance)
[![CI](https://github.com/cucumber-rs/cucumber-expressions/workflows/CI/badge.svg?branch=main "CI")](https://github.com/cucumber-rs/cucumber-expressions/actions?query=workflow%3ACI+branch%3Amaster)
[![Rust docs](https://docs.rs/cucumber-expressions/badge.svg "Rust docs")](https://docs.rs/cucumber-expressions)
Expand Down
2 changes: 1 addition & 1 deletion fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "cucumber-expressions-fuzz"
version = "0.0.0"
edition = "2021"
rust-version = "1.65"
rust-version = "1.75"
description = "Fuzz testing for `cucumber-expressions` crate."
license = "MIT OR Apache-2.0"
authors = [
Expand Down
56 changes: 21 additions & 35 deletions src/expand/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

pub mod parameters;

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

use derive_more::{Display, Error, From};
use derive_more::{Debug, Display, Error as StdError, From};
use either::Either;
use nom::{AsChar, InputIter};
use regex::Regex;
Expand Down Expand Up @@ -140,41 +140,38 @@ 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, From, StdError)]
pub enum Error<Input>
where
Input: fmt::Display,
Input: 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, StdError)]
pub enum ParameterError<Input>
where
Input: fmt::Display,
Input: Display,
{
/// [`Parameter`] not found.
#[display(fmt = "Parameter `{}` not found.", _0)]
#[display("Parameter `{_0}` not found")]
NotFound(Input),

/// Failed to rename [`Regex`] capturing group.
#[display(
fmt = "Failed to rename capturing groups in regex `{}` of \
parameter `{}`: {}",
re,
parameter,
err
"Failed to rename capturing groups in regex `{re}` of \
parameter `{parameter}`: {err}"
)]
RenameRegexGroup {
/// [`Parameter`] name.
Expand All @@ -196,8 +193,8 @@ where
/// [0]: https://github.com/cucumber/cucumber-expressions#readme
/// [1]: https://git.io/J159T
/// [AST]: https://en.wikipedia.org/wiki/Abstract_syntax_tree
pub trait IntoRegexCharIter<Input: fmt::Display> {
/// Type of an [`Iterator`] performing the expansion.
pub trait IntoRegexCharIter<Input: Display> {
/// Type of [`Iterator`] performing the expansion.
type Iter: Iterator<Item = Result<char, ParameterError<Input>>>;

/// Consumes this [AST] element returning an [`Iterator`] over [`char`]s
Expand All @@ -209,7 +206,7 @@ pub trait IntoRegexCharIter<Input: fmt::Display> {

impl<Input> IntoRegexCharIter<Input> for Expression<Input>
where
Input: Clone + fmt::Display + InputIter,
Input: Clone + Display + InputIter,
<Input as InputIter>::Item: AsChar,
{
type Iter = ExpressionIter<Input>;
Expand Down Expand Up @@ -244,7 +241,7 @@ type ExpressionIter<Input> = iter::Chain<

impl<Input> IntoRegexCharIter<Input> for SingleExpression<Input>
where
Input: Clone + fmt::Display + InputIter,
Input: Clone + Display + InputIter,
<Input as InputIter>::Item: AsChar,
{
type Iter = SingleExpressionIter<Input>;
Expand Down Expand Up @@ -290,7 +287,7 @@ type SingleExpressionIter<Input> = Either<

impl<Input> IntoRegexCharIter<Input> for Alternation<Input>
where
Input: fmt::Display + InputIter,
Input: Display + InputIter,
<Input as InputIter>::Item: AsChar,
{
type Iter = AlternationIter<Input>;
Expand Down Expand Up @@ -345,7 +342,7 @@ type AlternationIterInner<I> = iter::Chain<

impl<Input> IntoRegexCharIter<Input> for Alternative<Input>
where
Input: fmt::Display + InputIter,
Input: Display + InputIter,
<Input as InputIter>::Item: AsChar,
{
type Iter = AlternativeIter<Input>;
Expand Down Expand Up @@ -382,7 +379,7 @@ type AlternativeIter<Input> = Either<

impl<Input> IntoRegexCharIter<Input> for Optional<Input>
where
Input: fmt::Display + InputIter,
Input: Display + InputIter,
<Input as InputIter>::Item: AsChar,
{
type Iter = OptionalIter<Input>;
Expand Down Expand Up @@ -422,7 +419,7 @@ type MapOkChar<Input> = fn(char) -> Result<char, ParameterError<Input>>;

impl<Input> IntoRegexCharIter<Input> for Parameter<Input>
where
Input: Clone + fmt::Display + InputIter,
Input: Clone + Display + InputIter,
<Input as InputIter>::Item: AsChar,
{
type Iter = ParameterIter<Input>;
Expand Down Expand Up @@ -490,6 +487,7 @@ type ParameterIter<Input> = Either<
/// [`Iterator`] for skipping a last [`Item`].
///
/// [`Item`]: Iterator::Item
#[derive(Debug)]
pub struct SkipLast<Iter: Iterator> {
/// Inner [`Iterator`] to skip the last [`Item`] from.
///
Expand All @@ -509,18 +507,6 @@ where
}
}

impl<Iter> fmt::Debug for SkipLast<Iter>
where
Iter: fmt::Debug + Iterator,
Iter::Item: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SkipLast")
.field("iter", &self.iter)
.finish()
}
}

impl<Iter: Iterator> SkipLast<Iter> {
/// Creates a new [`SkipLast`] [`Iterator`].
pub fn new(iter: Iter) -> Self {
Expand Down
5 changes: 2 additions & 3 deletions src/expand/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,8 @@ mod regex_hir {
HirKind::Look(l) => Hir::look(l),
HirKind::Repetition(rep) => Hir::repetition(rep),
HirKind::Capture(mut capture) => {
capture.name = Some(
format!("__{parameter_id}_{}", *group_id_indexer).into(),
);
capture.name =
Some(format!("__{parameter_id}_{group_id_indexer}").into());
*group_id_indexer += 1;

let inner_hir =
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@
unused_results,
variant_size_differences
)]
// TODO: Remove on next `derive_more` major version.
#![allow(clippy::uninlined_format_args)]

pub mod ast;
mod combinator;
Expand Down
Loading
Loading