Skip to content

Commit 935602b

Browse files
committed
Tune lints for 1.58 Rust
1 parent 73c0033 commit 935602b

File tree

18 files changed

+121
-19
lines changed

18 files changed

+121
-19
lines changed

book/src/architecture/writer.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl<W: 'static> cucumber::Writer<W> for CustomWriter {
271271
event::Step::Passed(_) => println!("ok"),
272272
event::Step::Skipped => println!("skip"),
273273
event::Step::Failed(_, _, err) => {
274-
println!("failed: {}", err)
274+
println!("failed: {err}")
275275
}
276276
},
277277
_ => {}
@@ -280,7 +280,7 @@ impl<W: 'static> cucumber::Writer<W> for CustomWriter {
280280
},
281281
_ => {}
282282
},
283-
Err(e) => println!("Error: {}", e),
283+
Err(e) => println!("Error: {e}"),
284284
}
285285
}
286286
}
@@ -450,7 +450,7 @@ async fn main() {
450450
# event::Step::Passed(_) => println!("ok"),
451451
# event::Step::Skipped => println!("skip"),
452452
# event::Step::Failed(_, _, err) => {
453-
# println!("failed: {}", err)
453+
# println!("failed: {err}", )
454454
# }
455455
# },
456456
# _ => {}
@@ -459,7 +459,7 @@ async fn main() {
459459
# },
460460
# _ => {}
461461
# },
462-
# Err(e) => println!("Error: {}", e),
462+
# Err(e) => println!("Error: {e}"),
463463
# }
464464
# }
465465
# }

book/src/writing/capturing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl FromStr for State {
111111
Ok(match s {
112112
"hungry" => Self::Hungry,
113113
"satiated" => Self::Satiated,
114-
invalid => return Err(format!("Invalid `State`: {}", invalid)),
114+
invalid => return Err(format!("Invalid `State`: {invalid}")),
115115
})
116116
}
117117
}
@@ -194,7 +194,7 @@ Alternatively, a [Cucumber Expression][expr] may be used to capture values. This
194194
# Ok(match s {
195195
# "hungry" => Self::Hungry,
196196
# "satiated" => Self::Satiated,
197-
# invalid => return Err(format!("Invalid `State`: {}", invalid)),
197+
# invalid => return Err(format!("Invalid `State`: {invalid}")),
198198
# })
199199
# }
200200
# }
@@ -285,7 +285,7 @@ impl FromStr for State {
285285
Ok(match s {
286286
"hungry" => Self::Hungry,
287287
"satiated" => Self::Satiated,
288-
invalid => return Err(format!("Invalid `State`: {}", invalid)),
288+
invalid => return Err(format!("Invalid `State`: {invalid}")),
289289
})
290290
}
291291
}

codegen/src/attribute.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,11 @@ impl Step {
113113

114114
let regex = self.gen_regex()?;
115115

116+
// TODO: Use "{func_name}" syntax once MSRV bumps above 1.58.
116117
let caller_name =
117118
format_ident!("__cucumber_{}_{}", self.attr_name, func_name);
118119
let awaiting = func.sig.asyncness.map(|_| quote! { .await });
120+
// TODO: Use "{e}" syntax once MSRV bumps above 1.58.
119121
let unwrapping = (!self.returns_unit())
120122
.then(|| quote! { .unwrap_or_else(|e| panic!("{}", e)) });
121123
let step_caller = quote! {
@@ -302,6 +304,7 @@ impl Step {
302304
return Err(syn::Error::new(ty.span(), "Type path expected"));
303305
};
304306

307+
// TODO: Use "{ident}" syntax once MSRV bumps above 1.58.
305308
let not_found_err = format!("{} not found", ident);
306309
let parsing_err = format!(
307310
"{} can not be parsed to {}",
@@ -371,6 +374,7 @@ impl Step {
371374
}
372375
AttributeArgument::Regex(re) => {
373376
drop(Regex::new(re.value().as_str()).map_err(|e| {
377+
// TODO: Use "{e}" syntax once MSRV bumps above 1.58.
374378
syn::Error::new(re.span(), format!("Invalid regex: {}", e))
375379
})?);
376380

@@ -455,6 +459,7 @@ impl<'p> Parameters<'p> {
455459
let expr = Expression::parse(expr).map_err(|e| {
456460
syn::Error::new(
457461
expr.span(),
462+
// TODO: Use "{e}" syntax once MSRV bumps above 1.58.
458463
format!("Incorrect cucumber expression: {}", e),
459464
)
460465
})?;
@@ -580,6 +585,7 @@ impl<'p> Parameters<'p> {
580585
} else {
581586
// Here we use double escaping to properly render `{name}`
582587
// in the assertion message of the generated code.
588+
// TODO: Use "{name}" syntax once MSRV bumps above 1.58.
583589
let assert_msg = format!(
584590
"Type `{}` doesn't implement a custom parameter \
585591
`{{{{{}}}}}`",

codegen/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
clippy::fallible_impl_from,
3939
clippy::float_cmp_const,
4040
clippy::fn_to_numeric_cast,
41+
clippy::fn_to_numeric_cast_any,
4142
clippy::get_unwrap,
4243
clippy::if_then_some_else_none,
4344
clippy::imprecise_flops,
@@ -63,11 +64,14 @@
6364
clippy::str_to_string,
6465
clippy::string_add,
6566
clippy::string_lit_as_bytes,
67+
clippy::string_slice,
6668
clippy::string_to_string,
6769
clippy::suboptimal_flops,
6870
clippy::suspicious_operation_groupings,
6971
clippy::todo,
72+
clippy::trailing_empty_array,
7073
clippy::trivial_regex,
74+
clippy::undocumented_unsafe_blocks,
7175
clippy::unimplemented,
7276
clippy::unnecessary_self_imports,
7377
clippy::unneeded_field_pattern,
@@ -101,6 +105,17 @@ mod world_init;
101105

102106
use proc_macro::TokenStream;
103107

108+
// TODO: Remove once tests run without complains about it.
109+
#[cfg(test)]
110+
mod actually_used_crates_in_tests {
111+
use async_trait as _;
112+
use cucumber as _;
113+
use derive_more as _;
114+
use futures as _;
115+
use tempfile as _;
116+
use tokio as _;
117+
}
118+
104119
/// Helper macro for generating public shims for [`macro@given`], [`macro@when`]
105120
/// and [`macro@then`] attributes.
106121
macro_rules! step_attribute {

codegen/src/parameter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ impl TryFrom<syn::DeriveInput> for Definition {
6565
let attrs: Attrs = Attrs::parse_attrs("param", &input)?;
6666

6767
let regex = Regex::new(&attrs.regex.value()).map_err(|e| {
68+
// TODO: Use "{e}" syntax once MSRV bumps above 1.58.
6869
syn::Error::new(attrs.regex.span(), format!("Invalid regex: {}", e))
6970
})?;
7071
if regex.captures_len() > 1 {

codegen/src/world_init.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub(crate) fn derive(
4646
///
4747
/// [`syn::Ident`]: struct@syn::Ident
4848
fn step_types(steps: &[&str], world: &syn::Ident) -> Vec<syn::Ident> {
49+
// TODO: Use "{world}" syntax once MSRV bumps above 1.58.
4950
steps
5051
.iter()
5152
.map(|step| format_ident!("Cucumber{}{}", to_pascal_case(step), world))

src/cucumber.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,7 @@ where
12731273

12741274
let failed_steps = writer.failed_steps();
12751275
if failed_steps > 0 {
1276+
// TODO: Use "{failed_steps}" syntax once MSRV bumps above 1.58.
12761277
msg.push(format!(
12771278
"{} step{} failed",
12781279
failed_steps,
@@ -1282,6 +1283,8 @@ where
12821283

12831284
let parsing_errors = writer.parsing_errors();
12841285
if parsing_errors > 0 {
1286+
// TODO: Use "{parsing_errors}" syntax once MSRV bumps above
1287+
// 1.58.
12851288
msg.push(format!(
12861289
"{} parsing error{}",
12871290
parsing_errors,
@@ -1291,6 +1294,7 @@ where
12911294

12921295
let hook_errors = writer.hook_errors();
12931296
if hook_errors > 0 {
1297+
// TODO: Use "{hook_errors}" syntax once MSRV bumps above 1.58.
12941298
msg.push(format!(
12951299
"{} hook error{}",
12961300
hook_errors,

src/event.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ pub enum HookType {
356356

357357
impl fmt::Display for HookType {
358358
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
359+
// TODO: Use "{self}" syntax once MSRV bumps above 1.58.
359360
write!(f, "{:?}", self)
360361
}
361362
}

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
clippy::filetype_is_file,
4141
clippy::float_cmp_const,
4242
clippy::fn_to_numeric_cast,
43+
clippy::fn_to_numeric_cast_any,
4344
clippy::get_unwrap,
4445
clippy::if_then_some_else_none,
4546
clippy::imprecise_flops,
@@ -65,11 +66,14 @@
6566
clippy::str_to_string,
6667
clippy::string_add,
6768
clippy::string_lit_as_bytes,
69+
clippy::string_slice,
6870
clippy::string_to_string,
6971
clippy::suboptimal_flops,
7072
clippy::suspicious_operation_groupings,
7173
clippy::todo,
74+
clippy::trailing_empty_array,
7275
clippy::trivial_regex,
76+
clippy::undocumented_unsafe_blocks,
7377
clippy::unimplemented,
7478
clippy::unnecessary_self_imports,
7579
clippy::unneeded_field_pattern,
@@ -112,6 +116,14 @@ pub mod writer;
112116
#[cfg(feature = "macros")]
113117
pub mod codegen;
114118

119+
// TODO: Remove once tests run without complains about it.
120+
#[cfg(test)]
121+
mod actually_used_crates_in_tests {
122+
use humantime as _;
123+
use tempfile as _;
124+
use tokio as _;
125+
}
126+
115127
use std::error::Error as StdError;
116128

117129
use async_trait::async_trait;

src/parser/basic.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ impl<I: AsRef<Path>> Parser<I> for Basic {
116116
.case_insensitive(true)
117117
.build()
118118
.unwrap_or_else(|e| {
119+
// TODO: Use "{e}" syntax once MSRV bumps above
120+
// 1.58.
119121
unreachable!("GlobWalkerBuilder panicked: {}", e)
120122
});
121123
walk(w)

0 commit comments

Comments
 (0)