From 935602b2cb36be7466f96af14315fe7db03e0f84 Mon Sep 17 00:00:00 2001 From: tyranron Date: Fri, 14 Jan 2022 15:22:11 +0100 Subject: [PATCH] Tune lints for 1.58 Rust --- book/src/architecture/writer.md | 8 ++++---- book/src/writing/capturing.md | 6 +++--- codegen/src/attribute.rs | 6 ++++++ codegen/src/lib.rs | 15 ++++++++++++++ codegen/src/parameter.rs | 1 + codegen/src/world_init.rs | 1 + src/cucumber.rs | 4 ++++ src/event.rs | 1 + src/lib.rs | 12 +++++++++++ src/parser/basic.rs | 2 ++ src/runner/basic.rs | 4 ++++ src/step.rs | 5 +++++ src/writer/basic.rs | 36 ++++++++++++++++++++++++--------- src/writer/json.rs | 10 ++++++++- src/writer/junit.rs | 18 ++++++++++++++++- src/writer/out.rs | 2 ++ src/writer/summarize.rs | 3 +++ tests/output.rs | 6 ++++++ 18 files changed, 121 insertions(+), 19 deletions(-) diff --git a/book/src/architecture/writer.md b/book/src/architecture/writer.md index 8fecb6a9..93d05c74 100644 --- a/book/src/architecture/writer.md +++ b/book/src/architecture/writer.md @@ -271,7 +271,7 @@ impl cucumber::Writer for CustomWriter { event::Step::Passed(_) => println!("ok"), event::Step::Skipped => println!("skip"), event::Step::Failed(_, _, err) => { - println!("failed: {}", err) + println!("failed: {err}") } }, _ => {} @@ -280,7 +280,7 @@ impl cucumber::Writer for CustomWriter { }, _ => {} }, - Err(e) => println!("Error: {}", e), + Err(e) => println!("Error: {e}"), } } } @@ -450,7 +450,7 @@ async fn main() { # event::Step::Passed(_) => println!("ok"), # event::Step::Skipped => println!("skip"), # event::Step::Failed(_, _, err) => { -# println!("failed: {}", err) +# println!("failed: {err}", ) # } # }, # _ => {} @@ -459,7 +459,7 @@ async fn main() { # }, # _ => {} # }, -# Err(e) => println!("Error: {}", e), +# Err(e) => println!("Error: {e}"), # } # } # } diff --git a/book/src/writing/capturing.md b/book/src/writing/capturing.md index fa2ce98f..4eb3d8b3 100644 --- a/book/src/writing/capturing.md +++ b/book/src/writing/capturing.md @@ -111,7 +111,7 @@ impl FromStr for State { Ok(match s { "hungry" => Self::Hungry, "satiated" => Self::Satiated, - invalid => return Err(format!("Invalid `State`: {}", invalid)), + invalid => return Err(format!("Invalid `State`: {invalid}")), }) } } @@ -194,7 +194,7 @@ Alternatively, a [Cucumber Expression][expr] may be used to capture values. This # Ok(match s { # "hungry" => Self::Hungry, # "satiated" => Self::Satiated, -# invalid => return Err(format!("Invalid `State`: {}", invalid)), +# invalid => return Err(format!("Invalid `State`: {invalid}")), # }) # } # } @@ -285,7 +285,7 @@ impl FromStr for State { Ok(match s { "hungry" => Self::Hungry, "satiated" => Self::Satiated, - invalid => return Err(format!("Invalid `State`: {}", invalid)), + invalid => return Err(format!("Invalid `State`: {invalid}")), }) } } diff --git a/codegen/src/attribute.rs b/codegen/src/attribute.rs index 3cf27231..45ebfa36 100644 --- a/codegen/src/attribute.rs +++ b/codegen/src/attribute.rs @@ -113,9 +113,11 @@ impl Step { let regex = self.gen_regex()?; + // TODO: Use "{func_name}" syntax once MSRV bumps above 1.58. let caller_name = format_ident!("__cucumber_{}_{}", self.attr_name, func_name); let awaiting = func.sig.asyncness.map(|_| quote! { .await }); + // TODO: Use "{e}" syntax once MSRV bumps above 1.58. let unwrapping = (!self.returns_unit()) .then(|| quote! { .unwrap_or_else(|e| panic!("{}", e)) }); let step_caller = quote! { @@ -302,6 +304,7 @@ impl Step { return Err(syn::Error::new(ty.span(), "Type path expected")); }; + // TODO: Use "{ident}" syntax once MSRV bumps above 1.58. let not_found_err = format!("{} not found", ident); let parsing_err = format!( "{} can not be parsed to {}", @@ -371,6 +374,7 @@ impl Step { } AttributeArgument::Regex(re) => { drop(Regex::new(re.value().as_str()).map_err(|e| { + // TODO: Use "{e}" syntax once MSRV bumps above 1.58. syn::Error::new(re.span(), format!("Invalid regex: {}", e)) })?); @@ -455,6 +459,7 @@ impl<'p> Parameters<'p> { let expr = Expression::parse(expr).map_err(|e| { syn::Error::new( expr.span(), + // TODO: Use "{e}" syntax once MSRV bumps above 1.58. format!("Incorrect cucumber expression: {}", e), ) })?; @@ -580,6 +585,7 @@ impl<'p> Parameters<'p> { } else { // Here we use double escaping to properly render `{name}` // in the assertion message of the generated code. + // TODO: Use "{name}" syntax once MSRV bumps above 1.58. let assert_msg = format!( "Type `{}` doesn't implement a custom parameter \ `{{{{{}}}}}`", diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index dc15c093..bf64c4f2 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -38,6 +38,7 @@ clippy::fallible_impl_from, clippy::float_cmp_const, clippy::fn_to_numeric_cast, + clippy::fn_to_numeric_cast_any, clippy::get_unwrap, clippy::if_then_some_else_none, clippy::imprecise_flops, @@ -63,11 +64,14 @@ clippy::str_to_string, clippy::string_add, clippy::string_lit_as_bytes, + clippy::string_slice, clippy::string_to_string, clippy::suboptimal_flops, clippy::suspicious_operation_groupings, clippy::todo, + clippy::trailing_empty_array, clippy::trivial_regex, + clippy::undocumented_unsafe_blocks, clippy::unimplemented, clippy::unnecessary_self_imports, clippy::unneeded_field_pattern, @@ -101,6 +105,17 @@ mod world_init; use proc_macro::TokenStream; +// TODO: Remove once tests run without complains about it. +#[cfg(test)] +mod actually_used_crates_in_tests { + use async_trait as _; + use cucumber as _; + use derive_more as _; + use futures as _; + use tempfile as _; + use tokio as _; +} + /// Helper macro for generating public shims for [`macro@given`], [`macro@when`] /// and [`macro@then`] attributes. macro_rules! step_attribute { diff --git a/codegen/src/parameter.rs b/codegen/src/parameter.rs index f32ad03e..0498bf5d 100644 --- a/codegen/src/parameter.rs +++ b/codegen/src/parameter.rs @@ -65,6 +65,7 @@ impl TryFrom for Definition { let attrs: Attrs = Attrs::parse_attrs("param", &input)?; let regex = Regex::new(&attrs.regex.value()).map_err(|e| { + // TODO: Use "{e}" syntax once MSRV bumps above 1.58. syn::Error::new(attrs.regex.span(), format!("Invalid regex: {}", e)) })?; if regex.captures_len() > 1 { diff --git a/codegen/src/world_init.rs b/codegen/src/world_init.rs index 5b90a463..fb4ce98e 100644 --- a/codegen/src/world_init.rs +++ b/codegen/src/world_init.rs @@ -46,6 +46,7 @@ pub(crate) fn derive( /// /// [`syn::Ident`]: struct@syn::Ident fn step_types(steps: &[&str], world: &syn::Ident) -> Vec { + // TODO: Use "{world}" syntax once MSRV bumps above 1.58. steps .iter() .map(|step| format_ident!("Cucumber{}{}", to_pascal_case(step), world)) diff --git a/src/cucumber.rs b/src/cucumber.rs index 67366f9c..f71a2f2d 100644 --- a/src/cucumber.rs +++ b/src/cucumber.rs @@ -1273,6 +1273,7 @@ where let failed_steps = writer.failed_steps(); if failed_steps > 0 { + // TODO: Use "{failed_steps}" syntax once MSRV bumps above 1.58. msg.push(format!( "{} step{} failed", failed_steps, @@ -1282,6 +1283,8 @@ where let parsing_errors = writer.parsing_errors(); if parsing_errors > 0 { + // TODO: Use "{parsing_errors}" syntax once MSRV bumps above + // 1.58. msg.push(format!( "{} parsing error{}", parsing_errors, @@ -1291,6 +1294,7 @@ where let hook_errors = writer.hook_errors(); if hook_errors > 0 { + // TODO: Use "{hook_errors}" syntax once MSRV bumps above 1.58. msg.push(format!( "{} hook error{}", hook_errors, diff --git a/src/event.rs b/src/event.rs index df665ac3..624bfb42 100644 --- a/src/event.rs +++ b/src/event.rs @@ -356,6 +356,7 @@ pub enum HookType { impl fmt::Display for HookType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // TODO: Use "{self}" syntax once MSRV bumps above 1.58. write!(f, "{:?}", self) } } diff --git a/src/lib.rs b/src/lib.rs index fc326409..379e3aba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,6 +40,7 @@ clippy::filetype_is_file, clippy::float_cmp_const, clippy::fn_to_numeric_cast, + clippy::fn_to_numeric_cast_any, clippy::get_unwrap, clippy::if_then_some_else_none, clippy::imprecise_flops, @@ -65,11 +66,14 @@ clippy::str_to_string, clippy::string_add, clippy::string_lit_as_bytes, + clippy::string_slice, clippy::string_to_string, clippy::suboptimal_flops, clippy::suspicious_operation_groupings, clippy::todo, + clippy::trailing_empty_array, clippy::trivial_regex, + clippy::undocumented_unsafe_blocks, clippy::unimplemented, clippy::unnecessary_self_imports, clippy::unneeded_field_pattern, @@ -112,6 +116,14 @@ pub mod writer; #[cfg(feature = "macros")] pub mod codegen; +// TODO: Remove once tests run without complains about it. +#[cfg(test)] +mod actually_used_crates_in_tests { + use humantime as _; + use tempfile as _; + use tokio as _; +} + use std::error::Error as StdError; use async_trait::async_trait; diff --git a/src/parser/basic.rs b/src/parser/basic.rs index d67fa320..17d789bb 100644 --- a/src/parser/basic.rs +++ b/src/parser/basic.rs @@ -116,6 +116,8 @@ impl> Parser for Basic { .case_insensitive(true) .build() .unwrap_or_else(|e| { + // TODO: Use "{e}" syntax once MSRV bumps above + // 1.58. unreachable!("GlobWalkerBuilder panicked: {}", e) }); walk(w) diff --git a/src/runner/basic.rs b/src/runner/basic.rs index 5fcbcdc7..d9bb668a 100644 --- a/src/runner/basic.rs +++ b/src/runner/basic.rs @@ -853,6 +853,8 @@ where .map_err(Info::from) .and_then(|r| { r.map_err(|e| { + // TODO: Use "{step:p}" syntax once MSRV bumps above + // 1.58. coerce_into_info(format!( "failed to initialize World: {}", e, @@ -1018,6 +1020,8 @@ where Ok(Ok(w)) => w, Ok(Err(e)) => { let e = event::StepError::Panic(coerce_into_info( + // TODO: Use "{step:p}" syntax once MSRV bumps above + // 1.58. format!("failed to initialize World: {}", e), )); return Err((e, None, None)); diff --git a/src/step.rs b/src/step.rs index 782dad26..e40a4099 100644 --- a/src/step.rs +++ b/src/step.rs @@ -60,6 +60,7 @@ impl fmt::Debug for Collection { f.debug_struct("Collection") .field( "given", + // TODO: Use "{step:p}" syntax once MSRV bumps above 1.58. &self .given .iter() @@ -68,6 +69,7 @@ impl fmt::Debug for Collection { ) .field( "when", + // TODO: Use "{step:p}" syntax once MSRV bumps above 1.58. &self .when .iter() @@ -76,6 +78,7 @@ impl fmt::Debug for Collection { ) .field( "then", + // TODO: Use "{step:p}" syntax once MSRV bumps above 1.58. &self .then .iter() @@ -184,6 +187,8 @@ impl Collection { } }; + // All indices here are obtained from the source string. + #[allow(clippy::string_slice)] let matches = iter::once(whole_match.as_str().to_owned()) .chain((1..captures.len()).map(|group_id| { captures diff --git a/src/writer/basic.rs b/src/writer/basic.rs index 89bcf62d..d7382b63 100644 --- a/src/writer/basic.rs +++ b/src/writer/basic.rs @@ -146,7 +146,10 @@ where Feature::Finished => Ok(()), }, } - .unwrap_or_else(|e| panic!("Failed to write into terminal: {}", e)); + .unwrap_or_else(|e| { + // TODO: Use "{e}" syntax once MSRV bumps above 1.58. + panic!("Failed to write into terminal: {}", e) + }); } } @@ -162,6 +165,7 @@ where where 'val: 'async_trait, { + // TODO: Use "{e}" syntax once MSRV bumps above 1.58. self.write_line(val.as_ref()) .unwrap_or_else(|e| panic!("Failed to write: {}", e)); } @@ -249,6 +253,7 @@ impl Basic { &mut self, error: impl Display, ) -> io::Result<()> { + // TODO: Use "{error}" syntax once MSRV bumps above 1.58. self.output .write_line(&self.styles.err(format!("Failed to parse: {}", error))) } @@ -369,7 +374,7 @@ impl Basic { self.clear_last_lines_if_term_present()?; self.output.write_line(&self.styles.err(format!( - "{indent}\u{2718} Scenario's {} hook failed {}:{}:{}\n\ + "{indent}✘ Scenario's {} hook failed {}:{}:{}\n\ {indent} Captured output: {}{}", which, feat.path @@ -381,6 +386,7 @@ impl Basic { coerce_error(info), world .map(|w| format_str_with_indent( + // TODO: Use "{w:#?}" syntax once MSRV bumps above 1.58. format!("{:#?}", w), self.indent.saturating_sub(3) + 3, )) @@ -496,8 +502,7 @@ impl Basic { ) -> io::Result<()> { self.clear_last_lines_if_term_present()?; - let step_keyword = - self.styles.ok(format!("\u{2714} {}", step.keyword)); + let step_keyword = self.styles.ok(format!("✔ {}", step.keyword)); let step_value = format_captures( &step.value, captures, @@ -522,6 +527,7 @@ impl Basic { .map(|t| format_table(t, self.indent)) .unwrap_or_default()); + // TODO: Use "{step_keyword}" syntax once MSRV bumps above 1.58. self.output.write_line(&self.styles.ok(format!( "{indent}{} {}{}{}", step_keyword, @@ -585,7 +591,7 @@ impl Basic { self.clear_last_lines_if_term_present()?; let step_keyword = self.styles.err(format!( - "{indent}\u{2718} {}", + "{indent}✘ {}", step.keyword, indent = " ".repeat(self.indent.saturating_sub(3)), )); @@ -626,11 +632,12 @@ impl Basic { step.position.line, step.position.col, format_str_with_indent( - format!("{}", err), + err.to_string(), self.indent.saturating_sub(3) + 3, ), world .map(|w| format_str_with_indent( + // TODO: Use "{w:#?}" syntax once MSRV bumps above 1.58. format!("{:#?}", w), self.indent.saturating_sub(3) + 3, )) @@ -639,6 +646,7 @@ impl Basic { indent = " ".repeat(self.indent.saturating_sub(3)) )); + // TODO: Use "{step_keyword}" syntax once MSRV bumps above 1.58. self.write_line(&format!( "{} {}{}", step_keyword, step_value, diagnostics, @@ -738,8 +746,7 @@ impl Basic { ) -> io::Result<()> { self.clear_last_lines_if_term_present()?; - let step_keyword = - self.styles.ok(format!("\u{2714}> {}", step.keyword)); + let step_keyword = self.styles.ok(format!("✔> {}", step.keyword)); let step_value = format_captures( &step.value, captures, @@ -764,6 +771,7 @@ impl Basic { .map(|t| format_table(t, self.indent)) .unwrap_or_default()); + // TODO: Use "{step_keyword}" syntax once MSRV bumps above 1.58. self.output.write_line(&self.styles.ok(format!( "{indent}{} {}{}{}", step_keyword, @@ -829,7 +837,7 @@ impl Basic { self.clear_last_lines_if_term_present()?; let step_keyword = self.styles.err(format!( - "{indent}\u{2718}> {}{}", + "{indent}✘> {}{}", step.keyword, indent = " ".repeat(self.indent.saturating_sub(3)), )); @@ -870,11 +878,12 @@ impl Basic { step.position.line, step.position.col, format_str_with_indent( - format!("{}", err), + err.to_string(), self.indent.saturating_sub(3) + 3, ), world .map(|w| format_str_with_indent( + // TODO: Use "{w:#?}" syntax once MSRV bumps above 1.58. format!("{:#?}", w), self.indent.saturating_sub(3) + 3, )) @@ -882,6 +891,7 @@ impl Basic { indent = " ".repeat(self.indent.saturating_sub(3)) )); + // TODO: Use "{step_keyword}" syntax once MSRV bumps above 1.58. self.write_line(&format!( "{} {}{}", step_keyword, step_value, diagnostics, @@ -906,11 +916,13 @@ pub(crate) fn coerce_error(err: &Info) -> Cow<'static, str> { /// Formats the given [`str`] by adding `indent`s to each line to prettify the /// output. fn format_str_with_indent(str: impl AsRef, indent: usize) -> String { + // TODO: Use "{line}" syntax once MSRV bumps above 1.58. let str = str .as_ref() .lines() .map(|line| format!("{}{}", " ".repeat(indent), line)) .join("\n"); + // TODO: Use "{str}" syntax once MSRV bumps above 1.58. (!str.is_empty()) .then(|| format!("\n{}", str)) .unwrap_or_default() @@ -935,6 +947,7 @@ fn format_table(table: &gherkin::Table, indent: usize) -> String { }) .unwrap_or_default(); + // TODO: Use "{cell:len$}" and "{row}" syntax once MSRV bumps above 1.58. let mut table = table .rows .iter() @@ -967,6 +980,9 @@ where D: for<'a> Fn(&'a str) -> Cow<'a, str>, A: for<'a> Fn(&'a str) -> Cow<'a, str>, { + // All indices here are obtained from the source string. + #![allow(clippy::string_slice)] + let value = value.as_ref(); let (mut formatted, end) = (1..captures.len()) diff --git a/src/writer/json.rs b/src/writer/json.rs index 6ae73cbb..056717d7 100644 --- a/src/writer/json.rs +++ b/src/writer/json.rs @@ -97,11 +97,16 @@ impl Writer for Json { .write_all( serde_json::to_string(&self.features) .unwrap_or_else(|e| { + // TODO: Use "{e}" syntax once MSRV bumps above + // 1.58. panic!("Failed to serialize JSON: {}", e) }) .as_bytes(), ) - .unwrap_or_else(|e| panic!("Failed to write JSON: {}", e)); + .unwrap_or_else(|e| { + // TODO: Use "{e}" syntax once MSRV bumps above 1.58. + panic!("Failed to write JSON: {}", e) + }); } _ => {} } @@ -204,11 +209,13 @@ impl Json { let mut duration = || { let started = self.started.take().unwrap_or_else(|| { + // TODO: Use "{hook_ty}" syntax once MSRV bumps above 1.58. panic!("No `Started` event for `{} Hook`", hook_ty) }); meta.at .duration_since(started) .unwrap_or_else(|e| { + // TODO: Use "{e}" syntax once MSRV bumps above 1.58. panic!( "Failed to compute duration between {:?} and {:?}: {}", meta.at, started, e, @@ -265,6 +272,7 @@ impl Json { meta.at .duration_since(started) .unwrap_or_else(|e| { + // TODO: Use "{e}" syntax once MSRV bumps above 1.58. panic!( "Failed to compute duration between {:?} and {:?}: {}", meta.at, started, e, diff --git a/src/writer/junit.rs b/src/writer/junit.rs index 58931bb7..79573f74 100644 --- a/src/writer/junit.rs +++ b/src/writer/junit.rs @@ -115,6 +115,8 @@ where TestSuiteBuilder::new(&format!( "Feature: {}{}", &feat.name, + // TODO: Use "{path}" syntax once MSRV bumps above + // 1.58. feat.path .as_deref() .and_then(Path::to_str) @@ -134,6 +136,8 @@ where } Feature::Finished => { let suite = self.suit.take().unwrap_or_else(|| { + // TODO: Use "{WRAP_ADVICE}" syntax once MSRV bumps + // above 1.58. panic!( "No `TestSuit` for `Feature` \"{}\"\n{}", feat.name, WRAP_ADVICE, @@ -143,6 +147,7 @@ where } }, Ok((Cucumber::Finished, _)) => { + // TODO: Use "{e}" syntax once MSRV bumps above 1.58. self.report .write_xml(&mut self.output) .unwrap_or_else(|e| panic!("Failed to write XML: {}", e)); @@ -225,6 +230,7 @@ impl JUnit { ( format!( "Feature{}", + // TODO: Use "{p}" syntax once MSRV bumps above 1.58. path.to_str() .map(|p| format!(": {}", p)) .unwrap_or_default(), @@ -235,6 +241,7 @@ impl JUnit { parser::Error::ExampleExpansion(err) => ( format!( "Feature: {}{}:{}", + // TODO: Use "{p}" syntax once MSRV bumps above 1.58. err.path .as_deref() .and_then(Path::to_str) @@ -253,7 +260,7 @@ impl JUnit { &name, Duration::ZERO, ty, - &format!("{}", err), + &err.to_string(), )) .build(), ); @@ -288,6 +295,8 @@ impl JUnit { self.suit .as_mut() .unwrap_or_else(|| { + // TODO: Use "{WRAP_ADVICE}" syntax once MSRV bumps + // above 1.58. panic!( "No `TestSuit` for `Scenario` \"{}\"\n{}", sc.name, WRAP_ADVICE, @@ -322,6 +331,7 @@ impl JUnit { ) }) .unwrap_or_else(|| { + // TODO: Use "{WRAP_ADVICE}" syntax once MSRV bumps above 1.58. panic!( "No events for `Scenario` \"{}\"\n{}", sc.name, WRAP_ADVICE, @@ -333,6 +343,7 @@ impl JUnit { rule.map(|r| format!("Rule: {}: ", r.name)) .unwrap_or_default(), sc.name, + // TODO: Use "{path}" syntax once MSRV bumps above 1.58. feat.path .as_ref() .and_then(|p| p.to_str()) @@ -371,6 +382,7 @@ impl JUnit { .build() } Scenario::Finished => { + // TODO: Use "{WRAP_ADVICE}" syntax once MSRV bumps above 1.58. panic!( "Duplicated `Finished` event for `Scenario`: \"{}\"\n{}", sc.name, WRAP_ADVICE, @@ -393,6 +405,7 @@ impl JUnit { }) .collect::>() .unwrap_or_else(|e| { + // TODO: Use "{e}" syntax once MSRV bumps above 1.58. panic!("Failed to write with `writer::Basic`: {}", e) }); @@ -410,6 +423,7 @@ impl JUnit { sc: &gherkin::Scenario, ) -> Duration { let started_at = self.scenario_started_at.take().unwrap_or_else(|| { + // TODO: Use "{WRAP_ADVICE}" syntax once MSRV bumps above 1.58. panic!( "No `Started` event for `Scenario` \"{}\"\n{}", sc.name, WRAP_ADVICE, @@ -417,6 +431,7 @@ impl JUnit { }); Duration::try_from(ended.duration_since(started_at).unwrap_or_else( |e| { + // TODO: Use "{e}" syntax once MSRV bumps above 1.58. panic!( "Failed to compute duration between {:?} and {:?}: {}", ended, started_at, e, @@ -424,6 +439,7 @@ impl JUnit { }, )) .unwrap_or_else(|e| { + // TODO: Use "{e}" syntax once MSRV bumps above 1.58. panic!( "Cannot covert `std::time::Duration` to `time::Duration`: {}", e, diff --git a/src/writer/out.rs b/src/writer/out.rs index 357373a2..718dbfa7 100644 --- a/src/writer/out.rs +++ b/src/writer/out.rs @@ -155,6 +155,7 @@ pub trait WriteStrExt: io::Write { /// /// If this writer fails to write a special sequence. fn move_cursor_up(&mut self, n: usize) -> io::Result<()> { + // TODO: Use "{n}" syntax once MSRV bumps above 1.58. (n > 0) .then(|| self.write_str(format!("\x1b[{}A", n))) .unwrap_or(Ok(())) @@ -167,6 +168,7 @@ pub trait WriteStrExt: io::Write { /// /// If this writer fails to write a special sequence. fn move_cursor_down(&mut self, n: usize) -> io::Result<()> { + // TODO: Use "{n}" syntax once MSRV bumps above 1.58. (n > 0) .then(|| self.write_str(format!("\x1b[{}B", n))) .unwrap_or(Ok(())) diff --git a/src/writer/summarize.rs b/src/writer/summarize.rs index d8181bfd..6ba1126c 100644 --- a/src/writer/summarize.rs +++ b/src/writer/summarize.rs @@ -486,6 +486,7 @@ impl Styles { .then(|| self.err(", ")) .unwrap_or_default(); + // TODO: Use "{features}" syntax once MSRV bumps above 1.58. format!( "{}\n{}\n{}{}{}\n{}{}\n{}{}{}", self.bold(self.header("[Summary]")), @@ -529,6 +530,7 @@ impl Styles { (!formatted.is_empty()) .then(|| { + // TODO: Use "{formatted}" syntax once MSRV bumps above 1.58. self.bold(format!( " {}{}{}", self.bold("("), @@ -545,6 +547,7 @@ impl Styles { singular: impl Into>, num: usize, ) -> Cow<'static, str> { + // TODO: Use "{num}" syntax once MSRV bumps above 1.58. self.bold(format!( "{} {}{}", num, diff --git a/tests/output.rs b/tests/output.rs index 8b553302..5cf58f8b 100644 --- a/tests/output.rs +++ b/tests/output.rs @@ -94,6 +94,7 @@ impl Writer for DebugWriter { ), ); + // TODO: Use "{ev:?}" syntax once MSRV bumps above 1.58. format!("{:?}", ev).into() } Ok(Cucumber::Feature( @@ -120,8 +121,10 @@ impl Writer for DebugWriter { ), ); + // TODO: Use "{ev:?}" syntax once MSRV bumps above 1.58. format!("{:?}", ev).into() } + // TODO: Use "{ev:?}" syntax once MSRV bumps above 1.58. Ok(ev) => format!("{:?}", ev).into(), }; @@ -163,6 +166,7 @@ mod spec { .collect::>(); for file in files { + // TODO: Use "{file}" syntax once MSRV bumps above 1.58. let out = fs::read_to_string(format!( "tests/features/output/{}.out", file, @@ -170,11 +174,13 @@ mod spec { .unwrap_or_default() .lines() .collect::(); + // TODO: Use "{file}" syntax once MSRV bumps above 1.58. let normalized = World::cucumber() .with_writer(DebugWriter::default().normalized()) .run(format!("tests/features/output/{}", file)) .await; + // TODO: Use "{file}" syntax once MSRV bumps above 1.58. assert_eq!(normalized.0, out, "file: {}", file); } }