@@ -219,7 +219,7 @@ impl<'a> NumericLiteral<'a> {
219219 }
220220
221221 /// Returns literal formatted in a sensible way.
222- crate fn grouping_hint ( & self ) -> String {
222+ crate fn format ( & self ) -> String {
223223 let mut output = String :: new ( ) ;
224224
225225 if let Some ( prefix) = self . prefix {
@@ -324,15 +324,15 @@ enum WarningType {
324324}
325325
326326impl 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 ) {
328328 match self {
329329 Self :: MistypedLiteralSuffix => span_lint_and_sugg (
330330 cx,
331331 MISTYPED_LITERAL_SUFFIXES ,
332332 span,
333333 "mistyped literal suffix" ,
334334 "did you mean to write" ,
335- grouping_hint . to_string ( ) ,
335+ suggested_format ,
336336 Applicability :: MaybeIncorrect ,
337337 ) ,
338338 Self :: UnreadableLiteral => span_lint_and_sugg (
@@ -341,7 +341,7 @@ impl WarningType {
341341 span,
342342 "long literal lacking separators" ,
343343 "consider" ,
344- grouping_hint . to_owned ( ) ,
344+ suggested_format ,
345345 Applicability :: MachineApplicable ,
346346 ) ,
347347 Self :: LargeDigitGroups => span_lint_and_sugg (
@@ -350,7 +350,7 @@ impl WarningType {
350350 span,
351351 "digit groups should be smaller" ,
352352 "consider" ,
353- grouping_hint . to_owned ( ) ,
353+ suggested_format ,
354354 Applicability :: MachineApplicable ,
355355 ) ,
356356 Self :: InconsistentDigitGrouping => span_lint_and_sugg (
@@ -359,7 +359,7 @@ impl WarningType {
359359 span,
360360 "digits grouped inconsistently by underscores" ,
361361 "consider" ,
362- grouping_hint . to_owned ( ) ,
362+ suggested_format ,
363363 Applicability :: MachineApplicable ,
364364 ) ,
365365 Self :: DecimalRepresentation => span_lint_and_sugg (
@@ -368,7 +368,7 @@ impl WarningType {
368368 span,
369369 "integer literal has a better hexadecimal representation" ,
370370 "consider" ,
371- grouping_hint . to_owned ( ) ,
371+ suggested_format ,
372372 Applicability :: MachineApplicable ,
373373 ) ,
374374 } ;
@@ -425,7 +425,7 @@ impl LiteralDigitGrouping {
425425
426426
427427 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)
429429 }
430430 }
431431 }
@@ -453,11 +453,11 @@ impl LiteralDigitGrouping {
453453 let last_group = split. next ( ) . expect ( "At least one group" ) ;
454454 if split. next ( ) . is_some ( ) && mistyped_suffixes. contains ( & last_group) {
455455 * 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) ;
461461 false
462462 } else {
463463 true
@@ -546,7 +546,7 @@ impl DecimalLiteralRepresentation {
546546 let hex = format!( "{:#X}" , val) ;
547547 let num_lit = NumericLiteral :: new( & hex, None , false ) ;
548548 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)
550550 } ) ;
551551 }
552552 }
0 commit comments