Skip to content

Commit 1920683

Browse files
committed
Migrate to 2021 Rust edition
- bump up MSRV to 1.56.0 - remove explicit `#[doc(cfg(...))]` attribute usage where it's implied by `#[cfg(...)]` (rust-lang/rust#89596)
1 parent 0a041c2 commit 1920683

File tree

9 files changed

+41
-45
lines changed

9 files changed

+41
-45
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
strategy:
6262
fail-fast: false
6363
matrix:
64-
msrv: ['1.54.0']
64+
msrv: ['1.56.0']
6565
crate:
6666
- cucumber-codegen
6767
- cucumber

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "cucumber"
33
version = "0.10.0"
4-
edition = "2018"
5-
resolver = "2"
4+
edition = "2021"
5+
rust-version = "1.56"
66
description = """\
77
Cucumber testing framework for Rust, with async support. \
88
Fully native, no external test runners or dependencies.\

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Cucumber testing framework for Rust
33

44
[![Documentation](https://docs.rs/cucumber/badge.svg)](https://docs.rs/cucumber)
55
[![Actions Status](https://github.com/cucumber-rs/cucumber/workflows/CI/badge.svg)](https://github.com/cucumber-rs/cucumber/actions)
6-
[![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)
7-
[![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance/)
6+
[![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)
7+
[![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance)
88

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

book/tests/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
[package]
22
name = "cucumber-book-tests"
33
version = "0.0.0"
4-
edition = "2018"
5-
resolver = "2"
4+
edition = "2021"
65
authors = [
76
"Brendan Molloy <[email protected]>",
87
"Ilya Solovyiov <[email protected]>",

codegen/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "cucumber-codegen"
33
version = "0.10.0" # should be the same as main crate version
4-
edition = "2018"
5-
resolver = "2"
4+
edition = "2021"
5+
rust-version = "1.56"
66
description = "Code generation for `cucumber` crate."
77
license = "MIT OR Apache-2.0"
88
authors = [

codegen/src/lib.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,13 @@
9393
variant_size_differences
9494
)]
9595

96+
use proc_macro::TokenStream;
97+
9698
mod attribute;
9799
mod derive;
98100

99-
use proc_macro::TokenStream;
100-
101+
/// Helper macro for generating public shims for [`macro@given`], [`macro@when`]
102+
/// and [`macro@then`] attributes.
101103
macro_rules! step_attribute {
102104
($name:ident) => {
103105
/// Attribute to auto-wire the test to the [`World`] implementer.
@@ -195,6 +197,9 @@ macro_rules! step_attribute {
195197
};
196198
}
197199

200+
/// Helper macro for generating public shim of [`macro@WorldInit`] deriving
201+
/// macro consistently with the ones of [`macro@given`], [`macro@when`] and
202+
/// [`macro@then`] attributes.
198203
macro_rules! steps {
199204
($($name:ident),*) => {
200205
/// Derive macro for tests auto-wiring.

src/codegen.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@
1313
use std::{fmt::Debug, path::Path};
1414

1515
use async_trait::async_trait;
16-
17-
use crate::{cucumber::DefaultCucumber, step, Cucumber, Step, World};
18-
1916
pub use futures::future::LocalBoxFuture;
2017
pub use inventory::{self, collect, submit};
2118
pub use regex::Regex;
2219

20+
use crate::{Cucumber, cucumber::DefaultCucumber, step, Step, World};
21+
2322
/// [`World`] extension with auto-wiring capabilities.
2423
#[async_trait(?Send)]
25-
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
2624
pub trait WorldInit<G, W, T>: WorldInventory<G, W, T>
2725
where
2826
Self: Debug,
@@ -124,7 +122,6 @@ where
124122
}
125123

126124
/// [`World`] extension allowing to register steps in [`inventory`].
127-
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
128125
pub trait WorldInventory<G, W, T>: World
129126
where
130127
G: StepConstructor<Self> + inventory::Collect,
@@ -186,7 +183,6 @@ where
186183
/// [`given`]: crate::given
187184
/// [`when`]: crate::when
188185
/// [`then`]: crate::then
189-
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
190186
pub trait StepConstructor<W> {
191187
/// Creates a new [`Step`] with the corresponding [`Regex`].
192188
#[must_use]

src/event.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ impl<World> Cucumber<World> {
104104
scenario: Arc<gherkin::Scenario>,
105105
event: Scenario<World>,
106106
) -> Self {
107-
#[allow(clippy::option_if_let_else)] // use of moved value: `event`
108-
if let Some(r) = rule {
109-
Self::Feature(
110-
feat,
111-
Feature::Rule(r, Rule::Scenario(scenario, event)),
112-
)
113-
} else {
114-
Self::Feature(feat, Feature::Scenario(scenario, event))
115-
}
107+
Self::Feature(
108+
feat,
109+
#[allow(clippy::option_if_let_else)] // use of moved value: `event`
110+
if let Some(r) = rule {
111+
Feature::Rule(r, Rule::Scenario(scenario, event))
112+
} else {
113+
Feature::Scenario(scenario, event)
114+
},
115+
)
116116
}
117117
}
118118

src/lib.rs

+15-19
Original file line numberDiff line numberDiff line change
@@ -97,31 +97,12 @@
9797
)]
9898
#![cfg_attr(docsrs, feature(doc_cfg))]
9999

100-
pub mod cli;
101-
mod cucumber;
102-
pub mod event;
103-
pub mod feature;
104-
pub mod parser;
105-
pub mod runner;
106-
pub mod step;
107-
pub mod writer;
108-
109-
#[cfg(feature = "macros")]
110-
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
111-
pub mod codegen;
112-
113100
use std::error::Error as StdError;
114101

115102
use async_trait::async_trait;
116-
117103
pub use gherkin;
118104

119105
#[cfg(feature = "macros")]
120-
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
121-
#[doc(inline)]
122-
pub use self::codegen::WorldInit;
123-
#[cfg(feature = "macros")]
124-
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
125106
#[doc(inline)]
126107
pub use cucumber_codegen::{given, then, when, WorldInit};
127108

@@ -136,6 +117,21 @@ pub use self::{
136117
Failure as FailureWriter, Writer,
137118
},
138119
};
120+
#[cfg(feature = "macros")]
121+
#[doc(inline)]
122+
pub use self::codegen::WorldInit;
123+
124+
pub mod cli;
125+
mod cucumber;
126+
pub mod event;
127+
pub mod feature;
128+
pub mod parser;
129+
pub mod runner;
130+
pub mod step;
131+
pub mod writer;
132+
133+
#[cfg(feature = "macros")]
134+
pub mod codegen;
139135

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

0 commit comments

Comments
 (0)