From 8def2fc122a9f698914606c51a9e8c18aed168df Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 4 Nov 2020 16:57:51 +0300 Subject: [PATCH] rustc_ast: Never clone empty token streams in mutable visitor --- compiler/rustc_ast/src/mut_visit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index af8b8ad34c8f2..517717eebd9d0 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -656,7 +656,7 @@ pub fn visit_tt(tt: &mut TokenTree, vis: &mut T) { // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. pub fn visit_tts(TokenStream(tts): &mut TokenStream, vis: &mut T) { - if vis.token_visiting_enabled() { + if vis.token_visiting_enabled() && !tts.is_empty() { let tts = Lrc::make_mut(tts); visit_vec(tts, |(tree, _is_joint)| visit_tt(tree, vis)); }