@@ -23,7 +23,7 @@ pub enum LitError {
2323
2424impl LitKind {
2525 /// 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 > {
2727 let token:: Lit { kind, symbol, suffix } = lit;
2828 if suffix. is_some ( ) && !kind. may_have_suffix ( ) {
2929 return Err ( LitError :: InvalidSuffix ) ;
@@ -153,7 +153,7 @@ impl LitKind {
153153 /// Attempts to recover a token from semantic literal.
154154 /// This function is used when the original token doesn't exist (e.g. the literal is created
155155 /// 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 {
157157 let ( kind, symbol, suffix) = match * self {
158158 LitKind :: Str ( symbol, ast:: StrStyle :: Cooked ) => {
159159 // Don't re-intern unless the escaped string is different.
@@ -208,8 +208,8 @@ impl LitKind {
208208
209209impl Lit {
210210 /// 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 } )
213213 }
214214
215215 /// Converts arbitrary token into an AST literal.
@@ -232,21 +232,21 @@ impl Lit {
232232 _ => return Err ( LitError :: NotLiteral ) ,
233233 } ;
234234
235- Lit :: from_lit_token ( lit, token. span )
235+ Lit :: from_token_lit ( lit, token. span )
236236 }
237237
238238 /// Attempts to recover an AST literal from semantic literal.
239239 /// This function is used when the original token doesn't exist (e.g. the literal is created
240240 /// by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
241241 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 }
243243 }
244244
245245 /// Losslessly convert an AST literal into a token.
246246 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 ) ,
250250 } ;
251251 Token :: new ( kind, self . span )
252252 }
0 commit comments