Skip to content

Commit

Permalink
Upgrade to 1.62 Rust and bump up MSRV
Browse files Browse the repository at this point in the history
- refactor to use `bool::then_some()`
- tune up lints
  • Loading branch information
tyranron committed Jul 1, 2022
1 parent 5e6d630 commit 8ad5cc8
Show file tree
Hide file tree
Showing 17 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
strategy:
fail-fast: false
matrix:
msrv: ["1.61.0"]
msrv: ["1.62.0"]
crate:
- cucumber-codegen
- cucumber
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` crate will be documented in this file. Th

### BC Breaks

- Bump up [MSRV] to 1.61 for more clever support of [Cargo feature]s and simplified codegen. ([fbd08ec2], [cf055ac0])
- Bump up [MSRV] to 1.62 for more clever support of [Cargo feature]s and simplified codegen. ([fbd08ec2], [cf055ac0], [todo])

### Changed

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "cucumber"
version = "0.14.0-dev"
edition = "2021"
rust-version = "1.61"
rust-version = "1.62"
description = """\
Cucumber testing framework for Rust, with async support. \
Fully native, no external test runners or dependencies.\
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Cucumber testing framework for Rust
[![Crates.io](https://img.shields.io/crates/v/cucumber.svg?maxAge=2592000)](https://crates.io/crates/cucumber)
[![Documentation](https://docs.rs/cucumber/badge.svg)](https://docs.rs/cucumber)
[![CI](https://github.com/cucumber-rs/cucumber/workflows/CI/badge.svg?branch=main "CI")](https://github.com/cucumber-rs/cucumber/actions?query=workflow%3ACI+branch%3Amain)
[![Rust 1.61+](https://img.shields.io/badge/rustc-1.61+-lightgray.svg "Rust 1.61+")](https://blog.rust-lang.org/2022/05/19/Rust-1.61.0.html)
[![Rust 1.62+](https://img.shields.io/badge/rustc-1.62+-lightgray.svg "Rust 1.62+")](https://blog.rust-lang.org/2022/06/30/Rust-1.62.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
2 changes: 1 addition & 1 deletion book/src/writing/asserting.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn feed_cat(_: &mut AnimalWorld) {}
#[then("the cat is not hungry")]
fn cat_is_fed(world: &mut AnimalWorld) -> Result<(), &'static str> {
(!world.cat.hungry).then(|| ()).ok_or("Cat is still hungry!")
(!world.cat.hungry).then_some(()).ok_or("Cat is still hungry!")
}
#
# #[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion codegen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ All user visible changes to `cucumber-codegen` crate will be documented in this

### BC Breaks

- Bump up [MSRV] to 1.61 for more clever support of [Cargo feature]s and simplified codegen. ([fbd08ec2], [cf055ac0])
- Bump up [MSRV] to 1.62 for more clever support of [Cargo feature]s and simplified codegen. ([fbd08ec2], [cf055ac0], [todo])

[cf055ac0]: /../../commit/cf055ac06c7b72f572882ce15d6a60da92ad60a0
[fbd08ec2]: /../../commit/fbd08ec24dbd036c89f5f0af4d936b616790a166
Expand Down
2 changes: 1 addition & 1 deletion codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "cucumber-codegen"
version = "0.14.0-dev" # should be the same as main crate version
edition = "2021"
rust-version = "1.61"
rust-version = "1.62"
description = "Code generation for `cucumber` crate."
license = "MIT OR Apache-2.0"
authors = [
Expand Down
2 changes: 1 addition & 1 deletion codegen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Crates.io](https://img.shields.io/crates/v/cucumber-codegen.svg?maxAge=2592000)](https://crates.io/crates/cucumber-codegen)
[![Documentation](https://docs.rs/cucumber-codegen/badge.svg)](https://docs.rs/cucumber-codegen)
[![CI](https://github.com/cucumber-rs/cucumber/workflows/CI/badge.svg?branch=main "CI")](https://github.com/cucumber-rs/cucumber/actions?query=workflow%3ACI+branch%3Amain)
[![Rust 1.61+](https://img.shields.io/badge/rustc-1.61+-lightgray.svg "Rust 1.61+")](https://blog.rust-lang.org/2022/05/19/Rust-1.61.0.html)
[![Rust 1.62+](https://img.shields.io/badge/rustc-1.62+-lightgray.svg "Rust 1.62+")](https://blog.rust-lang.org/2022/06/30/Rust-1.62.0.html)
[![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance)

- [Changelog](https://github.com/cucumber-rs/cucumber/blob/main/codegen/CHANGELOG.md)
Expand Down
13 changes: 6 additions & 7 deletions codegen/src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl Step {
.map(|(_, (_, s))| s.as_str()),
)
.fold(None, |acc, s| {
acc.or_else(|| (!s.is_empty()).then(|| s))
acc.or_else(|| (!s.is_empty()).then_some(s))
})
.unwrap_or_default();

Expand Down Expand Up @@ -367,10 +367,9 @@ impl Step {
.take(to_take)
.map(|(_, s)| s.as_str()),
)
.fold(
None,
|acc, s| acc.or_else(|| (!s.is_empty()).then(|| s)),
)
.fold(None, |acc, s| {
acc.or_else(|| (!s.is_empty()).then_some(s))
})
.unwrap_or_default()
};
let #ident = #ident.parse::<#ty>().expect(#parsing_err);
Expand Down Expand Up @@ -523,7 +522,7 @@ impl<'p> Parameters<'p> {
Err(err) => return Some(Err(err)),
};
let is_step = step.map(|s| s == ident).unwrap_or_default();
(!is_step).then(|| Ok(ty))
(!is_step).then_some(Ok(ty))
})
.collect::<syn::Result<Vec<_>>>()?;

Expand Down Expand Up @@ -666,7 +665,7 @@ impl<'p> Parameters<'p> {
.iter()
.filter_map(|par| {
let name = par.param.input.fragment();
(!DEFAULT_PARAMETERS.contains(name)).then(|| (*name, &par.ty))
(!DEFAULT_PARAMETERS.contains(name)).then_some((*name, &par.ty))
})
.unzip();

Expand Down
3 changes: 3 additions & 0 deletions codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
clippy::decimal_literal_representation,
clippy::default_union_representation,
clippy::else_if_without_else,
clippy::empty_drop,
clippy::empty_line_after_outer_attr,
clippy::empty_structs_with_brackets,
clippy::equatable_if_let,
clippy::exit,
clippy::expect_used,
Expand All @@ -45,6 +47,7 @@
clippy::imprecise_flops,
clippy::index_refutable_slice,
clippy::iter_with_drain,
clippy::large_include_file,
clippy::let_underscore_must_use,
clippy::lossy_float_literal,
clippy::map_err_ignore,
Expand Down
6 changes: 3 additions & 3 deletions src/cucumber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1278,23 +1278,23 @@ where
if failed_steps > 0 {
msg.push(format!(
"{failed_steps} step{} failed",
(failed_steps > 1).then(|| "s").unwrap_or_default(),
(failed_steps > 1).then_some("s").unwrap_or_default(),
));
}

let parsing_errors = writer.parsing_errors();
if parsing_errors > 0 {
msg.push(format!(
"{parsing_errors} parsing error{}",
(parsing_errors > 1).then(|| "s").unwrap_or_default(),
(parsing_errors > 1).then_some("s").unwrap_or_default(),
));
}

let hook_errors = writer.hook_errors();
if hook_errors > 0 {
msg.push(format!(
"{hook_errors} hook error{}",
(hook_errors > 1).then(|| "s").unwrap_or_default(),
(hook_errors > 1).then_some("s").unwrap_or_default(),
));
}

Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
clippy::decimal_literal_representation,
clippy::default_union_representation,
clippy::else_if_without_else,
clippy::empty_drop,
clippy::empty_line_after_outer_attr,
clippy::empty_structs_with_brackets,
clippy::equatable_if_let,
clippy::exit,
clippy::expect_used,
Expand All @@ -47,6 +49,7 @@
clippy::imprecise_flops,
clippy::index_refutable_slice,
clippy::iter_with_drain,
clippy::large_include_file,
clippy::let_underscore_must_use,
clippy::lossy_float_literal,
clippy::map_err_ignore,
Expand Down
2 changes: 1 addition & 1 deletion src/runner/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl<World> Default for Basic<World> {
.tags
.iter()
.any(|tag| tag == "serial")
.then(|| ScenarioType::Serial)
.then_some(ScenarioType::Serial)
.unwrap_or(ScenarioType::Concurrent)
};

Expand Down
2 changes: 2 additions & 0 deletions src/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ impl<World> fmt::Debug for Collection<World> {
}
}

// Implemented manually to omit redundant `World: Default` trait bound, imposed
// by `#[derive(Default)]`.
impl<World> Default for Collection<World> {
fn default() -> Self {
Self {
Expand Down
2 changes: 1 addition & 1 deletion src/writer/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ fn format_table(table: &gherkin::Table, indent: usize) -> String {
.rows
.iter()
.fold(None, |mut acc: Option<Vec<_>>, row| {
// false positive due to mut borrowing
// false positive: due to mut borrowing
#[allow(clippy::option_if_let_else)]
if let Some(existing_len) = acc.as_mut() {
for (cell, max_len) in row.iter().zip(existing_len) {
Expand Down
3 changes: 2 additions & 1 deletion src/writer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,11 @@ impl<T> Ext for T {
pub trait NonTransforming {}

/// Standard verbosity levels of a [`Writer`].
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Default)]
#[repr(u8)]
pub enum Verbosity {
/// None additional info.
#[default]
Default = 0,

/// Outputs the whole [`World`] on [`Failed`] [`Step`]s whenever is
Expand Down
2 changes: 1 addition & 1 deletion src/writer/summarize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ impl Styles {
self.bold(format!(
"{num} {}{}",
singular.into(),
(num != 1).then(|| "s").unwrap_or_default(),
(num != 1).then_some("s").unwrap_or_default(),
))
}
}

0 comments on commit 8ad5cc8

Please sign in to comment.