@@ -23,7 +23,7 @@ pub enum LitError {
23
23
24
24
impl LitKind {
25
25
/// Converts literal token into a semantic literal.
26
- pub fn from_lit_token ( lit : token:: Lit ) -> Result < LitKind , LitError > {
26
+ pub fn from_token_lit ( lit : token:: Lit ) -> Result < LitKind , LitError > {
27
27
let token:: Lit { kind, symbol, suffix } = lit;
28
28
if suffix. is_some ( ) && !kind. may_have_suffix ( ) {
29
29
return Err ( LitError :: InvalidSuffix ) ;
@@ -153,7 +153,7 @@ impl LitKind {
153
153
/// Attempts to recover a token from semantic literal.
154
154
/// This function is used when the original token doesn't exist (e.g. the literal is created
155
155
/// by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
156
- pub fn to_lit_token ( & self ) -> token:: Lit {
156
+ pub fn to_token_lit ( & self ) -> token:: Lit {
157
157
let ( kind, symbol, suffix) = match * self {
158
158
LitKind :: Str ( symbol, ast:: StrStyle :: Cooked ) => {
159
159
// Don't re-intern unless the escaped string is different.
@@ -208,8 +208,8 @@ impl LitKind {
208
208
209
209
impl Lit {
210
210
/// Converts literal token into an AST literal.
211
- pub fn from_lit_token ( token : token:: Lit , span : Span ) -> Result < Lit , LitError > {
212
- Ok ( Lit { token , kind : LitKind :: from_lit_token ( token ) ?, span } )
211
+ pub fn from_token_lit ( token_lit : token:: Lit , span : Span ) -> Result < Lit , LitError > {
212
+ Ok ( Lit { token_lit , kind : LitKind :: from_token_lit ( token_lit ) ?, span } )
213
213
}
214
214
215
215
/// Converts arbitrary token into an AST literal.
@@ -232,21 +232,21 @@ impl Lit {
232
232
_ => return Err ( LitError :: NotLiteral ) ,
233
233
} ;
234
234
235
- Lit :: from_lit_token ( lit, token. span )
235
+ Lit :: from_token_lit ( lit, token. span )
236
236
}
237
237
238
238
/// Attempts to recover an AST literal from semantic literal.
239
239
/// This function is used when the original token doesn't exist (e.g. the literal is created
240
240
/// by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
241
241
pub fn from_lit_kind ( kind : LitKind , span : Span ) -> Lit {
242
- Lit { token : kind. to_lit_token ( ) , kind, span }
242
+ Lit { token_lit : kind. to_token_lit ( ) , kind, span }
243
243
}
244
244
245
245
/// Losslessly convert an AST literal into a token.
246
246
pub fn to_token ( & self ) -> Token {
247
- let kind = match self . token . kind {
248
- token:: Bool => token:: Ident ( self . token . symbol , false ) ,
249
- _ => token:: Literal ( self . token ) ,
247
+ let kind = match self . token_lit . kind {
248
+ token:: Bool => token:: Ident ( self . token_lit . symbol , false ) ,
249
+ _ => token:: Literal ( self . token_lit ) ,
250
250
} ;
251
251
Token :: new ( kind, self . span )
252
252
}
0 commit comments