From a9d032ac321a47b44ecbad1aae0b2be56291bd26 Mon Sep 17 00:00:00 2001 From: tyranron Date: Fri, 14 Jun 2024 17:02:19 +0200 Subject: [PATCH] Tune lints for 1.79 Rust --- Cargo.toml | 2 +- codegen/src/lib.rs | 4 ++-- src/event.rs | 2 +- src/feature.rs | 2 +- src/future.rs | 2 +- src/lib.rs | 4 ++-- src/parser/mod.rs | 2 +- src/runner/basic.rs | 10 ++++++---- src/step.rs | 2 +- src/tracing.rs | 2 +- src/writer/basic.rs | 10 +++++----- src/writer/discard.rs | 6 +----- src/writer/json.rs | 3 +-- src/writer/libtest.rs | 6 +++--- src/writer/summarize.rs | 2 +- 15 files changed, 28 insertions(+), 31 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 48f11913..143e5427 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,7 +65,7 @@ tracing = ["dep:crossbeam-utils", "dep:tracing", "dep:tracing-subscriber"] [dependencies] clap = { version = "4.3.2", features = ["derive", "wrap_help"] } console = "0.15" -derive_more = { version = "0.99.17", features = ["as_ref", "deref", "deref_mut", "display", "error", "from", "from_str", "into"], default_features = false } +derive_more = { version = "0.99.17", features = ["as_ref", "deref", "deref_mut", "display", "error", "from", "from_str", "into"], default-features = false } drain_filter_polyfill = "0.1.2" either = "1.6" futures = "0.3.17" diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index 60ff5012..f7e4db68 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -65,7 +65,6 @@ clippy::let_underscore_untyped, clippy::lossy_float_literal, clippy::manual_c_str_literals, - clippy::manual_clamp, clippy::map_err_ignore, clippy::mem_forget, clippy::missing_assert_message, @@ -92,7 +91,6 @@ clippy::rc_buffer, clippy::rc_mutex, clippy::read_zero_byte_vec, - clippy::readonly_write_lock, clippy::redundant_clone, clippy::redundant_type_annotations, clippy::ref_patterns, @@ -141,9 +139,11 @@ missing_copy_implementations, missing_debug_implementations, missing_docs, + redundant_lifetimes, semicolon_in_expressions_from_macros, single_use_lifetimes, unit_bindings, + unnameable_types, unreachable_pub, unsafe_op_in_unsafe_fn, unstable_features, diff --git a/src/event.rs b/src/event.rs index 7ac413c8..69ebe71b 100644 --- a/src/event.rs +++ b/src/event.rs @@ -441,7 +441,7 @@ pub enum HookType { After, } -#[allow(clippy::use_debug)] // `Debug` usage is intentional here +#[allow(clippy::use_debug)] // intentional impl fmt::Display for HookType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{self:?}") diff --git a/src/feature.rs b/src/feature.rs index 2254bfcf..2e9d2cf2 100644 --- a/src/feature.rs +++ b/src/feature.rs @@ -173,7 +173,7 @@ fn expand_scenario( .replace_all(str, |cap: ®ex::Captures<'_>| { // PANIC: Unwrapping is OK here as `TEMPLATE_REGEX` // contains this capture group. - #[allow(clippy::unwrap_used)] + #[allow(clippy::unwrap_used)] // intentional let name = cap.get(1).unwrap().as_str(); row.clone() diff --git a/src/future.rs b/src/future.rs index 47edcceb..813e5fb2 100644 --- a/src/future.rs +++ b/src/future.rs @@ -123,11 +123,11 @@ where { type Output = Either<(A::Output, B), (B::Output, A)>; - #[allow(clippy::expect_used)] fn poll( mut self: Pin<&mut Self>, cx: &mut task::Context<'_>, ) -> task::Poll { + #[allow(clippy::expect_used)] // intentional let (mut a, mut b) = self .inner .take() diff --git a/src/lib.rs b/src/lib.rs index f4be86d8..995edb9e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -66,7 +66,6 @@ clippy::let_underscore_untyped, clippy::lossy_float_literal, clippy::manual_c_str_literals, - clippy::manual_clamp, clippy::map_err_ignore, clippy::mem_forget, clippy::missing_assert_message, @@ -93,7 +92,6 @@ clippy::rc_buffer, clippy::rc_mutex, clippy::read_zero_byte_vec, - clippy::readonly_write_lock, clippy::redundant_clone, clippy::redundant_type_annotations, clippy::ref_patterns, @@ -142,9 +140,11 @@ missing_copy_implementations, missing_debug_implementations, missing_docs, + redundant_lifetimes, semicolon_in_expressions_from_macros, single_use_lifetimes, unit_bindings, + unnameable_types, unreachable_pub, unsafe_op_in_unsafe_fn, unstable_features, diff --git a/src/parser/mod.rs b/src/parser/mod.rs index b1e4e21b..8ee8600c 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -53,7 +53,7 @@ pub trait Parser { /// Result of parsing [Gherkin] files. /// /// [Gherkin]: https://cucumber.io/docs/gherkin/reference -#[allow(clippy::absolute_paths)] +#[allow(clippy::absolute_paths)] // intentional pub type Result = std::result::Result; /// [`Parser`] error. diff --git a/src/runner/basic.rs b/src/runner/basic.rs index 6df71da0..19121b49 100644 --- a/src/runner/basic.rs +++ b/src/runner/basic.rs @@ -146,7 +146,7 @@ impl RetryOptions { scenario: &gherkin::Scenario, cli: &Cli, ) -> Option { - #[allow(clippy::shadow_unrelated)] + #[allow(clippy::shadow_unrelated)] // intentional let parse_tags = |tags: &[String]| { tags.iter().find_map(|tag| { tag.strip_prefix("retry").map(|retries| { @@ -894,6 +894,7 @@ async fn insert_features( /// [`Feature`]: gherkin::Feature /// [`Rule`]: gherkin::Rule /// [`Scenario`]: gherkin::Scenario +// TODO: Needs refactoring. #[allow(clippy::too_many_arguments, clippy::too_many_lines)] async fn execute( features: Features, @@ -999,7 +1000,7 @@ async fn execute( } async { // Cannot annotate `async` block with `-> !`. - #[allow(clippy::infinite_loop)] + #[allow(clippy::infinite_loop)] // intentional loop { while let Some(logs) = logs_collector .as_mut() @@ -1177,6 +1178,7 @@ where /// [`Feature`]: gherkin::Feature /// [`Rule`]: gherkin::Rule /// [`Scenario`]: gherkin::Scenario + // TODO: Needs refactoring. #[allow(clippy::too_many_arguments, clippy::too_many_lines)] async fn run_scenario( &self, @@ -1722,7 +1724,7 @@ where /// /// Doesn't emit any events, see [`Self::emit_failed_events()`] for more /// details. - #[allow(clippy::too_many_arguments)] + #[allow(clippy::too_many_arguments)] // TODO: Needs refactoring. async fn run_after_hook( &self, mut world: Option, @@ -1784,7 +1786,7 @@ where /// /// See [`Self::emit_failed_events()`] for the explanation why we don't do /// that inside [`Self::run_after_hook()`]. - #[allow(clippy::too_many_arguments)] + #[allow(clippy::too_many_arguments)] // TODO: Needs refactoring. fn emit_after_hook_events( &self, feature: Arc, diff --git a/src/step.rs b/src/step.rs index 7b978654..3c55c38a 100644 --- a/src/step.rs +++ b/src/step.rs @@ -208,7 +208,7 @@ impl Collection { // PANIC: Slicing is OK here, as all indices are obtained from the // source string. - #[allow(clippy::string_slice)] + #[allow(clippy::string_slice)] // intentional let matches = names .map(|opt| opt.map(str::to_owned)) .zip(iter::once(whole_match.as_str().to_owned()).chain( diff --git a/src/tracing.rs b/src/tracing.rs index 167c5e82..58f7d170 100644 --- a/src/tracing.rs +++ b/src/tracing.rs @@ -312,7 +312,7 @@ impl Collector { } // We better keep this here, as it's related to `tracing` capabilities only. -#[allow(clippy::multiple_inherent_impl)] +#[allow(clippy::multiple_inherent_impl)] // intentional impl ScenarioId { /// Name of the [`ScenarioId`] [`Span`] field. const SPAN_FIELD_NAME: &'static str = "__cucumber_scenario_id"; diff --git a/src/writer/basic.rs b/src/writer/basic.rs index c44ffcf8..7b4d0ada 100644 --- a/src/writer/basic.rs +++ b/src/writer/basic.rs @@ -646,7 +646,7 @@ impl Basic { /// /// [failed]: event::Step::Failed /// [`Step`]: gherkin::Step - #[allow(clippy::too_many_arguments)] + #[allow(clippy::too_many_arguments)] // TODO: Needs refactoring. pub(crate) fn step_failed( &mut self, feat: &gherkin::Feature, @@ -926,7 +926,7 @@ impl Basic { /// [failed]: event::Step::Failed /// [`Background`]: gherkin::Background /// [`Step`]: gherkin::Step - #[allow(clippy::too_many_arguments)] + #[allow(clippy::too_many_arguments)] // TODO: Needs refactoring. pub(crate) fn bg_step_failed( &mut self, feat: &gherkin::Feature, @@ -1046,8 +1046,8 @@ fn format_table(table: &gherkin::Table, indent: usize) -> String { .rows .iter() .fold(None, |mut acc: Option>, row| { - // false positive: due to mut borrowing - #[allow(clippy::option_if_let_else)] + // False Positive: Due to mut borrowing. + #[allow(clippy::option_if_let_else)] // false positive if let Some(existing_len) = acc.as_mut() { for (cell, max_len) in row.iter().zip(existing_len) { *max_len = cmp::max(*max_len, cell.len()); @@ -1096,7 +1096,7 @@ where { // PANIC: Slicing is OK here, as all indices are obtained from the source // string. - #![allow(clippy::string_slice)] + #![allow(clippy::string_slice)] // intentional let value = value.as_ref(); diff --git a/src/writer/discard.rs b/src/writer/discard.rs index a046b537..3eec2c8b 100644 --- a/src/writer/discard.rs +++ b/src/writer/discard.rs @@ -43,11 +43,7 @@ where Self: Writer, { /// Does nothing. - async fn write( - &mut self, - #[allow(clippy::let_underscore_untyped)] // false positive - _: Val, - ) { + async fn write(&mut self, _: Val) { // Intentionally no-op. } } diff --git a/src/writer/json.rs b/src/writer/json.rs index 526c0fd6..599f17cc 100644 --- a/src/writer/json.rs +++ b/src/writer/json.rs @@ -77,7 +77,6 @@ impl Writer for Json { async fn handle_event( &mut self, event: parser::Result>>, - #[allow(clippy::let_underscore_untyped)] // false positive _: &Self::Cli, ) { use event::{Cucumber, Rule}; @@ -277,7 +276,7 @@ impl Json { } /// Handles the given [`event::Step`]. - #[allow(clippy::too_many_arguments)] + #[allow(clippy::too_many_arguments)] // TODO: Needs refactoring. fn handle_step_event( &mut self, feature: &gherkin::Feature, diff --git a/src/writer/libtest.rs b/src/writer/libtest.rs index f8bb06fd..334ae7f9 100644 --- a/src/writer/libtest.rs +++ b/src/writer/libtest.rs @@ -521,7 +521,7 @@ impl Libtest { // the standard library’s `print!()` macro. // This is the same as `tracing_subscriber::fmt::TestWriter` does // (check its documentation for details). - #[allow(clippy::print_stdout)] + #[allow(clippy::print_stdout)] // intentional Scenario::Log(msg) => { print!("{msg}"); vec![] @@ -530,7 +530,7 @@ impl Libtest { } /// Converts the provided [`event::Hook`] into [`LibTestJsonEvent`]s. - #[allow(clippy::too_many_arguments)] + #[allow(clippy::too_many_arguments)] // TODO: Needs refactoring. fn expand_hook_event( &mut self, feature: &gherkin::Feature, @@ -576,7 +576,7 @@ impl Libtest { } /// Converts the provided [`event::Step`] into [`LibTestJsonEvent`]s. - #[allow(clippy::too_many_arguments)] + #[allow(clippy::too_many_arguments)] // TODO: Needs refactoring. fn expand_step_event( &mut self, feature: &gherkin::Feature, diff --git a/src/writer/summarize.rs b/src/writer/summarize.rs index b6fc266d..d0612b2d 100644 --- a/src/writer/summarize.rs +++ b/src/writer/summarize.rs @@ -551,7 +551,7 @@ pub trait Summarizable {} impl Summarizable for T {} // We better keep this here, as it's related to summarization only. -#[allow(clippy::multiple_inherent_impl)] +#[allow(clippy::multiple_inherent_impl)] // intentional impl Styles { /// Generates a formatted summary [`String`]. #[must_use]