File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -506,7 +506,11 @@ impl MiscEarlyLints {
506506 ) ;
507507 }
508508
509- if lit_snip. starts_with ( "0x" ) && maybe_last_sep_idx >= 3 {
509+ if lit_snip. starts_with ( "0x" ) {
510+ if maybe_last_sep_idx <= 2 {
511+ // It's meaningless or causes range error.
512+ return ;
513+ }
510514 let mut seen = ( false , false ) ;
511515 for ch in lit_snip. as_bytes ( ) [ 2 ..=maybe_last_sep_idx] . iter ( ) {
512516 match ch {
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ fn main() {
2828 let ok15 = 0xab_cabc_abca_bcab_cabc ;
2929 let ok16 = 0xFE_BAFE_ABAB_ABCD ;
3030 let ok17 = 0x123_4567_8901_usize ;
31+ let ok18 = 0xF ;
3132
3233 let fail19 = 12_3456_21 ;
3334 let fail22 = 3__4___23 ;
Original file line number Diff line number Diff line change @@ -50,21 +50,21 @@ LL | let fail8 = 0o123;
5050 | ^^^^^
5151
5252error: digits grouped inconsistently by underscores
53- --> $DIR/literals.rs:32 :18
53+ --> $DIR/literals.rs:33 :18
5454 |
5555LL | let fail19 = 12_3456_21;
5656 | ^^^^^^^^^^ help: consider: `12_345_621`
5757 |
5858 = note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings`
5959
6060error: digits grouped inconsistently by underscores
61- --> $DIR/literals.rs:33 :18
61+ --> $DIR/literals.rs:34 :18
6262 |
6363LL | let fail22 = 3__4___23;
6464 | ^^^^^^^^^ help: consider: `3_423`
6565
6666error: digits grouped inconsistently by underscores
67- --> $DIR/literals.rs:34 :18
67+ --> $DIR/literals.rs:35 :18
6868 |
6969LL | let fail23 = 3__16___23;
7070 | ^^^^^^^^^^ help: consider: `31_623`
You can’t perform that action at this time.
0 commit comments