1
Fork 0

perform TokenStream replacement in-place when possible in expand_macro

This commit is contained in:
The 8472 2023-07-02 22:43:39 +02:00
parent 6162f6f123
commit 14e57d7c13
2 changed files with 19 additions and 5 deletions

View file

@ -223,8 +223,7 @@ fn expand_macro<'cx>(
// Replace all the tokens for the corresponding positions in the macro, to maintain
// proper positions in error reporting, while maintaining the macro_backtrace.
if tts.len() == rhs.tts.len() {
tts = tts.map_enumerated(|i, tt| {
let mut tt = tt.clone();
tts = tts.map_enumerated_owned(|i, mut tt| {
let rhs_tt = &rhs.tts[i];
let ctxt = tt.span().ctxt();
match (&mut tt, rhs_tt) {