@@ -123,7 +123,7 @@ impl Radix {
123
123
}
124
124
125
125
#[ derive( Debug ) ]
126
- pub ( super ) struct DigitInfo < ' a > {
126
+ pub ( super ) struct NumericLiteral < ' a > {
127
127
/// Which radix the literal was represented in.
128
128
crate radix : Radix ,
129
129
/// The radix prefix, if present.
@@ -140,12 +140,12 @@ pub(super) struct DigitInfo<'a> {
140
140
crate suffix : Option < & ' a str > ,
141
141
}
142
142
143
- impl < ' a > DigitInfo < ' a > {
144
- fn from_lit ( src : & ' a str , lit : & Lit ) -> Option < DigitInfo < ' a > > {
143
+ impl < ' a > NumericLiteral < ' a > {
144
+ fn from_lit ( src : & ' a str , lit : & Lit ) -> Option < NumericLiteral < ' a > > {
145
145
if lit. kind . is_numeric ( ) && src. chars ( ) . next ( ) . map_or ( false , |c| c. is_digit ( 10 ) ) {
146
146
let ( unsuffixed, suffix) = split_suffix ( & src, & lit. kind ) ;
147
147
let float = if let LitKind :: Float ( ..) = lit. kind { true } else { false } ;
148
- Some ( DigitInfo :: new ( unsuffixed, suffix, float) )
148
+ Some ( NumericLiteral :: new ( unsuffixed, suffix, float) )
149
149
} else {
150
150
None
151
151
}
@@ -400,21 +400,21 @@ impl LiteralDigitGrouping {
400
400
401
401
if_chain ! {
402
402
if let Some ( src) = snippet_opt( cx, lit. span) ;
403
- if let Some ( mut digit_info ) = DigitInfo :: from_lit( & src, & lit) ;
403
+ if let Some ( mut num_lit ) = NumericLiteral :: from_lit( & src, & lit) ;
404
404
then {
405
- if !Self :: check_for_mistyped_suffix( cx, lit. span, & mut digit_info ) {
405
+ if !Self :: check_for_mistyped_suffix( cx, lit. span, & mut num_lit ) {
406
406
return ;
407
407
}
408
408
409
409
let result = ( || {
410
410
411
- let integral_group_size = Self :: get_group_size( digit_info . integer. split( '_' ) , in_macro) ?;
412
- if let Some ( fraction) = digit_info . fraction {
411
+ let integral_group_size = Self :: get_group_size( num_lit . integer. split( '_' ) , in_macro) ?;
412
+ if let Some ( fraction) = num_lit . fraction {
413
413
let fractional_group_size = Self :: get_group_size( fraction. rsplit( '_' ) , in_macro) ?;
414
414
415
415
let consistent = Self :: parts_consistent( integral_group_size,
416
416
fractional_group_size,
417
- digit_info . integer. len( ) ,
417
+ num_lit . integer. len( ) ,
418
418
fraction. len( ) ) ;
419
419
if !consistent {
420
420
return Err ( WarningType :: InconsistentDigitGrouping ) ;
@@ -425,7 +425,7 @@ impl LiteralDigitGrouping {
425
425
426
426
427
427
if let Err ( warning_type) = result {
428
- warning_type. display( & digit_info . grouping_hint( ) , cx, lit. span)
428
+ warning_type. display( & num_lit . grouping_hint( ) , cx, lit. span)
429
429
}
430
430
}
431
431
}
@@ -435,25 +435,25 @@ impl LiteralDigitGrouping {
435
435
fn check_for_mistyped_suffix (
436
436
cx : & EarlyContext < ' _ > ,
437
437
span : syntax_pos:: Span ,
438
- digit_info : & mut DigitInfo < ' _ > ,
438
+ num_lit : & mut NumericLiteral < ' _ > ,
439
439
) -> bool {
440
- if digit_info . suffix . is_some ( ) {
440
+ if num_lit . suffix . is_some ( ) {
441
441
return true ;
442
442
}
443
443
444
- let ( part, mistyped_suffixes, missing_char) = if let Some ( ( _, exponent) ) = & mut digit_info . exponent {
444
+ let ( part, mistyped_suffixes, missing_char) = if let Some ( ( _, exponent) ) = & mut num_lit . exponent {
445
445
( exponent, & [ "32" , "64" ] [ ..] , 'f' )
446
- } else if let Some ( fraction) = & mut digit_info . fraction {
446
+ } else if let Some ( fraction) = & mut num_lit . fraction {
447
447
( fraction, & [ "32" , "64" ] [ ..] , 'f' )
448
448
} else {
449
- ( & mut digit_info . integer , & [ "8" , "16" , "32" , "64" ] [ ..] , 'i' )
449
+ ( & mut num_lit . integer , & [ "8" , "16" , "32" , "64" ] [ ..] , 'i' )
450
450
} ;
451
451
452
452
let mut split = part. rsplit ( '_' ) ;
453
453
let last_group = split. next ( ) . expect ( "At least one group" ) ;
454
454
if split. next ( ) . is_some ( ) && mistyped_suffixes. contains ( & last_group) {
455
455
* part = & part[ ..part. len ( ) - last_group. len ( ) ] ;
456
- let mut hint = digit_info . grouping_hint ( ) ;
456
+ let mut hint = num_lit . grouping_hint ( ) ;
457
457
hint. push ( '_' ) ;
458
458
hint. push ( missing_char) ;
459
459
hint. push_str ( last_group) ;
@@ -539,14 +539,14 @@ impl DecimalLiteralRepresentation {
539
539
if_chain ! {
540
540
if let LitKind :: Int ( val, _) = lit. kind;
541
541
if let Some ( src) = snippet_opt( cx, lit. span) ;
542
- if let Some ( digit_info ) = DigitInfo :: from_lit( & src, & lit) ;
543
- if digit_info . radix == Radix :: Decimal ;
542
+ if let Some ( num_lit ) = NumericLiteral :: from_lit( & src, & lit) ;
543
+ if num_lit . radix == Radix :: Decimal ;
544
544
if val >= u128 :: from( self . threshold) ;
545
545
then {
546
546
let hex = format!( "{:#X}" , val) ;
547
- let digit_info = DigitInfo :: new( & hex, None , false ) ;
548
- let _ = Self :: do_lint( digit_info . integer) . map_err( |warning_type| {
549
- warning_type. display( & digit_info . grouping_hint( ) , cx, lit. span)
547
+ let num_lit = NumericLiteral :: new( & hex, None , false ) ;
548
+ let _ = Self :: do_lint( num_lit . integer) . map_err( |warning_type| {
549
+ warning_type. display( & num_lit . grouping_hint( ) , cx, lit. span)
550
550
} ) ;
551
551
}
552
552
}
0 commit comments