Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor housekeeping work #310

Merged
merged 7 commits into from
Nov 21, 2023
Merged

Minor housekeeping work #310

merged 7 commits into from
Nov 21, 2023

Conversation

barafael
Copy link
Contributor

I study how people use clippy. I found it interesting that this crate actually sets clippy to pedantic by default. There were minor findings, let me know what you think.

Copy link
Member

@tyranron tyranron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barafael thanks for taking a look and giving a care. However, most of these changes seem not to be better. I've commented each one of them.

Anything other is OK, and I'm going to merge.

Also, I've added linting without features to CI.

Cargo.toml Outdated
"rt-multi-thread",
"sync",
"time",
] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barafael I've found it more comfortable to keep each dependency as a single line in [dependencies] section.

@@ -53,7 +53,7 @@ struct Step {
/// reference.
///
/// [`gherkin::Step`]: https://bit.ly/3j42hcd
step_arg_name: Option<syn::Ident>,
arg_name: Option<syn::Ident>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barafael step_ prefix was referring to a gherkin::Step here, rather than this struct itself.

@@ -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)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barafael not a fan of this particular change. It's more meaningful to emphasize we're queuing something here, rather than bothering reader with exact semantics of the queue, which is "implementation detail".

src/event.rs Outdated
@@ -54,7 +54,7 @@ pub struct Event<T: ?Sized> {
impl<T> Event<T> {
/// Creates a new [`Event`] out of the given `value`.
#[must_use]
pub fn new(value: T) -> Self {
pub const fn new(value: T) -> Self {
Self {
#[cfg(feature = "timestamps")]
at: SystemTime::now(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barafael this won't compile with --feature timestamps:

error[E0015]: cannot call non-const fn `std::time::SystemTime::now` in constant functions
  --> src/event.rs:60:17
   |
60 |             at: SystemTime::now(),
   |                 ^^^^^^^^^^^^^^^^^
   |
   = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants

@@ -1485,7 +1485,7 @@ where
(fut, span_id)
};
#[cfg(not(feature = "tracing"))]
let _ = scenario_id;
let _: ScenarioId = scenario_id;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barafael I would prefer _ = scenario_id;, but yes:

error[E0658]: attributes on expressions are experimental
    --> src/runner/basic.rs:1076:13
     |
1076 |             #[cfg(not(feature = "tracing"))]
     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information

@tyranron tyranron added enhancement Improvement of existing features or bugfix k::toolchain Related to project toolchain k::refactor Refactoring, technical debt elimination and other improvements of existing code base labels Nov 21, 2023
@tyranron tyranron added this to the 0.21.0 milestone Nov 21, 2023
@tyranron tyranron merged commit d9fe09f into cucumber-rs:main Nov 21, 2023
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing features or bugfix k::refactor Refactoring, technical debt elimination and other improvements of existing code base k::toolchain Related to project toolchain
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants