@@ -171,12 +171,15 @@ impl LitKind {
171
171
/// by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
172
172
pub fn to_lit_token ( & self ) -> token:: Lit {
173
173
let ( kind, symbol, suffix) = match * self {
174
- LitKind :: Str ( string, ast:: StrStyle :: Cooked ) => {
175
- let escaped = string. as_str ( ) . escape_default ( ) . to_string ( ) ;
176
- ( token:: Str , Symbol :: intern ( & escaped) , None )
174
+ LitKind :: Str ( symbol, ast:: StrStyle :: Cooked ) => {
175
+ // Don't re-intern unless the escaped string is different.
176
+ let s = & symbol. as_str ( ) ;
177
+ let escaped = s. escape_default ( ) . to_string ( ) ;
178
+ let symbol = if escaped == * s { symbol } else { Symbol :: intern ( & escaped) } ;
179
+ ( token:: Str , symbol, None )
177
180
}
178
- LitKind :: Str ( string , ast:: StrStyle :: Raw ( n) ) => {
179
- ( token:: StrRaw ( n) , string , None )
181
+ LitKind :: Str ( symbol , ast:: StrStyle :: Raw ( n) ) => {
182
+ ( token:: StrRaw ( n) , symbol , None )
180
183
}
181
184
LitKind :: ByteStr ( ref bytes) => {
182
185
let string = bytes. iter ( ) . cloned ( ) . flat_map ( ascii:: escape_default)
0 commit comments