Skip to content

Commit

Permalink
Auto merge of #82422 - petrochenkov:allunst, r=oli-obk
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Mar 12, 2021
2 parents 0cc64a3 + ddd20ef commit 338647d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ impl SyntaxExtension {
attrs: &[ast::Attribute],
) -> SyntaxExtension {
let allow_internal_unstable =
Some(attr::allow_internal_unstable(sess, &attrs).collect::<Vec<Symbol>>().into());
attr::allow_internal_unstable(sess, &attrs).collect::<Vec<Symbol>>();

let mut local_inner_macros = false;
if let Some(macro_export) = sess.find_by_name(attrs, sym::macro_export) {
Expand Down Expand Up @@ -803,7 +803,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: stability.map(|(s, _)| s),
Expand Down

0 comments on commit 338647d

Please sign in to comment.