Skip to content

Commit 64058f4

Browse files
committed
wip: Undo unnecessary refactoring
1 parent 1df3c61 commit 64058f4

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

compiler/rustc_expand/src/expand.rs

+17-19
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
488488
self.cx.force_mode = force;
489489

490490
let fragment_kind = invoc.fragment_kind;
491-
match self.expand_invoc(invoc, &ext) {
491+
match self.expand_invoc(invoc, &ext.kind) {
492492
ExpandResult::Ready(fragment) => {
493493
let mut derive_invocations = Vec::new();
494494
let derive_placeholders = self
@@ -650,7 +650,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
650650
fn expand_invoc(
651651
&mut self,
652652
invoc: Invocation,
653-
ext: &Lrc<SyntaxExtension>,
653+
ext: &SyntaxExtensionKind,
654654
) -> ExpandResult<AstFragment, Invocation> {
655655
let recursion_limit = match self.cx.reduced_recursion_limit {
656656
Some((limit, _)) => limit,
@@ -671,7 +671,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
671671

672672
let (fragment_kind, span) = (invoc.fragment_kind, invoc.span());
673673
ExpandResult::Ready(match invoc.kind {
674-
InvocationKind::Bang { mac, span } => match &ext.kind {
674+
InvocationKind::Bang { mac, span } => match ext {
675675
SyntaxExtensionKind::Bang(expander) => {
676676
match expander.expand(self.cx, span, mac.args.tokens.clone()) {
677677
Ok(tok_result) => {
@@ -701,7 +701,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
701701
}
702702
_ => unreachable!(),
703703
},
704-
InvocationKind::Attr { attr, pos, mut item, derives } => match &ext.kind {
704+
InvocationKind::Attr { attr, pos, mut item, derives } => match ext {
705705
SyntaxExtensionKind::Attr(expander) => {
706706
self.gate_proc_macro_input(&item);
707707
self.gate_proc_macro_attr_item(span, &item);
@@ -780,10 +780,10 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
780780
}
781781
_ => unreachable!(),
782782
},
783-
InvocationKind::Derive { path, item, is_const } => match &ext.kind {
783+
InvocationKind::Derive { path, item, is_const } => match ext {
784784
SyntaxExtensionKind::Derive(expander)
785785
| SyntaxExtensionKind::LegacyDerive(expander) => {
786-
if let SyntaxExtensionKind::Derive(..) = ext.kind {
786+
if let SyntaxExtensionKind::Derive(..) = ext {
787787
self.gate_proc_macro_input(&item);
788788
}
789789
// The `MetaItem` representing the trait to derive can't
@@ -794,7 +794,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
794794
span,
795795
path,
796796
};
797-
invoc.expansion_data.id.expn_data();
798797
let items = match expander.expand(self.cx, span, &meta, item, is_const) {
799798
ExpandResult::Ready(items) => items,
800799
ExpandResult::Retry(item) => {
@@ -811,19 +810,18 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
811810
},
812811
InvocationKind::GlobDelegation { item } => {
813812
let AssocItemKind::DelegationMac(deleg) = &item.kind else { unreachable!() };
814-
let suffixes = match &ext.kind {
815-
SyntaxExtensionKind::GlobDelegation(expander) => {
816-
match expander.expand(self.cx) {
817-
ExpandResult::Ready(suffixes) => suffixes,
818-
ExpandResult::Retry(()) => {
819-
// Reassemble the original invocation for retrying.
820-
return ExpandResult::Retry(Invocation {
821-
kind: InvocationKind::GlobDelegation { item },
822-
..invoc
823-
});
824-
}
813+
let suffixes = match ext {
814+
SyntaxExtensionKind::GlobDelegation(expander) => match expander.expand(self.cx)
815+
{
816+
ExpandResult::Ready(suffixes) => suffixes,
817+
ExpandResult::Retry(()) => {
818+
// Reassemble the original invocation for retrying.
819+
return ExpandResult::Retry(Invocation {
820+
kind: InvocationKind::GlobDelegation { item },
821+
..invoc
822+
});
825823
}
826-
}
824+
},
827825
SyntaxExtensionKind::LegacyBang(..) => {
828826
let msg = "expanded a dummy glob delegation";
829827
let guar = self.cx.dcx().span_delayed_bug(span, msg);

0 commit comments

Comments
 (0)