Skip to content

Commit 338647d

Browse files
committed
Auto merge of #82422 - petrochenkov:allunst, r=oli-obk
expand: Do not allocate `Lrc` for `allow_internal_unstable` list unless necessary This allocation is done for any macro defined in the current crate, or used from a different crate. EDIT: This also removes an `Lrc` increment from each *use* of such macro, which may be more significant. Noticed when reviewing #82367. This probably doesn't matter, but let's do a perf run.
2 parents 0cc64a3 + ddd20ef commit 338647d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/rustc_expand/src/base.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ impl SyntaxExtension {
775775
attrs: &[ast::Attribute],
776776
) -> SyntaxExtension {
777777
let allow_internal_unstable =
778-
Some(attr::allow_internal_unstable(sess, &attrs).collect::<Vec<Symbol>>().into());
778+
attr::allow_internal_unstable(sess, &attrs).collect::<Vec<Symbol>>();
779779

780780
let mut local_inner_macros = false;
781781
if let Some(macro_export) = sess.find_by_name(attrs, sym::macro_export) {
@@ -803,7 +803,8 @@ impl SyntaxExtension {
803803
SyntaxExtension {
804804
kind,
805805
span,
806-
allow_internal_unstable,
806+
allow_internal_unstable: (!allow_internal_unstable.is_empty())
807+
.then(|| allow_internal_unstable.into()),
807808
allow_internal_unsafe: sess.contains_name(attrs, sym::allow_internal_unsafe),
808809
local_inner_macros,
809810
stability: stability.map(|(s, _)| s),

0 commit comments

Comments
 (0)