@@ -372,9 +372,15 @@ impl LiteralDigitGrouping {
372
372
} ;
373
373
374
374
let result = ( || {
375
+ if let Some ( suffix) = digit_info. suffix {
376
+ if is_mistyped_suffix( suffix) {
377
+ return Err ( WarningType :: MistypedLiteralSuffix ) ;
378
+ }
379
+ }
380
+
375
381
match lit. kind {
376
382
LitKind :: Int ( ..) => {
377
- Self :: do_lint( digit_info. digits, digit_info . suffix , in_macro) ?;
383
+ Self :: do_lint( digit_info. digits, in_macro) ?;
378
384
} ,
379
385
LitKind :: Float ( ..) => {
380
386
// Separate digits into integral and fractional parts.
@@ -385,11 +391,11 @@ impl LiteralDigitGrouping {
385
391
386
392
// Lint integral and fractional parts separately, and then check consistency of digit
387
393
// groups if both pass.
388
- let integral_group_size = Self :: do_lint( parts[ 0 ] , digit_info . suffix , in_macro) ?;
394
+ let integral_group_size = Self :: do_lint( parts[ 0 ] , in_macro) ?;
389
395
if parts. len( ) > 1 {
390
396
// Lint the fractional part of literal just like integral part, but reversed.
391
397
let fractional_part = & parts[ 1 ] . chars( ) . rev( ) . collect:: <String >( ) ;
392
- let fractional_group_size = Self :: do_lint( fractional_part, None , in_macro) ?;
398
+ let fractional_group_size = Self :: do_lint( fractional_part, in_macro) ?;
393
399
let consistent = Self :: parts_consistent( integral_group_size,
394
400
fractional_group_size,
395
401
parts[ 0 ] . len( ) ,
@@ -432,12 +438,7 @@ impl LiteralDigitGrouping {
432
438
433
439
/// Performs lint on `digits` (no decimal point) and returns the group
434
440
/// size on success or `WarningType` when emitting a warning.
435
- fn do_lint ( digits : & str , suffix : Option < & str > , in_macro : bool ) -> Result < usize , WarningType > {
436
- if let Some ( suffix) = suffix {
437
- if is_mistyped_suffix ( suffix) {
438
- return Err ( WarningType :: MistypedLiteralSuffix ) ;
439
- }
440
- }
441
+ fn do_lint ( digits : & str , in_macro : bool ) -> Result < usize , WarningType > {
441
442
// Grab underscore indices with respect to the units digit.
442
443
let underscore_positions: Vec < usize > = digits
443
444
. chars ( )
0 commit comments