rustc_ast: Never clone empty token streams in mutable visitor

This commit is contained in:
Vadim Petrochenkov 2020-11-04 16:57:51 +03:00
parent 63343f6323
commit 8def2fc122

View File

@ -656,7 +656,7 @@ pub fn visit_tt<T: MutVisitor>(tt: &mut TokenTree, vis: &mut T) {
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`. // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_tts<T: MutVisitor>(TokenStream(tts): &mut TokenStream, vis: &mut T) { pub fn visit_tts<T: MutVisitor>(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); let tts = Lrc::make_mut(tts);
visit_vec(tts, |(tree, _is_joint)| visit_tt(tree, vis)); visit_vec(tts, |(tree, _is_joint)| visit_tt(tree, vis));
} }