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

fix clippy assign_op_pattern warnings #354

Closed
wants to merge 1 commit into from
Closed

fix clippy assign_op_pattern warnings #354

wants to merge 1 commit into from

Conversation

warthog618
Copy link

I'm currently seeing clippy warnings like:

warning: manual implementation of an assign operation
   --> uapi/src/v1.rs:457:1
    |
457 | / bitflags! {
458 | |     /// Additional configuration flags for event requests.
459 | |     #[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
460 | |     pub struct EventRequestFlags: u32 {
...   |
469 | |     }
470 | | }
    | |_^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assign_op_pattern
    = note: this warning originates in the macro `__impl_public_bitflags` which comes from the expansion of the macro `bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)

This patch addresses those by replacing occurrences of a = a op b to a op= b, as suggested by the info link.
Not sure of that is all of them - but it is at least all that my code was triggering.

@KodrAus
Copy link
Member

KodrAus commented May 17, 2023

Thanks for the PR @warthog618! We actually use the non-assigning variants intentionally here so that the trait bounds required by the underlying bits types is limited to BitOp rather than BitOp plus BitOpAssign.

I think the fix here would be to allow that lint.

It's probably also really about time I add clippy to CI here so these lints stop triggering in end-users code 🙂

@warthog618
Copy link
Author

Fair enough. I'd be happy with any solution that will keep clippy quiet, so whatever works for you.

@warthog618 warthog618 closed this May 17, 2023
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