Skip to content

Commit

Permalink
Tune lints for 1.81 Rust
Browse files Browse the repository at this point in the history
- bump up MSRV to 1.81
  • Loading branch information
tyranron committed Sep 9, 2024
1 parent 4010c1a commit f130703
Show file tree
Hide file tree
Showing 22 changed files with 114 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
strategy:
fail-fast: false
matrix:
msrv: ["1.80.0"]
msrv: ["1.81.0"]
crate:
- cucumber-codegen
- cucumber
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ All user visible changes to `cucumber` crate will be documented in this file. Th

### BC Breaks

- Bumped up [MSRV] to 1.80 to get rid of `once_cell` crate. ([todo])
- Bumped up [MSRV] to 1.81 to get rid of `once_cell` crate and for `#[expect]` attribute usage. ([4010c1ad], [todo])

[4010c1ad]: /../../commit/4010c1ad6a53d6b7f0b28cefea73c8c13e880e9f
[todo]: /../../commit/todo-full


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.21.1"
edition = "2021"
rust-version = "1.80"
rust-version = "1.81"
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 @@ -2,7 +2,7 @@ Cucumber testing framework for Rust
===================================

[![crates.io](https://img.shields.io/crates/v/cucumber.svg?maxAge=2592000 "crates.io")](https://crates.io/crates/cucumber)
[![Rust 1.80+](https://img.shields.io/badge/rustc-1.80+-lightgray.svg "Rust 1.80")](https://blog.rust-lang.org/2024/07/25/Rust-1.80.0.html)
[![Rust 1.81+](https://img.shields.io/badge/rustc-1.81+-lightgray.svg "Rust 1.81+")](https://blog.rust-lang.org/2024/09/05/Rust-1.81.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/workflows/CI/badge.svg?branch=main "CI")](https://github.com/cucumber-rs/cucumber/actions?query=workflow%3ACI+branch%3Amain)
[![Rust docs](https://docs.rs/cucumber/badge.svg "Rust docs")](https://docs.rs/cucumber)
Expand Down
3 changes: 2 additions & 1 deletion codegen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ All user visible changes to `cucumber-codegen` crate will be documented in this

### BC Breaks

- Bumped up [MSRV] to 1.80 to get rid of `once_cell` crate. ([todo])
- Bumped up [MSRV] to 1.81 to get rid of `once_cell` crate and for `#[expect]` attribute usage. ([4010c1ad], [todo])

[4010c1ad]: /../../commit/4010c1ad6a53d6b7f0b28cefea73c8c13e880e9f
[todo]: /../../commit/todo-full


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.21.1" # should be the same as main crate version
edition = "2021"
rust-version = "1.80"
rust-version = "1.81"
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 @@ -2,7 +2,7 @@
========================

[![crates.io](https://img.shields.io/crates/v/cucumber-codegen.svg?maxAge=2592000 "crates.io")](https://crates.io/crates/cucumber-codegen)
[![Rust 1.80+](https://img.shields.io/badge/rustc-1.80+-lightgray.svg "Rust 1.80")](https://blog.rust-lang.org/2024/07/25/Rust-1.80.0.html)
[![Rust 1.81+](https://img.shields.io/badge/rustc-1.81+-lightgray.svg "Rust 1.81+")](https://blog.rust-lang.org/2024/09/05/Rust-1.81.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/workflows/CI/badge.svg?branch=main "CI")](https://github.com/cucumber-rs/cucumber/actions?query=workflow%3ACI+branch%3Amain)
[![Rust docs](https://docs.rs/cucumber-codegen/badge.svg "Rust docs")](https://docs.rs/cucumber-codegen)
Expand Down
2 changes: 0 additions & 2 deletions codegen/src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ impl Step {

Ok((func_args, addon_parsing))
} else {
// false positive: impl of `FnOnce` is not general enough
#[allow(clippy::redundant_closure_for_method_calls)]
let (idents, parsings): (Vec<_>, Vec<_>) =
itertools::process_results(
func.sig
Expand Down
4 changes: 4 additions & 0 deletions codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@
#![forbid(non_ascii_idents, unsafe_code)]
#![warn(
clippy::absolute_paths,
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
clippy::as_conversions,
clippy::as_ptr_cast_mut,
clippy::assertions_on_result_states,
clippy::branches_sharing_code,
clippy::cfg_not_test,
clippy::clear_with_drain,
clippy::clone_on_ref_ptr,
clippy::collection_is_never_read,
Expand Down Expand Up @@ -98,6 +101,7 @@
clippy::rest_pat_in_fully_bound_structs,
clippy::same_name_method,
clippy::semicolon_inside_block,
clippy::set_contains_or_insert,
clippy::shadow_unrelated,
clippy::significant_drop_in_scrutinee,
clippy::significant_drop_tightening,
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl Definition {
const STEPS: &'static [&'static str] = &["given", "when", "then"];

/// Assertion to ensure, that [`Self::STEPS`] has exactly 3 step types.
#[allow(clippy::manual_assert)] // `assert_eq!` isn't const yet
#[expect(clippy::manual_assert, reason = "`assert_eq!` isn't const yet")]
const EXACTLY_3_STEPS: () = if Self::STEPS.len() != 3 {
panic!("expected exactly 3 step names");
};
Expand Down
26 changes: 12 additions & 14 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl<T> Event<T> {
/// Creates a new [`Event`] out of the given `value`.
#[cfg_attr(
not(feature = "timestamps"),
allow(clippy::missing_const_for_fn)
expect(clippy::missing_const_for_fn, reason = "API compliance")
)]
#[must_use]
pub fn new(value: T) -> Self {
Expand Down Expand Up @@ -150,7 +150,6 @@ impl Retries {
/// Top-level [Cucumber] run event.
///
/// [Cucumber]: https://cucumber.io
#[allow(variant_size_differences)]
#[derive(Debug)]
pub enum Cucumber<World> {
/// [`Cucumber`] execution being started.
Expand Down Expand Up @@ -223,15 +222,15 @@ impl<World> Cucumber<World> {
///
/// [`Feature`]: gherkin::Feature
#[must_use]
pub fn feature_started(feat: Arc<gherkin::Feature>) -> Self {
pub const fn feature_started(feat: Arc<gherkin::Feature>) -> Self {
Self::Feature(feat, Feature::Started)
}

/// Constructs an event of a [`Rule`] being started.
///
/// [`Rule`]: gherkin::Rule
#[must_use]
pub fn rule_started(
pub const fn rule_started(
feat: Arc<gherkin::Feature>,
rule: Arc<gherkin::Rule>,
) -> Self {
Expand All @@ -242,15 +241,15 @@ impl<World> Cucumber<World> {
///
/// [`Feature`]: gherkin::Feature
#[must_use]
pub fn feature_finished(feat: Arc<gherkin::Feature>) -> Self {
pub const fn feature_finished(feat: Arc<gherkin::Feature>) -> Self {
Self::Feature(feat, Feature::Finished)
}

/// Constructs an event of a [`Rule`] being finished.
///
/// [`Rule`]: gherkin::Rule
#[must_use]
pub fn rule_finished(
pub const fn rule_finished(
feat: Arc<gherkin::Feature>,
rule: Arc<gherkin::Rule>,
) -> Self {
Expand Down Expand Up @@ -441,7 +440,7 @@ pub enum HookType {
After,
}

#[allow(clippy::use_debug)] // intentional
#[expect(clippy::use_debug, reason = "intentional")]
impl fmt::Display for HookType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{self:?}")
Expand Down Expand Up @@ -556,7 +555,7 @@ impl<World> Scenario<World> {
///
/// [`Step`]: gherkin::Step
#[must_use]
pub fn step_started(step: Arc<gherkin::Step>) -> Self {
pub const fn step_started(step: Arc<gherkin::Step>) -> Self {
Self::Step(step, Step::Started)
}

Expand All @@ -565,15 +564,15 @@ impl<World> Scenario<World> {
/// [`Background`]: gherkin::Background
/// [`Step`]: gherkin::Step
#[must_use]
pub fn background_step_started(step: Arc<gherkin::Step>) -> Self {
pub const fn background_step_started(step: Arc<gherkin::Step>) -> Self {
Self::Background(step, Step::Started)
}

/// Constructs an event of a passed [`Step`].
///
/// [`Step`]: gherkin::Step
#[must_use]
pub fn step_passed(
pub const fn step_passed(
step: Arc<gherkin::Step>,
captures: regex::CaptureLocations,
loc: Option<step::Location>,
Expand All @@ -586,7 +585,7 @@ impl<World> Scenario<World> {
/// [`Background`]: gherkin::Background
/// [`Step`]: gherkin::Step
#[must_use]
pub fn background_step_passed(
pub const fn background_step_passed(
step: Arc<gherkin::Step>,
captures: regex::CaptureLocations,
loc: Option<step::Location>,
Expand All @@ -598,15 +597,15 @@ impl<World> Scenario<World> {
///
/// [`Step`]: gherkin::Step
#[must_use]
pub fn step_skipped(step: Arc<gherkin::Step>) -> Self {
pub const fn step_skipped(step: Arc<gherkin::Step>) -> Self {
Self::Step(step, Step::Skipped)
}
/// Constructs an event of a skipped [`Background`] [`Step`].
///
/// [`Background`]: gherkin::Background
/// [`Step`]: gherkin::Step
#[must_use]
pub fn background_step_skipped(step: Arc<gherkin::Step>) -> Self {
pub const fn background_step_skipped(step: Arc<gherkin::Step>) -> Self {
Self::Background(step, Step::Skipped)
}

Expand Down Expand Up @@ -678,7 +677,6 @@ impl<World> Clone for RetryableScenario<World> {
/// Event explaining why a [Scenario] has finished.
///
/// [Scenario]: https://cucumber.io/docs/gherkin/reference#example
#[allow(variant_size_differences)]
#[derive(Clone, Debug)]
pub enum ScenarioFinished {
/// [`Before`] [`Hook::Failed`].
Expand Down
10 changes: 6 additions & 4 deletions src/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fn expand_scenario(
/// [`Examples`]: gherkin::Examples
// TODO: Switch back to `lazy-regex::regex!()` once it migrates to `std`:
// https://github.com/Canop/lazy-regex/issues/10
#[allow(clippy::unwrap_used)] // never panics
#[expect(clippy::unwrap_used, reason = "regex is valid")]
static TEMPLATE_REGEX: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"<([^>\s]+)>").unwrap());

Expand Down Expand Up @@ -174,9 +174,11 @@ fn expand_scenario(
let mut err = None;
let replaced = TEMPLATE_REGEX
.replace_all(str, |cap: &regex::Captures<'_>| {
// PANIC: Unwrapping is OK here as `TEMPLATE_REGEX`
// contains this capture group.
#[allow(clippy::unwrap_used)] // intentional
#[expect( // intentional
clippy::unwrap_used,
reason = "`TEMPLATE_REGEX` contains this capture \
group"
)]
let name = cap.get(1).unwrap().as_str();

row.clone()
Expand Down
2 changes: 1 addition & 1 deletion src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ where
mut self: Pin<&mut Self>,
cx: &mut task::Context<'_>,
) -> task::Poll<Self::Output> {
#[allow(clippy::expect_used)] // intentional
#[expect(clippy::expect_used, reason = "should not happen normally")]
let (mut a, mut b) = self
.inner
.take()
Expand Down
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
#![forbid(non_ascii_idents, unsafe_code)]
#![warn(
clippy::absolute_paths,
clippy::allow_attributes,
clippy::allow_attributes_without_reason,
clippy::as_conversions,
clippy::as_ptr_cast_mut,
clippy::assertions_on_result_states,
clippy::branches_sharing_code,
clippy::cfg_not_test,
clippy::clear_with_drain,
clippy::clone_on_ref_ptr,
clippy::collection_is_never_read,
Expand Down Expand Up @@ -99,6 +102,7 @@
clippy::rest_pat_in_fully_bound_structs,
clippy::same_name_method,
clippy::semicolon_inside_block,
clippy::set_contains_or_insert,
clippy::shadow_unrelated,
clippy::significant_drop_in_scrutinee,
clippy::significant_drop_tightening,
Expand Down Expand Up @@ -160,7 +164,7 @@
variant_size_differences
)]
// TODO: Remove on next `derive_more` major version.
#![allow(clippy::uninlined_format_args)]
#![expect(clippy::uninlined_format_args, reason = "`derive_more` expansion")]

pub mod cli;
mod cucumber;
Expand Down
2 changes: 1 addition & 1 deletion src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub trait Parser<I> {
/// Result of parsing [Gherkin] files.
///
/// [Gherkin]: https://cucumber.io/docs/gherkin/reference
#[allow(clippy::absolute_paths)] // intentional
#[expect(clippy::absolute_paths, reason = "one liner")]
pub type Result<T> = std::result::Result<T, Error>;

/// [`Parser`] error.
Expand Down
Loading

0 comments on commit f130703

Please sign in to comment.