summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/clippy_lints/src/literal_representation.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/clippy_lints/src/literal_representation.rs')
-rw-r--r--src/tools/clippy/clippy_lints/src/literal_representation.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/tools/clippy/clippy_lints/src/literal_representation.rs b/src/tools/clippy/clippy_lints/src/literal_representation.rs
index 3a7b7835c..dadcd9c51 100644
--- a/src/tools/clippy/clippy_lints/src/literal_representation.rs
+++ b/src/tools/clippy/clippy_lints/src/literal_representation.rs
@@ -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 in groups of equal size",
"consider",
suggested_format,
Applicability::MachineApplicable,
@@ -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 {
+ if let Some(second_size) = groups.next() {
+ if !groups.all(|i| i == second_size) || first > second_size {
+ return Err(WarningType::UnusualByteGroupings);
+ }
+ }
}
if let Some(second) = groups.next() {
@@ -484,7 +488,7 @@ impl DecimalLiteralRepresentation {
then {
let hex = format!("{val:#X}");
let num_lit = NumericLiteral::new(&hex, num_lit.suffix, false);
- let _ = Self::do_lint(num_lit.integer).map_err(|warning_type| {
+ let _: Result<(), ()> = Self::do_lint(num_lit.integer).map_err(|warning_type| {
warning_type.display(num_lit.format(), cx, span);
});
}