From 14e57d7c134cc80878c10f2e2bb61e62cc6a2fdb Mon Sep 17 00:00:00 2001 From: The 8472 Date: Sun, 2 Jul 2023 22:43:39 +0200 Subject: perform TokenStream replacement in-place when possible in expand_macro --- compiler/rustc_expand/src/mbe/macro_rules.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'compiler/rustc_expand/src') diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index 4a8a14994ff..42cc0a6b143 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -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) { -- cgit 1.4.1-3-g733a5