Skip to content

Commit a5daa52

Browse files
committed
Tune lints for 1.80 Rust
1 parent e3a4887 commit a5daa52

15 files changed

+53
-47
lines changed

.clippy.toml

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ absolute-paths-allowed-crates = [
1313

1414
doc-valid-idents = ["JUnit"]
1515

16+
ignore-interior-mutability = ["cucumber::step::HashableRegex"]
17+
1618
standard-macro-braces = [
1719
{ name = "assert", brace = "(" },
1820
{ name = "assert_eq", brace = "(" },

codegen/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
clippy::read_zero_byte_vec,
9494
clippy::redundant_clone,
9595
clippy::redundant_type_annotations,
96+
clippy::renamed_function_params,
9697
clippy::ref_patterns,
9798
clippy::rest_pat_in_fully_bound_structs,
9899
clippy::same_name_method,
@@ -130,6 +131,7 @@
130131
clippy::use_self,
131132
clippy::useless_let_if_seq,
132133
clippy::verbose_file_reads,
134+
clippy::while_float,
133135
clippy::wildcard_enum_match_arm,
134136
explicit_outlives_requirements,
135137
future_incompatible,

src/cucumber.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,8 @@ where
572572
/// [`cli::Opts`].
573573
///
574574
/// > ⚠️ __WARNING__: Any CLI options of [`Parser`], [`Runner`], [`Writer`]
575-
/// or custom ones should not overlap, otherwise
576-
/// [`cli::Opts`] will fail to parse on startup.
575+
/// > or custom ones should not overlap, otherwise
576+
/// > [`cli::Opts`] will fail to parse on startup.
577577
///
578578
/// # Example
579579
///

src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
clippy::read_zero_byte_vec,
9595
clippy::redundant_clone,
9696
clippy::redundant_type_annotations,
97+
clippy::renamed_function_params,
9798
clippy::ref_patterns,
9899
clippy::rest_pat_in_fully_bound_structs,
99100
clippy::same_name_method,
@@ -131,6 +132,7 @@
131132
clippy::use_self,
132133
clippy::useless_let_if_seq,
133134
clippy::verbose_file_reads,
135+
clippy::while_float,
134136
clippy::wildcard_enum_match_arm,
135137
explicit_outlives_requirements,
136138
future_incompatible,

src/parser/basic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<I: AsRef<Path>> Parser<I> for Basic {
6161
type Output =
6262
stream::Iter<vec::IntoIter<Result<gherkin::Feature, ParseError>>>;
6363

64-
fn parse(self, path: I, cli: Self::Cli) -> Self::Output {
64+
fn parse(self, input: I, cli: Self::Cli) -> Self::Output {
6565
let walk = |walker: GlobWalker| {
6666
walker
6767
.filter_map(Result::ok)
@@ -78,7 +78,7 @@ impl<I: AsRef<Path>> Parser<I> for Basic {
7878
};
7979

8080
let get_features_path = || {
81-
let path = path.as_ref();
81+
let path = input.as_ref();
8282
path.canonicalize()
8383
.or_else(|_| {
8484
let mut buf = PathBuf::from(env!("CARGO_MANIFEST_DIR"));

src/tracing.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,13 @@ where
403403
{
404404
fn on_new_span(
405405
&self,
406-
attr: &span::Attributes<'_>,
406+
attrs: &span::Attributes<'_>,
407407
id: &span::Id,
408408
ctx: layer::Context<'_, S>,
409409
) {
410410
if let Some(span) = ctx.span(id) {
411411
let mut visitor = GetScenarioId(None);
412-
attr.values().record(&mut visitor);
412+
attrs.values().record(&mut visitor);
413413

414414
if let Some(scenario_id) = visitor.0 {
415415
let mut ext = span.extensions_mut();

src/writer/basic.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ where
140140

141141
async fn handle_event(
142142
&mut self,
143-
ev: parser::Result<Event<event::Cucumber<W>>>,
144-
opts: &Self::Cli,
143+
event: parser::Result<Event<event::Cucumber<W>>>,
144+
cli: &Self::Cli,
145145
) {
146146
use event::{Cucumber, Feature};
147147

148-
self.apply_cli(*opts);
148+
self.apply_cli(*cli);
149149

150-
match ev.map(Event::into_inner) {
150+
match event.map(Event::into_inner) {
151151
Err(err) => self.parsing_failed(&err),
152152
Ok(
153153
Cucumber::Started
@@ -263,7 +263,7 @@ impl<Out: io::Write> Basic<Out> {
263263
error: impl Display,
264264
) -> io::Result<()> {
265265
self.output
266-
.write_line(&self.styles.err(format!("Failed to parse: {error}")))
266+
.write_line(self.styles.err(format!("Failed to parse: {error}")))
267267
}
268268

269269
/// Outputs the [started] [`Feature`].
@@ -275,7 +275,7 @@ impl<Out: io::Write> Basic<Out> {
275275
feature: &gherkin::Feature,
276276
) -> io::Result<()> {
277277
let out = format!("{}: {}", feature.keyword, feature.name);
278-
self.output.write_line(&self.styles.ok(out))
278+
self.output.write_line(self.styles.ok(out))
279279
}
280280

281281
/// Outputs the [`Rule`]'s [started]/[scenario]/[finished] event.
@@ -321,7 +321,7 @@ impl<Out: io::Write> Basic<Out> {
321321
indent = " ".repeat(self.indent)
322322
);
323323
self.indent += 2;
324-
self.output.write_line(&self.styles.ok(out))
324+
self.output.write_line(self.styles.ok(out))
325325
}
326326

327327
/// Outputs the [`Scenario`]'s [started]/[background]/[step] event.
@@ -404,7 +404,7 @@ impl<Out: io::Write> Basic<Out> {
404404
}
405405
};
406406

407-
self.output.write_line(&style(format!(
407+
self.output.write_line(style(format!(
408408
"{indent}✘ Scenario's {which} hook failed {}:{}:{}\n\
409409
{indent} Captured output: {}{}",
410410
feat.path
@@ -448,15 +448,15 @@ impl<Out: io::Write> Basic<Out> {
448448
retries.current,
449449
retries.left + retries.current,
450450
);
451-
self.output.write_line(&self.styles.retry(out))
451+
self.output.write_line(self.styles.retry(out))
452452
} else {
453453
let out = format!(
454454
"{}{}: {}",
455455
" ".repeat(self.indent),
456456
scenario.keyword,
457457
scenario.name,
458458
);
459-
self.output.write_line(&self.styles.ok(out))
459+
self.output.write_line(self.styles.ok(out))
460460
}
461461
}
462462

@@ -598,7 +598,7 @@ impl<Out: io::Write> Basic<Out> {
598598
.unwrap_or_default(),
599599
);
600600

601-
self.output.write_line(&style(format!(
601+
self.output.write_line(style(format!(
602602
"{indent}{step_keyword}{step_value}{doc_str}{step_table}",
603603
indent = " ".repeat(self.indent.saturating_sub(3)),
604604
)))
@@ -614,7 +614,7 @@ impl<Out: io::Write> Basic<Out> {
614614
step: &gherkin::Step,
615615
) -> io::Result<()> {
616616
self.clear_last_lines_if_term_present()?;
617-
self.output.write_line(&self.styles.skipped(format!(
617+
self.output.write_line(self.styles.skipped(format!(
618618
"{indent}? {}{}{}{}\n\
619619
{indent} Step skipped: {}:{}:{}",
620620
step.keyword,
@@ -877,7 +877,7 @@ impl<Out: io::Write> Basic<Out> {
877877
.unwrap_or_default(),
878878
);
879879

880-
self.output.write_line(&style(format!(
880+
self.output.write_line(style(format!(
881881
"{step_keyword}{step_value}{doc_str}{step_table}",
882882
)))
883883
}
@@ -893,7 +893,7 @@ impl<Out: io::Write> Basic<Out> {
893893
step: &gherkin::Step,
894894
) -> io::Result<()> {
895895
self.clear_last_lines_if_term_present()?;
896-
self.output.write_line(&self.styles.skipped(format!(
896+
self.output.write_line(self.styles.skipped(format!(
897897
"{indent}?> {}{}{}{}\n\
898898
{indent} Background step failed: {}:{}:{}",
899899
step.keyword,

src/writer/discard.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ impl<W: World, Wr: Writer<W> + ?Sized> Writer<W> for Arbitrary<Wr> {
2929

3030
async fn handle_event(
3131
&mut self,
32-
ev: parser::Result<Event<Cucumber<W>>>,
32+
event: parser::Result<Event<Cucumber<W>>>,
3333
cli: &Self::Cli,
3434
) {
35-
self.0.handle_event(ev, cli).await;
35+
self.0.handle_event(event, cli).await;
3636
}
3737
}
3838

@@ -114,10 +114,10 @@ impl<W: World, Wr: Writer<W> + ?Sized> Writer<W> for Stats<Wr> {
114114

115115
async fn handle_event(
116116
&mut self,
117-
ev: parser::Result<Event<Cucumber<W>>>,
117+
event: parser::Result<Event<Cucumber<W>>>,
118118
cli: &Self::Cli,
119119
) {
120-
self.0.handle_event(ev, cli).await;
120+
self.0.handle_event(event, cli).await;
121121
}
122122
}
123123

src/writer/json.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -799,18 +799,18 @@ impl Feature {
799799
}
800800

801801
impl PartialEq<gherkin::Feature> for Feature {
802-
fn eq(&self, feature: &gherkin::Feature) -> bool {
802+
fn eq(&self, other: &gherkin::Feature) -> bool {
803803
self.uri
804804
.as_ref()
805805
.and_then(|uri| {
806-
feature
806+
other
807807
.path
808808
.as_ref()
809809
.and_then(|p| p.to_str().map(trim_path))
810810
.map(|path| uri == path)
811811
})
812812
.unwrap_or_default()
813-
&& self.name == feature.name
813+
&& self.name == other.name
814814
}
815815
}
816816

src/writer/junit.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ where
112112

113113
async fn handle_event(
114114
&mut self,
115-
ev: parser::Result<Event<event::Cucumber<W>>>,
116-
opts: &Self::Cli,
115+
event: parser::Result<Event<event::Cucumber<W>>>,
116+
cli: &Self::Cli,
117117
) {
118118
use event::{Cucumber, Feature, Rule};
119119

120-
self.apply_cli(*opts);
120+
self.apply_cli(*cli);
121121

122-
match ev.map(Event::split) {
122+
match event.map(Event::split) {
123123
Err(err) => self.handle_error(&err),
124124
Ok((Cucumber::Started | Cucumber::ParsingFinished { .. }, _)) => {}
125125
Ok((Cucumber::Feature(feat, ev), meta)) => match ev {

src/writer/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub trait Writer<World> {
8686
/// [`Cucumber`]: crate::event::Cucumber
8787
fn handle_event(
8888
&mut self,
89-
ev: parser::Result<Event<event::Cucumber<World>>>,
89+
event: parser::Result<Event<event::Cucumber<World>>>,
9090
cli: &Self::Cli,
9191
) -> impl Future<Output = ()>;
9292
}
@@ -285,15 +285,15 @@ impl<T> Ext for T {
285285
FailOnSkipped::from(self)
286286
}
287287

288-
fn fail_on_skipped_with<F>(self, f: F) -> FailOnSkipped<Self, F>
288+
fn fail_on_skipped_with<F>(self, with: F) -> FailOnSkipped<Self, F>
289289
where
290290
F: Fn(
291291
&gherkin::Feature,
292292
Option<&gherkin::Rule>,
293293
&gherkin::Scenario,
294294
) -> bool,
295295
{
296-
FailOnSkipped::with(self, f)
296+
FailOnSkipped::with(self, with)
297297
}
298298

299299
fn repeat_skipped<W>(self) -> Repeat<W, Self> {

src/writer/normalize.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -702,17 +702,17 @@ impl<'me, World> Emitter<World> for &'me mut FeatureQueue<World> {
702702

703703
async fn emit<W: Writer<World>>(
704704
self,
705-
feature: Self::EmittedPath,
705+
path: Self::EmittedPath,
706706
writer: &mut W,
707707
cli: &W::Cli,
708708
) -> Option<Self::Emitted> {
709709
match self.current_item()? {
710710
Either::Left((rule, events)) => events
711-
.emit((feature, rule), writer, cli)
711+
.emit((path, rule), writer, cli)
712712
.await
713713
.map(Either::Left),
714714
Either::Right((scenario, events)) => events
715-
.emit((feature, None, scenario), writer, cli)
715+
.emit((path, None, scenario), writer, cli)
716716
.await
717717
.map(Either::Right),
718718
}

src/writer/or.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ where
6969

7070
async fn handle_event(
7171
&mut self,
72-
ev: parser::Result<Event<event::Cucumber<W>>>,
72+
event: parser::Result<Event<event::Cucumber<W>>>,
7373
cli: &Self::Cli,
7474
) {
75-
if (self.predicate)(&ev, cli) {
76-
self.left.handle_event(ev, &cli.left).await;
75+
if (self.predicate)(&event, cli) {
76+
self.left.handle_event(event, &cli.left).await;
7777
} else {
78-
self.right.handle_event(ev, &cli.right).await;
78+
self.right.handle_event(event, &cli.right).await;
7979
}
8080
}
8181
}

src/writer/summarize.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ where
202202

203203
async fn handle_event(
204204
&mut self,
205-
ev: parser::Result<Event<event::Cucumber<W>>>,
205+
event: parser::Result<Event<event::Cucumber<W>>>,
206206
cli: &Self::Cli,
207207
) {
208208
use event::{Cucumber, Feature, Rule};
@@ -212,7 +212,7 @@ where
212212
// This is done to avoid miscalculations if this `Writer` happens to be
213213
// wrapped by a `writer::Repeat` or similar.
214214
if matches!(self.state, State::InProgress) {
215-
match ev.as_deref() {
215+
match event.as_deref() {
216216
Err(_) => self.parsing_errors += 1,
217217
Ok(Cucumber::Feature(feat, ev)) => match ev {
218218
Feature::Started => self.features += 1,
@@ -244,7 +244,7 @@ where
244244
};
245245
}
246246

247-
self.writer.handle_event(ev, cli).await;
247+
self.writer.handle_event(event, cli).await;
248248

249249
if matches!(self.state, State::FinishedButNotOutput) {
250250
self.state = State::FinishedAndOutput;

src/writer/tee.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ where
6060

6161
async fn handle_event(
6262
&mut self,
63-
ev: parser::Result<Event<event::Cucumber<W>>>,
63+
event: parser::Result<Event<event::Cucumber<W>>>,
6464
cli: &Self::Cli,
6565
) {
6666
future::join(
67-
self.left.handle_event(ev.clone(), &cli.left),
68-
self.right.handle_event(ev, &cli.right),
67+
self.left.handle_event(event.clone(), &cli.left),
68+
self.right.handle_event(event, &cli.right),
6969
)
7070
.await;
7171
}

0 commit comments

Comments
 (0)