Skip to content

Commit

Permalink
Fix lint and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cgm616 committed Oct 16, 2020
1 parent 07c45b6 commit aee3baf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions clippy_lints/src/literal_representation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ impl LiteralDigitGrouping {
let should_warn = match warning_type {
| WarningType::UnreadableLiteral
| WarningType::InconsistentDigitGrouping
| WarningType::UnusualByteGrouping(_)
| WarningType::LargeDigitGroups => {
!in_macro(lit.span)
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/utils/numeric_literal.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_ast::ast::{Lit, LitFloatType, LitIntType, LitKind};

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum Radix {
Binary,
Octal,
Expand Down
5 changes: 5 additions & 0 deletions tests/ui/literals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ fn main() {
let fail19 = 12_3456_21;
let fail22 = 3__4___23;
let fail23 = 3__16___23;

let fail24 = 0xAB_ABC_AB;
let fail25 = 0b01_100_101;
let ok26 = 0x6_A0_BF;
let ok27 = 0b1_0010_0101;
}
16 changes: 15 additions & 1 deletion tests/ui/literals.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,19 @@ error: digits grouped inconsistently by underscores
LL | let fail23 = 3__16___23;
| ^^^^^^^^^^ help: consider: `31_623`

error: aborting due to 8 previous errors
error: digits not grouped by byte
--> $DIR/literals.rs:37:18
|
LL | let fail24 = 0xAB_ABC_AB;
| ^^^^^^^^^^^ help: consider: `0x0A_BA_BC_AB`
|
= note: `-D clippy::unusual-byte-grouping` implied by `-D warnings`

error: digits not grouped by nibble
--> $DIR/literals.rs:38:18
|
LL | let fail25 = 0b01_100_101;
| ^^^^^^^^^^^^ help: consider: `0b0110_0101`

error: aborting due to 10 previous errors

0 comments on commit aee3baf

Please sign in to comment.