Rename LitKind::to_token_lit as LitKind::synthesize_token_lit.

This makes it clearer that it's not a lossless conversion, which I find
helpful.
This commit is contained in:
Nicholas Nethercote
2022-11-29 13:01:04 +11:00
parent c090c6880c
commit e658144586
6 changed files with 8 additions and 8 deletions

View File

@@ -142,10 +142,10 @@ impl LitKind {
})
}
/// Attempts to recover a token from semantic literal.
/// Synthesizes a token from a semantic literal.
/// This function is used when the original token doesn't exist (e.g. the literal is created
/// by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
pub fn to_token_lit(&self) -> token::Lit {
pub fn synthesize_token_lit(&self) -> token::Lit {
let (kind, symbol, suffix) = match *self {
LitKind::Str(symbol, ast::StrStyle::Cooked) => {
// Don't re-intern unless the escaped string is different.