@@ -219,7 +219,7 @@ impl<'a> NumericLiteral<'a> {
219
219
}
220
220
221
221
/// Returns literal formatted in a sensible way.
222
- crate fn grouping_hint ( & self ) -> String {
222
+ crate fn format ( & self ) -> String {
223
223
let mut output = String :: new ( ) ;
224
224
225
225
if let Some ( prefix) = self . prefix {
@@ -324,15 +324,15 @@ enum WarningType {
324
324
}
325
325
326
326
impl WarningType {
327
- crate fn display ( & self , grouping_hint : & str , cx : & EarlyContext < ' _ > , span : syntax_pos:: Span ) {
327
+ crate fn display ( & self , suggested_format : String , cx : & EarlyContext < ' _ > , span : syntax_pos:: Span ) {
328
328
match self {
329
329
Self :: MistypedLiteralSuffix => span_lint_and_sugg (
330
330
cx,
331
331
MISTYPED_LITERAL_SUFFIXES ,
332
332
span,
333
333
"mistyped literal suffix" ,
334
334
"did you mean to write" ,
335
- grouping_hint . to_string ( ) ,
335
+ suggested_format ,
336
336
Applicability :: MaybeIncorrect ,
337
337
) ,
338
338
Self :: UnreadableLiteral => span_lint_and_sugg (
@@ -341,7 +341,7 @@ impl WarningType {
341
341
span,
342
342
"long literal lacking separators" ,
343
343
"consider" ,
344
- grouping_hint . to_owned ( ) ,
344
+ suggested_format ,
345
345
Applicability :: MachineApplicable ,
346
346
) ,
347
347
Self :: LargeDigitGroups => span_lint_and_sugg (
@@ -350,7 +350,7 @@ impl WarningType {
350
350
span,
351
351
"digit groups should be smaller" ,
352
352
"consider" ,
353
- grouping_hint . to_owned ( ) ,
353
+ suggested_format ,
354
354
Applicability :: MachineApplicable ,
355
355
) ,
356
356
Self :: InconsistentDigitGrouping => span_lint_and_sugg (
@@ -359,7 +359,7 @@ impl WarningType {
359
359
span,
360
360
"digits grouped inconsistently by underscores" ,
361
361
"consider" ,
362
- grouping_hint . to_owned ( ) ,
362
+ suggested_format ,
363
363
Applicability :: MachineApplicable ,
364
364
) ,
365
365
Self :: DecimalRepresentation => span_lint_and_sugg (
@@ -368,7 +368,7 @@ impl WarningType {
368
368
span,
369
369
"integer literal has a better hexadecimal representation" ,
370
370
"consider" ,
371
- grouping_hint . to_owned ( ) ,
371
+ suggested_format ,
372
372
Applicability :: MachineApplicable ,
373
373
) ,
374
374
} ;
@@ -425,7 +425,7 @@ impl LiteralDigitGrouping {
425
425
426
426
427
427
if let Err ( warning_type) = result {
428
- warning_type. display( & num_lit. grouping_hint ( ) , cx, lit. span)
428
+ warning_type. display( num_lit. format ( ) , cx, lit. span)
429
429
}
430
430
}
431
431
}
@@ -453,11 +453,11 @@ impl LiteralDigitGrouping {
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 = num_lit. grouping_hint ( ) ;
457
- hint . push ( '_' ) ;
458
- hint . push ( missing_char) ;
459
- hint . push_str ( last_group) ;
460
- WarningType :: MistypedLiteralSuffix . display ( & hint , cx, span) ;
456
+ let mut sugg = num_lit. format ( ) ;
457
+ sugg . push ( '_' ) ;
458
+ sugg . push ( missing_char) ;
459
+ sugg . push_str ( last_group) ;
460
+ WarningType :: MistypedLiteralSuffix . display ( sugg , cx, span) ;
461
461
false
462
462
} else {
463
463
true
@@ -546,7 +546,7 @@ impl DecimalLiteralRepresentation {
546
546
let hex = format!( "{:#X}" , val) ;
547
547
let num_lit = NumericLiteral :: new( & hex, None , false ) ;
548
548
let _ = Self :: do_lint( num_lit. integer) . map_err( |warning_type| {
549
- warning_type. display( & num_lit. grouping_hint ( ) , cx, lit. span)
549
+ warning_type. display( num_lit. format ( ) , cx, lit. span)
550
550
} ) ;
551
551
}
552
552
}
0 commit comments