-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
unusual_byte_groupings fires for octal values represented in binary #6556
Comments
Hmm I guess we'll just add a special case for 3 groups of 3? Usually the groups don't have semantic meaning like they do in a unix mode. |
I think this doesn't depend on any semantic meaning. Grouping by four bits is a specification of one hexadecimal digit in the binary numeral system. Likewise, grouping by three bits is a specification of one octal digit in binary. The octal numeral system is used often enough to make this warning unexpected in computer science. |
In virtual machine development, we often need to encode/decode an instruction, and the instruction encoding usually has its own format, such as RISC-V ISA:
I think the addition of this check is an impulsive decision, and it should never exist, whether it is a 4-bit grouping or a 3-bit grouping, when people choose to use binary to represent a number, they understand what they are doing better than Clippy. |
Good point. Seems very sensible to not lint groups of three.
Certainly there can be any grouping for any proprietary format. But these are "unusual". However, maybe they really are not that unusual and so this lint should not warn by default? |
I think formats that deal with bit fields are uncommon enough to keep this lint enabled by default. |
@rustbot claim |
Change unusual_byte_groupings to require byte groupings of equal size Fixes issue #6556 This lint required byte groupings of size 2 or 4 for `Radix::Binary` and `Radix::Hexadecimal`. Since there are good reasons for allowing groups of other sizes, this PR relaxes the restriction. This lint now requires that - group sizes after the first group be of the same size and - greater or equal in size to the first group. --- changelog: [`unusual_byte_groupings`]: reduce false positives by relaxing restriction requiring groups of specific sizes.
Fixed by #10353. |
Lint name: unusual_byte_groupings
I tried this code:
I didn't expect to see the warning
digits of hex or binary literal not grouped by four
, because grouping by 3 bits is very reasonable when binary is clearer than octal.Meta
cargo clippy -V
:rustc -Vv
:The text was updated successfully, but these errors were encountered: