From ddd20ef8cba83d97bdfd0b1e113e6ff7ee6e93f3 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Tue, 23 Feb 2021 01:38:36 +0300 Subject: [PATCH] expand: Do not allocate `Lrc` for `allow_internal_unstable` list unless necessary --- compiler/rustc_expand/src/base.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index ca304c05cdce3..90be010e667d1 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -757,7 +757,7 @@ impl SyntaxExtension { attrs: &[ast::Attribute], ) -> SyntaxExtension { let allow_internal_unstable = - Some(attr::allow_internal_unstable(sess, &attrs).collect::>().into()); + attr::allow_internal_unstable(sess, &attrs).collect::>(); let mut local_inner_macros = false; if let Some(macro_export) = sess.find_by_name(attrs, sym::macro_export) { @@ -779,7 +779,8 @@ impl SyntaxExtension { SyntaxExtension { kind, span, - allow_internal_unstable, + allow_internal_unstable: (!allow_internal_unstable.is_empty()) + .then(|| allow_internal_unstable.into()), allow_internal_unsafe: sess.contains_name(attrs, sym::allow_internal_unsafe), local_inner_macros, stability,