File tree 3 files changed +9
-4
lines changed
3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -506,7 +506,11 @@ impl MiscEarlyLints {
506
506
) ;
507
507
}
508
508
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
+ }
510
514
let mut seen = ( false , false ) ;
511
515
for ch in lit_snip. as_bytes ( ) [ 2 ..=maybe_last_sep_idx] . iter ( ) {
512
516
match ch {
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ fn main() {
28
28
let ok15 = 0xab_cabc_abca_bcab_cabc ;
29
29
let ok16 = 0xFE_BAFE_ABAB_ABCD ;
30
30
let ok17 = 0x123_4567_8901_usize ;
31
+ let ok18 = 0xF ;
31
32
32
33
let fail19 = 12_3456_21 ;
33
34
let fail22 = 3__4___23 ;
Original file line number Diff line number Diff line change @@ -50,21 +50,21 @@ LL | let fail8 = 0o123;
50
50
| ^^^^^
51
51
52
52
error: digits grouped inconsistently by underscores
53
- --> $DIR/literals.rs:32 :18
53
+ --> $DIR/literals.rs:33 :18
54
54
|
55
55
LL | let fail19 = 12_3456_21;
56
56
| ^^^^^^^^^^ help: consider: `12_345_621`
57
57
|
58
58
= note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings`
59
59
60
60
error: digits grouped inconsistently by underscores
61
- --> $DIR/literals.rs:33 :18
61
+ --> $DIR/literals.rs:34 :18
62
62
|
63
63
LL | let fail22 = 3__4___23;
64
64
| ^^^^^^^^^ help: consider: `3_423`
65
65
66
66
error: digits grouped inconsistently by underscores
67
- --> $DIR/literals.rs:34 :18
67
+ --> $DIR/literals.rs:35 :18
68
68
|
69
69
LL | let fail23 = 3__16___23;
70
70
| ^^^^^^^^^^ help: consider: `31_623`
You can’t perform that action at this time.
0 commit comments