Skip to content

Commit 8d5eb6b

Browse files
committed
mbe: Simplify compile_declarative_macro by factoring out some variables
1 parent 3c95364 commit 8d5eb6b

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -373,17 +373,10 @@ pub fn compile_declarative_macro(
373373
node_id: NodeId,
374374
edition: Edition,
375375
) -> (SyntaxExtension, usize) {
376+
let is_local = node_id != DUMMY_NODE_ID;
376377
let mk_syn_ext = |expander| {
377-
SyntaxExtension::new(
378-
sess,
379-
SyntaxExtensionKind::LegacyBang(expander),
380-
span,
381-
Vec::new(),
382-
edition,
383-
ident.name,
384-
attrs,
385-
node_id != DUMMY_NODE_ID,
386-
)
378+
let kind = SyntaxExtensionKind::LegacyBang(expander);
379+
SyntaxExtension::new(sess, kind, span, Vec::new(), edition, ident.name, attrs, is_local)
387380
};
388381
let dummy_syn_ext = |guar| (mk_syn_ext(Arc::new(DummyExpander(guar))), 0);
389382

@@ -454,7 +447,7 @@ pub fn compile_declarative_macro(
454447
}
455448

456449
// Return the number of rules for unused rule linting, if this is a local macro.
457-
let nrules = if node_id != DUMMY_NODE_ID { rules.len() } else { 0 };
450+
let nrules = if is_local { rules.len() } else { 0 };
458451

459452
let expander =
460453
Arc::new(MacroRulesMacroExpander { name: ident, span, node_id, transparency, rules });

0 commit comments

Comments
 (0)