Skip to content

Commit 91c0d1b

Browse files
committed
wip: Undo unnecessary refactoring
1 parent a81aaed commit 91c0d1b

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
@@ -490,7 +490,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
490490
self.cx.force_mode = force;
491491

492492
let fragment_kind = invoc.fragment_kind;
493-
match self.expand_invoc(invoc, &ext) {
493+
match self.expand_invoc(invoc, &ext.kind) {
494494
ExpandResult::Ready(fragment) => {
495495
let mut derive_invocations = Vec::new();
496496
let derive_placeholders = self
@@ -652,7 +652,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
652652
fn expand_invoc(
653653
&mut self,
654654
invoc: Invocation,
655-
ext: &Lrc<SyntaxExtension>,
655+
ext: &SyntaxExtensionKind,
656656
) -> ExpandResult<AstFragment, Invocation> {
657657
let recursion_limit = match self.cx.reduced_recursion_limit {
658658
Some((limit, _)) => limit,
@@ -673,7 +673,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
673673

674674
let (fragment_kind, span) = (invoc.fragment_kind, invoc.span());
675675
ExpandResult::Ready(match invoc.kind {
676-
InvocationKind::Bang { mac, span } => match &ext.kind {
676+
InvocationKind::Bang { mac, span } => match ext {
677677
SyntaxExtensionKind::Bang(expander) => {
678678
match expander.expand(self.cx, span, mac.args.tokens.clone()) {
679679
Ok(tok_result) => {
@@ -703,7 +703,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
703703
}
704704
_ => unreachable!(),
705705
},
706-
InvocationKind::Attr { attr, pos, mut item, derives } => match &ext.kind {
706+
InvocationKind::Attr { attr, pos, mut item, derives } => match ext {
707707
SyntaxExtensionKind::Attr(expander) => {
708708
self.gate_proc_macro_input(&item);
709709
self.gate_proc_macro_attr_item(span, &item);
@@ -782,10 +782,10 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
782782
}
783783
_ => unreachable!(),
784784
},
785-
InvocationKind::Derive { path, item, is_const } => match &ext.kind {
785+
InvocationKind::Derive { path, item, is_const } => match ext {
786786
SyntaxExtensionKind::Derive(expander)
787787
| SyntaxExtensionKind::LegacyDerive(expander) => {
788-
if let SyntaxExtensionKind::Derive(..) = ext.kind {
788+
if let SyntaxExtensionKind::Derive(..) = ext {
789789
self.gate_proc_macro_input(&item);
790790
}
791791
// The `MetaItem` representing the trait to derive can't
@@ -796,7 +796,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
796796
span,
797797
path,
798798
};
799-
invoc.expansion_data.id.expn_data();
800799
let items = match expander.expand(self.cx, span, &meta, item, is_const) {
801800
ExpandResult::Ready(items) => items,
802801
ExpandResult::Retry(item) => {
@@ -813,19 +812,18 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
813812
},
814813
InvocationKind::GlobDelegation { item } => {
815814
let AssocItemKind::DelegationMac(deleg) = &item.kind else { unreachable!() };
816-
let suffixes = match &ext.kind {
817-
SyntaxExtensionKind::GlobDelegation(expander) => {
818-
match expander.expand(self.cx) {
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-
});
826-
}
815+
let suffixes = match ext {
816+
SyntaxExtensionKind::GlobDelegation(expander) => match expander.expand(self.cx)
817+
{
818+
ExpandResult::Ready(suffixes) => suffixes,
819+
ExpandResult::Retry(()) => {
820+
// Reassemble the original invocation for retrying.
821+
return ExpandResult::Retry(Invocation {
822+
kind: InvocationKind::GlobDelegation { item },
823+
..invoc
824+
});
827825
}
828-
}
826+
},
829827
SyntaxExtensionKind::LegacyBang(..) => {
830828
let msg = "expanded a dummy glob delegation";
831829
let guar = self.cx.dcx().span_delayed_bug(span, msg);

0 commit comments

Comments
 (0)