Skip to content

Commit

Permalink
Tune lints for 1.75 Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
tyranron committed Jan 2, 2024
1 parent 00f12d4 commit 2a0df7b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
18 changes: 11 additions & 7 deletions codegen/src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct Step {
/// reference.
///
/// [`gherkin::Step`]: https://bit.ly/3j42hcd
step_arg_name: Option<syn::Ident>,
arg_name_of_step_context: Option<syn::Ident>,
}

impl Step {
Expand Down Expand Up @@ -97,7 +97,7 @@ impl Step {
attr_name,
attr_arg,
func,
step_arg_name,
arg_name_of_step_context: step_arg_name,
})
}

Expand Down Expand Up @@ -274,7 +274,7 @@ impl Step {

Ok((func_args, addon_parsing))
}
} else if self.step_arg_name.is_some() {
} else if self.arg_name_of_step_context.is_some() {
Ok((
quote! { ::std::borrow::Borrow::borrow(&__cucumber_ctx.step), },
None,
Expand Down Expand Up @@ -304,7 +304,8 @@ impl Step {
let (ident, ty) = parse_fn_arg(arg)?;

let is_ctx_arg =
self.step_arg_name.as_ref().map(|i| *i == *ident) == Some(true);
self.arg_name_of_step_context.as_ref().map(|i| *i == *ident)
== Some(true);

let decl = if is_ctx_arg {
quote! {
Expand Down Expand Up @@ -385,7 +386,7 @@ impl Step {
&self,
arg: &syn::FnArg,
) -> syn::Result<TokenStream> {
if let Some(name) = &self.step_arg_name {
if let Some(name) = &self.arg_name_of_step_context {
let (ident, _) = parse_fn_arg(arg)?;
if name == ident {
return Ok(quote! {
Expand Down Expand Up @@ -443,8 +444,11 @@ impl Step {
expr: &syn::LitStr,
) -> syn::Result<TokenStream> {
let expr = expr.value();
let params =
Parameters::new(&expr, &self.func, self.step_arg_name.as_ref())?;
let params = Parameters::new(
&expr,
&self.func,
self.arg_name_of_step_context.as_ref(),
)?;

let provider_impl =
params.gen_provider_impl(&parse_quote! { Provider });
Expand Down
1 change: 1 addition & 0 deletions codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
clippy::pub_without_shorthand,
clippy::rc_buffer,
clippy::rc_mutex,
clippy::read_zero_byte_vec,
clippy::readonly_write_lock,
clippy::redundant_clone,
clippy::redundant_type_annotations,
Expand Down
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
clippy::pub_without_shorthand,
clippy::rc_buffer,
clippy::rc_mutex,
clippy::read_zero_byte_vec,
clippy::readonly_write_lock,
clippy::redundant_clone,
clippy::redundant_type_annotations,
Expand Down Expand Up @@ -148,9 +149,6 @@
)]
// TODO: Remove on next `derive_more` major version.
#![allow(clippy::uninlined_format_args)]
// TODO: Massive false positives on `.await` points. Try remove on next Rust
// version.
#![allow(clippy::multiple_unsafe_ops_per_block)]

pub mod cli;
mod cucumber;
Expand Down
32 changes: 16 additions & 16 deletions src/writer/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ impl<Writer> Normalized for AssertNormalized<Writer> {}
#[derive(Clone, Debug)]
struct Queue<K: Eq + Hash, V> {
/// Underlying FIFO queue of values.
queue: LinkedHashMap<K, V>,
fifo: LinkedHashMap<K, V>,

/// Initial [`Metadata`] of this [`Queue`] creation.
///
Expand All @@ -363,7 +363,7 @@ impl<K: Eq + Hash, V> Queue<K, V> {
/// Creates a new normalization [`Queue`] with an initial metadata.
fn new(initial: Metadata) -> Self {
Self {
queue: LinkedHashMap::new(),
fifo: LinkedHashMap::new(),
initial: Some(initial),
state: FinishedState::NotFinished,
}
Expand All @@ -385,7 +385,7 @@ impl<K: Eq + Hash, V> Queue<K, V> {

/// Removes the given `key` from this [`Queue`].
fn remove(&mut self, key: &K) {
drop(self.queue.remove(key));
drop(self.fifo.remove(key));
}
}

Expand Down Expand Up @@ -489,7 +489,7 @@ impl<World> CucumberQueue<World> {
/// [`Feature`]: gherkin::Feature
fn new_feature(&mut self, feat: Event<Arc<gherkin::Feature>>) {
let (feat, meta) = feat.split();
drop(self.queue.insert(feat, FeatureQueue::new(meta)));
drop(self.fifo.insert(feat, FeatureQueue::new(meta)));
}

/// Marks a [`Feature`] as finished on [`event::Feature::Finished`].
Expand All @@ -500,7 +500,7 @@ impl<World> CucumberQueue<World> {
/// [`Feature`]: gherkin::Feature
fn feature_finished(&mut self, feat: Event<&gherkin::Feature>) {
let (feat, meta) = feat.split();
self.queue
self.fifo
.get_mut(feat)
.unwrap_or_else(|| panic!("No Feature {}", feat.name))
.finished(meta);
Expand All @@ -514,7 +514,7 @@ impl<World> CucumberQueue<World> {
feat: &gherkin::Feature,
rule: Event<Arc<gherkin::Rule>>,
) {
self.queue
self.fifo
.get_mut(feat)
.unwrap_or_else(|| panic!("No Feature {}", feat.name))
.new_rule(rule);
Expand All @@ -531,7 +531,7 @@ impl<World> CucumberQueue<World> {
feat: &gherkin::Feature,
rule: Event<Arc<gherkin::Rule>>,
) {
self.queue
self.fifo
.get_mut(feat)
.unwrap_or_else(|| panic!("No Feature {}", feat.name))
.rule_finished(rule);
Expand All @@ -545,7 +545,7 @@ impl<World> CucumberQueue<World> {
scenario: Arc<gherkin::Scenario>,
event: Event<event::RetryableScenario<World>>,
) {
self.queue
self.fifo
.get_mut(feat)
.unwrap_or_else(|| panic!("No Feature {}", feat.name))
.insert_scenario_event(rule, scenario, event.retries, event);
Expand All @@ -559,7 +559,7 @@ impl<'me, World> Emitter<World> for &'me mut CucumberQueue<World> {
type EmittedPath = ();

fn current_item(self) -> Option<Self::Current> {
self.queue
self.fifo
.iter_mut()
.next()
.map(|(f, ev)| (Arc::clone(f), ev))
Expand Down Expand Up @@ -641,7 +641,7 @@ impl<World> FeatureQueue<World> {
fn new_rule(&mut self, rule: Event<Arc<gherkin::Rule>>) {
let (rule, meta) = rule.split();
drop(
self.queue.insert(
self.fifo.insert(
Either::Left(rule),
Either::Left(RulesQueue::new(meta)),
),
Expand All @@ -653,7 +653,7 @@ impl<World> FeatureQueue<World> {
/// [`Rule`]: gherkin::Rule
fn rule_finished(&mut self, rule: Event<Arc<gherkin::Rule>>) {
let (rule, meta) = rule.split();
match self.queue.get_mut(&Either::Left(rule)) {
match self.fifo.get_mut(&Either::Left(rule)) {
Some(Either::Left(ev)) => {
ev.finished(meta);
}
Expand All @@ -673,12 +673,12 @@ impl<World> FeatureQueue<World> {
) {
if let Some(r) = rule {
match self
.queue
.fifo
.get_mut(&Either::Left(Arc::clone(&r)))
.unwrap_or_else(|| panic!("No Rule {}", r.name))
{
Either::Left(rules) => rules
.queue
.fifo
.entry((scenario, retries))
.or_insert_with(ScenariosQueue::new)
.0
Expand All @@ -687,7 +687,7 @@ impl<World> FeatureQueue<World> {
}
} else {
match self
.queue
.fifo
.entry(Either::Right((scenario, retries)))
.or_insert_with(|| Either::Right(ScenariosQueue::new()))
{
Expand All @@ -705,7 +705,7 @@ impl<'me, World> Emitter<World> for &'me mut FeatureQueue<World> {
type EmittedPath = Arc<gherkin::Feature>;

fn current_item(self) -> Option<Self::Current> {
Some(match self.queue.iter_mut().next()? {
Some(match self.fifo.iter_mut().next()? {
(Either::Left(rule), Either::Left(events)) => {
Either::Left((Arc::clone(rule), events))
}
Expand Down Expand Up @@ -748,7 +748,7 @@ impl<'me, World> Emitter<World> for &'me mut RulesQueue<World> {
type EmittedPath = (Arc<gherkin::Feature>, Arc<gherkin::Rule>);

fn current_item(self) -> Option<Self::Current> {
self.queue
self.fifo
.iter_mut()
.next()
.map(|((sc, _), ev)| (Arc::clone(sc), ev))
Expand Down

0 comments on commit 2a0df7b

Please sign in to comment.