Skip to content

Commit

Permalink
Tune lints for 1.79 Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
tyranron committed Jun 14, 2024
1 parent b859364 commit a9d032a
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}")
Expand Down
2 changes: 1 addition & 1 deletion src/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ fn expand_scenario(
.replace_all(str, |cap: &regex::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()
Expand Down
2 changes: 1 addition & 1 deletion src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self::Output> {
#[allow(clippy::expect_used)] // intentional
let (mut a, mut b) = self
.inner
.take()
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
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)]
#[allow(clippy::absolute_paths)] // intentional
pub type Result<T> = std::result::Result<T, Error>;

/// [`Parser`] error.
Expand Down
10 changes: 6 additions & 4 deletions src/runner/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl RetryOptions {
scenario: &gherkin::Scenario,
cli: &Cli,
) -> Option<Self> {
#[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| {
Expand Down Expand Up @@ -894,6 +894,7 @@ async fn insert_features<W, S, F>(
/// [`Feature`]: gherkin::Feature
/// [`Rule`]: gherkin::Rule
/// [`Scenario`]: gherkin::Scenario
// TODO: Needs refactoring.
#[allow(clippy::too_many_arguments, clippy::too_many_lines)]
async fn execute<W, Before, After>(
features: Features,
Expand Down Expand Up @@ -999,7 +1000,7 @@ async fn execute<W, Before, After>(
}
async {
// Cannot annotate `async` block with `-> !`.
#[allow(clippy::infinite_loop)]
#[allow(clippy::infinite_loop)] // intentional
loop {
while let Some(logs) = logs_collector
.as_mut()
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<W>,
Expand Down Expand Up @@ -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<gherkin::Feature>,
Expand Down
2 changes: 1 addition & 1 deletion src/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl<World> Collection<World> {

// 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(
Expand Down
2 changes: 1 addition & 1 deletion src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
10 changes: 5 additions & 5 deletions src/writer/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ impl<Out: io::Write> Basic<Out> {
///
/// [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<W: Debug>(
&mut self,
feat: &gherkin::Feature,
Expand Down Expand Up @@ -926,7 +926,7 @@ impl<Out: io::Write> Basic<Out> {
/// [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<W: Debug>(
&mut self,
feat: &gherkin::Feature,
Expand Down Expand Up @@ -1046,8 +1046,8 @@ fn format_table(table: &gherkin::Table, indent: usize) -> String {
.rows
.iter()
.fold(None, |mut acc: Option<Vec<_>>, 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());
Expand Down Expand Up @@ -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();

Expand Down
6 changes: 1 addition & 5 deletions src/writer/discard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ where
Self: Writer<W>,
{
/// Does nothing.
async fn write(
&mut self,
#[allow(clippy::let_underscore_untyped)] // false positive
_: Val,
) {
async fn write(&mut self, _: Val) {
// Intentionally no-op.
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/writer/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ impl<W: World + Debug, Out: io::Write> Writer<W> for Json<Out> {
async fn handle_event(
&mut self,
event: parser::Result<Event<event::Cucumber<W>>>,
#[allow(clippy::let_underscore_untyped)] // false positive
_: &Self::Cli,
) {
use event::{Cucumber, Rule};
Expand Down Expand Up @@ -277,7 +276,7 @@ impl<Out: io::Write> Json<Out> {
}

/// Handles the given [`event::Step`].
#[allow(clippy::too_many_arguments)]
#[allow(clippy::too_many_arguments)] // TODO: Needs refactoring.
fn handle_step_event<W>(
&mut self,
feature: &gherkin::Feature,
Expand Down
6 changes: 3 additions & 3 deletions src/writer/libtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ impl<W: Debug + World, Out: io::Write> Libtest<W, Out> {
// 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![]
Expand All @@ -530,7 +530,7 @@ impl<W: Debug + World, Out: io::Write> Libtest<W, Out> {
}

/// 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,
Expand Down Expand Up @@ -576,7 +576,7 @@ impl<W: Debug + World, Out: io::Write> Libtest<W, Out> {
}

/// 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,
Expand Down
2 changes: 1 addition & 1 deletion src/writer/summarize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ pub trait Summarizable {}
impl<T: writer::NonTransforming> 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]
Expand Down

0 comments on commit a9d032a

Please sign in to comment.