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

Clippy fixes #295

Closed
wants to merge 6 commits into from
Closed

Clippy fixes #295

wants to merge 6 commits into from

Conversation

gybrish
Copy link
Contributor

@gybrish gybrish commented Nov 18, 2022

Fixing up clippy warnings/errors before we look to address #287

@gybrish
Copy link
Contributor Author

gybrish commented Nov 18, 2022

Not sure why the commits for the rust fmt workflow are included in this, let me know if I can fix it up somehow.

@gregtatum
Copy link
Member

It looks like you merged rather than fast forwarded: https://code-maven.com/enforce-fast-forward-as-merge-strategy

I suspect you ran into issues because I recently changed the master branch to main, so you will probably need to change it locally a well. You can then pull the latest changes and rebase your work.

You could also fetch the latest changes, and then reset --hard to main when you are in your clippy_fixes branch and then git cherry-pick cf5aa9e since your work is a single commit.

@gregtatum gregtatum self-requested a review November 18, 2022 17:19
Copy link
Member

@gregtatum gregtatum left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Overall this looks good. I'm marking as request changes for:

  • Clean commit history without extraneous commits.
  • I have a couple of blocking questions I'd like answered before I re-review.

After addressing those this looks mergeable to me!

@@ -88,7 +88,7 @@ pub fn get_defaults(path: &str) -> Result<TestDefaults, io::Error> {
Ok(serde_yaml::from_str(&s).expect("Parsing YAML failed."))
}

#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
Copy link
Member

Choose a reason for hiding this comment

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

Question: Which clippy rule is this? It seems fine since these are in tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq

For tests yeah, I'd say this rule is not applicable, we can suppress the warning

@@ -2,7 +2,7 @@ use fluent_bundle::FluentError;
use std::error::Error;
use unic_langid::LanguageIdentifier;

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
Copy link
Member

Choose a reason for hiding this comment

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

Question (blocking): Similar to above, I'd like to know what this clippy rule is before merging, since it's changing a public facing API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq

This is more of a judgement call tbh, is there a reason to limit it to PartialEq and not Eq?

@@ -53,7 +53,7 @@ pub enum ResourceType {
}

/// A resource identifier for a localization resource.
#[derive(Debug, Clone, Hash)]
Copy link
Member

Choose a reason for hiding this comment

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

Question (blocking): Which clippy rule is this? I don't understand this change (probably since I don't know the clippy rule)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://rust-lang.github.io/rust-clippy/master/index.html#derive_hash_xor_eq

There's an impl PartialEq which only uses self.value for equality testing, while the derived Hash would use both value & resource_type, which breaks the invariant k1 == k2 => hash(k1) == hash(k2) (from the clippy rule)

@@ -5,15 +5,15 @@ use super::Comment;
// This is a helper struct used to properly deserialize referential
// JSON comments which are single continous String, into a vec of
// content slices.
#[derive(Debug, PartialEq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone)]
Copy link
Member

Choose a reason for hiding this comment

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

TODO (me): Review this and any other Eq traits after the above questions are answered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gybrish gybrish closed this by deleting the head repository Nov 18, 2022
@gybrish
Copy link
Contributor Author

gybrish commented Nov 19, 2022

Looks like it's difficult to sync the fork after the branch name change - will resubmit a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants