-
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
Change unusual_byte_groupings to require byte groupings of equal size #10353
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Alexendoo (or someone else) soon. Please see the contribution instructions for more information. |
@@ -210,7 +210,7 @@ impl WarningType { | |||
cx, | |||
UNUSUAL_BYTE_GROUPINGS, | |||
span, | |||
"digits of hex or binary literal not grouped by four", | |||
"digits of hex, binary or octal literal not groups of equal size", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"digits of hex, binary or octal literal not groups of equal size", | |
"digits of hex, binary or octal literal not in groups of equal size", |
@@ -427,8 +427,12 @@ impl LiteralDigitGrouping { | |||
|
|||
let first = groups.next().expect("At least one group"); | |||
|
|||
if (radix == Radix::Binary || radix == Radix::Hexadecimal) && groups.any(|i| i != 4 && i != 2) { | |||
return Err(WarningType::UnusualByteGroupings); | |||
if radix == Radix::Binary || radix == Radix::Octal || radix == Radix::Hexadecimal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if radix == Radix::Binary || radix == Radix::Octal || radix == Radix::Hexadecimal { | |
if radix != Radix::Decimal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this keeps the intention clearer.
r? @llogiq |
Thank you! @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Fixes issue #6556
This lint required byte groupings of size 2 or 4 for
Radix::Binary
andRadix::Hexadecimal
. Since there are good reasons for allowing groups of other sizes, this PR relaxes the restriction. This lint now requires thatchangelog: [
unusual_byte_groupings
]: reduce false positives by relaxing restriction requiring groups of specific sizes.