Add allowable warnings for multiple flags with equal values #490

Open
opened 2026-06-16 16:02:30 -05:00 by inner-daemons · 0 comments
inner-daemons commented 2026-06-16 16:02:30 -05:00 (Migrated from github.com)

I'm not sure if it would fit the project, but it would be useful to give a warning when two flags have exactly the same bits.

In wgpu we use bitflags for features and capabilities, and these are constantly being added in multiple open pull requests. We go through the bits in order, so each of these open pull requests usually tries to use the same next bit. Then when one of them gets merged everybody else has to figure out why their feature subtly stopped working, which can be confusing.

I propose some new compile-time warning for when multiple flags have the exact same value. Of course this could be disabled for certain values with an attribute like #[allow_duplicate], or globally on the whole bitflag type. Perhaps it is even opt in to the bitflag type, with an attribute like #[disallow_duplicate].

I might be willing to work on this myself if it is blessed by the maintainers.

Not sure exactly how this would fit into semver or if thats out of scope for the project. Just a random idea I had.

I'm not sure if it would fit the project, but it would be useful to give a warning when two flags have exactly the same bits. In wgpu we use bitflags for features and capabilities, and these are constantly being added in multiple open pull requests. We go through the bits in order, so each of these open pull requests usually tries to use the same next bit. Then when one of them gets merged everybody else has to figure out why their feature subtly stopped working, which can be confusing. I propose some new compile-time warning for when multiple flags have the exact same value. Of course this could be disabled for certain values with an attribute like `#[allow_duplicate]`, or globally on the whole bitflag type. Perhaps it is even opt in to the bitflag type, with an attribute like `#[disallow_duplicate]`. I might be willing to work on this myself if it is blessed by the maintainers. Not sure exactly how this would fit into semver or if thats out of scope for the project. Just a random idea I had.
Sign in to join this conversation.
No labels
bug
good first issue
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-bitflags/bitflags#490
No description provided.