Skip to content

Commit 3953d8b

Browse files
committed
wip: Undo unnecessary refactoring
1 parent 2b85ef1 commit 3953d8b

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

compiler/rustc_expand/src/expand.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
491491
self.cx.force_mode = force;
492492

493493
let fragment_kind = invoc.fragment_kind;
494-
match self.expand_invoc(invoc, &ext) {
494+
match self.expand_invoc(invoc, &ext.kind) {
495495
ExpandResult::Ready(fragment) => {
496496
let mut derive_invocations = Vec::new();
497497
let derive_placeholders = self
@@ -653,7 +653,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
653653
fn expand_invoc(
654654
&mut self,
655655
invoc: Invocation,
656-
ext: &Lrc<SyntaxExtension>,
656+
ext: &SyntaxExtensionKind,
657657
) -> ExpandResult<AstFragment, Invocation> {
658658
let recursion_limit = match self.cx.reduced_recursion_limit {
659659
Some((limit, _)) => limit,
@@ -674,7 +674,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
674674

675675
let (fragment_kind, span) = (invoc.fragment_kind, invoc.span());
676676
ExpandResult::Ready(match invoc.kind {
677-
InvocationKind::Bang { mac, span } => match &ext.kind {
677+
InvocationKind::Bang { mac, span } => match ext {
678678
SyntaxExtensionKind::Bang(expander) => {
679679
match expander.expand(self.cx, span, mac.args.tokens.clone()) {
680680
Ok(tok_result) => {
@@ -704,7 +704,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
704704
}
705705
_ => unreachable!(),
706706
},
707-
InvocationKind::Attr { attr, pos, mut item, derives } => match &ext.kind {
707+
InvocationKind::Attr { attr, pos, mut item, derives } => match ext {
708708
SyntaxExtensionKind::Attr(expander) => {
709709
self.gate_proc_macro_input(&item);
710710
self.gate_proc_macro_attr_item(span, &item);
@@ -783,10 +783,10 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
783783
}
784784
_ => unreachable!(),
785785
},
786-
InvocationKind::Derive { path, item, is_const } => match &ext.kind {
786+
InvocationKind::Derive { path, item, is_const } => match ext {
787787
SyntaxExtensionKind::Derive(expander)
788788
| SyntaxExtensionKind::LegacyDerive(expander) => {
789-
if let SyntaxExtensionKind::Derive(..) = ext.kind {
789+
if let SyntaxExtensionKind::Derive(..) = ext {
790790
self.gate_proc_macro_input(&item);
791791
}
792792
// The `MetaItem` representing the trait to derive can't
@@ -797,7 +797,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
797797
span,
798798
path,
799799
};
800-
invoc.expansion_data.id.expn_data();
801800
let items = match expander.expand(self.cx, span, &meta, item, is_const) {
802801
ExpandResult::Ready(items) => items,
803802
ExpandResult::Retry(item) => {
@@ -814,19 +813,18 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
814813
},
815814
InvocationKind::GlobDelegation { item } => {
816815
let AssocItemKind::DelegationMac(deleg) = &item.kind else { unreachable!() };
817-
let suffixes = match &ext.kind {
818-
SyntaxExtensionKind::GlobDelegation(expander) => {
819-
match expander.expand(self.cx) {
820-
ExpandResult::Ready(suffixes) => suffixes,
821-
ExpandResult::Retry(()) => {
822-
// Reassemble the original invocation for retrying.
823-
return ExpandResult::Retry(Invocation {
824-
kind: InvocationKind::GlobDelegation { item },
825-
..invoc
826-
});
827-
}
816+
let suffixes = match ext {
817+
SyntaxExtensionKind::GlobDelegation(expander) => match expander.expand(self.cx)
818+
{
819+
ExpandResult::Ready(suffixes) => suffixes,
820+
ExpandResult::Retry(()) => {
821+
// Reassemble the original invocation for retrying.
822+
return ExpandResult::Retry(Invocation {
823+
kind: InvocationKind::GlobDelegation { item },
824+
..invoc
825+
});
828826
}
829-
}
827+
},
830828
SyntaxExtensionKind::LegacyBang(..) => {
831829
let msg = "expanded a dummy glob delegation";
832830
let guar = self.cx.dcx().span_delayed_bug(span, msg);

0 commit comments

Comments
 (0)