@@ -114,20 +114,26 @@ pub(super) enum Radix {
114114impl Radix {
115115 /// Returns a reasonable digit group size for this radix.
116116 #[ must_use]
117- crate fn suggest_grouping ( & self ) -> usize {
117+ fn suggest_grouping ( & self ) -> usize {
118118 match * self {
119119 Self :: Binary | Self :: Hexadecimal => 4 ,
120120 Self :: Octal | Self :: Decimal => 3 ,
121121 }
122122 }
123123}
124124
125+ /// A helper method to format numeric literals with digit grouping.
126+ /// `lit` must be a valid numeric literal without suffix.
127+ pub fn format_numeric_literal ( lit : & str , type_suffix : Option < & str > , float : bool ) -> String {
128+ NumericLiteral :: new ( lit, type_suffix, float) . format ( )
129+ }
130+
125131#[ derive( Debug ) ]
126132pub ( super ) struct NumericLiteral < ' a > {
127133 /// Which radix the literal was represented in.
128- crate radix : Radix ,
134+ radix : Radix ,
129135 /// The radix prefix, if present.
130- crate prefix : Option < & ' a str > ,
136+ prefix : Option < & ' a str > ,
131137
132138 /// The integer part of the number.
133139 integer : & ' a str ,
@@ -137,7 +143,7 @@ pub(super) struct NumericLiteral<'a> {
137143 exponent : Option < ( char , & ' a str ) > ,
138144
139145 /// The type suffix, including preceding underscore if present.
140- crate suffix : Option < & ' a str > ,
146+ suffix : Option < & ' a str > ,
141147}
142148
143149impl < ' a > NumericLiteral < ' a > {
@@ -152,7 +158,7 @@ impl<'a> NumericLiteral<'a> {
152158 }
153159
154160 #[ must_use]
155- crate fn new ( lit : & ' a str , suffix : Option < & ' a str > , float : bool ) -> Self {
161+ fn new ( lit : & ' a str , suffix : Option < & ' a str > , float : bool ) -> Self {
156162 // Determine delimiter for radix prefix, if present, and radix.
157163 let radix = if lit. starts_with ( "0x" ) {
158164 Radix :: Hexadecimal
@@ -219,7 +225,7 @@ impl<'a> NumericLiteral<'a> {
219225 }
220226
221227 /// Returns literal formatted in a sensible way.
222- crate fn format ( & self ) -> String {
228+ fn format ( & self ) -> String {
223229 let mut output = String :: new ( ) ;
224230
225231 if let Some ( prefix) = self . prefix {
@@ -324,7 +330,7 @@ enum WarningType {
324330}
325331
326332impl WarningType {
327- crate fn display ( & self , suggested_format : String , cx : & EarlyContext < ' _ > , span : syntax_pos:: Span ) {
333+ fn display ( & self , suggested_format : String , cx : & EarlyContext < ' _ > , span : syntax_pos:: Span ) {
328334 match self {
329335 Self :: MistypedLiteralSuffix => span_lint_and_sugg (
330336 cx,
0 commit comments