Skip to content

Commit

Permalink
Migrate to 2021 Rust edition
Browse files Browse the repository at this point in the history
- bump up MSRV to 1.56.0
- remove explicit `#[doc(cfg(...))]` attribute usage where it's implied by `#[cfg(...)]` (rust-lang/rust#89596)
  • Loading branch information
tyranron committed Oct 25, 2021
1 parent 0a041c2 commit 3541120
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
strategy:
fail-fast: false
matrix:
msrv: ['1.54.0']
msrv: ['1.56.0']
crate:
- cucumber-codegen
- cucumber
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "cucumber"
version = "0.10.0"
edition = "2018"
resolver = "2"
edition = "2021"
rust-version = "1.56"
description = """\
Cucumber testing framework for Rust, with async support. \
Fully native, no external test runners or dependencies.\
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Cucumber testing framework for Rust

[![Documentation](https://docs.rs/cucumber/badge.svg)](https://docs.rs/cucumber)
[![Actions Status](https://github.com/cucumber-rs/cucumber/workflows/CI/badge.svg)](https://github.com/cucumber-rs/cucumber/actions)
[![Rust 1.54+](https://img.shields.io/badge/rustc-1.54+-lightgray.svg "Rust 1.54+")](https://blog.rust-lang.org/2021/07/29/Rust-1.54.0.html)
[![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance/)
[![Rust 1.56+](https://img.shields.io/badge/rustc-1.56+-lightgray.svg "Rust 1.56+")](https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html)
[![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance)

An implementation of the [Cucumber] testing framework for Rust. Fully native, no external test runners or dependencies.

Expand Down
3 changes: 1 addition & 2 deletions book/tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[package]
name = "cucumber-book-tests"
version = "0.0.0"
edition = "2018"
resolver = "2"
edition = "2021"
authors = [
"Brendan Molloy <brendan@bbqsrc.net>",
"Ilya Solovyiov <ilya.solovyiov@gmail.com>",
Expand Down
4 changes: 2 additions & 2 deletions codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "cucumber-codegen"
version = "0.10.0" # should be the same as main crate version
edition = "2018"
resolver = "2"
edition = "2021"
rust-version = "1.56"
description = "Code generation for `cucumber` crate."
license = "MIT OR Apache-2.0"
authors = [
Expand Down
9 changes: 7 additions & 2 deletions codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@
variant_size_differences
)]

use proc_macro::TokenStream;

mod attribute;
mod derive;

use proc_macro::TokenStream;

/// Helper macro for generating public shims for [`macro@given`], [`macro@when`]
/// and [`macro@then`] attributes.
macro_rules! step_attribute {
($name:ident) => {
/// Attribute to auto-wire the test to the [`World`] implementer.
Expand Down Expand Up @@ -195,6 +197,9 @@ macro_rules! step_attribute {
};
}

/// Helper macro for generating public shim of [`macro@WorldInit`] deriving
/// macro consistently with the ones of [`macro@given`], [`macro@when`] and
/// [`macro@then`] attributes.
macro_rules! steps {
($($name:ident),*) => {
/// Derive macro for tests auto-wiring.
Expand Down
8 changes: 2 additions & 6 deletions src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
use std::{fmt::Debug, path::Path};

use async_trait::async_trait;

use crate::{cucumber::DefaultCucumber, step, Cucumber, Step, World};

pub use futures::future::LocalBoxFuture;
pub use inventory::{self, collect, submit};
pub use regex::Regex;

use crate::{cucumber::DefaultCucumber, step, Cucumber, Step, World};

/// [`World`] extension with auto-wiring capabilities.
#[async_trait(?Send)]
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
pub trait WorldInit<G, W, T>: WorldInventory<G, W, T>
where
Self: Debug,
Expand Down Expand Up @@ -124,7 +122,6 @@ where
}

/// [`World`] extension allowing to register steps in [`inventory`].
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
pub trait WorldInventory<G, W, T>: World
where
G: StepConstructor<Self> + inventory::Collect,
Expand Down Expand Up @@ -186,7 +183,6 @@ where
/// [`given`]: crate::given
/// [`when`]: crate::when
/// [`then`]: crate::then
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
pub trait StepConstructor<W> {
/// Creates a new [`Step`] with the corresponding [`Regex`].
#[must_use]
Expand Down
18 changes: 9 additions & 9 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ impl<World> Cucumber<World> {
scenario: Arc<gherkin::Scenario>,
event: Scenario<World>,
) -> Self {
#[allow(clippy::option_if_let_else)] // use of moved value: `event`
if let Some(r) = rule {
Self::Feature(
feat,
Feature::Rule(r, Rule::Scenario(scenario, event)),
)
} else {
Self::Feature(feat, Feature::Scenario(scenario, event))
}
Self::Feature(
feat,
#[allow(clippy::option_if_let_else)] // use of moved value: `event`
if let Some(r) = rule {
Feature::Rule(r, Rule::Scenario(scenario, event))
} else {
Feature::Scenario(scenario, event)
},
)
}
}

Expand Down
34 changes: 15 additions & 19 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,34 +97,18 @@
)]
#![cfg_attr(docsrs, feature(doc_cfg))]

pub mod cli;
mod cucumber;
pub mod event;
pub mod feature;
pub mod parser;
pub mod runner;
pub mod step;
pub mod writer;

#[cfg(feature = "macros")]
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
pub mod codegen;

use std::error::Error as StdError;

use async_trait::async_trait;

pub use gherkin;

#[cfg(feature = "macros")]
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
#[doc(inline)]
pub use self::codegen::WorldInit;
#[cfg(feature = "macros")]
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
#[doc(inline)]
pub use cucumber_codegen::{given, then, when, WorldInit};

#[cfg(feature = "macros")]
#[doc(inline)]
pub use self::codegen::WorldInit;
#[doc(inline)]
pub use self::{
cucumber::Cucumber,
Expand All @@ -137,6 +121,18 @@ pub use self::{
},
};

pub mod cli;
mod cucumber;
pub mod event;
pub mod feature;
pub mod parser;
pub mod runner;
pub mod step;
pub mod writer;

#[cfg(feature = "macros")]
pub mod codegen;

/// Represents a shared user-defined state for a [Cucumber] run.
/// It lives on per-[scenario][0] basis.
///
Expand Down

0 comments on commit 3541120

Please sign in to comment.