Skip to content

Commit

Permalink
wip: Undo unnecessary refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
futile committed Aug 19, 2024
1 parent 1df3c61 commit 64058f4
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions compiler/rustc_expand/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
self.cx.force_mode = force;

let fragment_kind = invoc.fragment_kind;
match self.expand_invoc(invoc, &ext) {
match self.expand_invoc(invoc, &ext.kind) {
ExpandResult::Ready(fragment) => {
let mut derive_invocations = Vec::new();
let derive_placeholders = self
Expand Down Expand Up @@ -650,7 +650,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
fn expand_invoc(
&mut self,
invoc: Invocation,
ext: &Lrc<SyntaxExtension>,
ext: &SyntaxExtensionKind,
) -> ExpandResult<AstFragment, Invocation> {
let recursion_limit = match self.cx.reduced_recursion_limit {
Some((limit, _)) => limit,
Expand All @@ -671,7 +671,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {

let (fragment_kind, span) = (invoc.fragment_kind, invoc.span());
ExpandResult::Ready(match invoc.kind {
InvocationKind::Bang { mac, span } => match &ext.kind {
InvocationKind::Bang { mac, span } => match ext {
SyntaxExtensionKind::Bang(expander) => {
match expander.expand(self.cx, span, mac.args.tokens.clone()) {
Ok(tok_result) => {
Expand Down Expand Up @@ -701,7 +701,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
}
_ => unreachable!(),
},
InvocationKind::Attr { attr, pos, mut item, derives } => match &ext.kind {
InvocationKind::Attr { attr, pos, mut item, derives } => match ext {
SyntaxExtensionKind::Attr(expander) => {
self.gate_proc_macro_input(&item);
self.gate_proc_macro_attr_item(span, &item);
Expand Down Expand Up @@ -780,10 +780,10 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
}
_ => unreachable!(),
},
InvocationKind::Derive { path, item, is_const } => match &ext.kind {
InvocationKind::Derive { path, item, is_const } => match ext {
SyntaxExtensionKind::Derive(expander)
| SyntaxExtensionKind::LegacyDerive(expander) => {
if let SyntaxExtensionKind::Derive(..) = ext.kind {
if let SyntaxExtensionKind::Derive(..) = ext {
self.gate_proc_macro_input(&item);
}
// The `MetaItem` representing the trait to derive can't
Expand All @@ -794,7 +794,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
span,
path,
};
invoc.expansion_data.id.expn_data();
let items = match expander.expand(self.cx, span, &meta, item, is_const) {
ExpandResult::Ready(items) => items,
ExpandResult::Retry(item) => {
Expand All @@ -811,19 +810,18 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
},
InvocationKind::GlobDelegation { item } => {
let AssocItemKind::DelegationMac(deleg) = &item.kind else { unreachable!() };
let suffixes = match &ext.kind {
SyntaxExtensionKind::GlobDelegation(expander) => {
match expander.expand(self.cx) {
ExpandResult::Ready(suffixes) => suffixes,
ExpandResult::Retry(()) => {
// Reassemble the original invocation for retrying.
return ExpandResult::Retry(Invocation {
kind: InvocationKind::GlobDelegation { item },
..invoc
});
}
let suffixes = match ext {
SyntaxExtensionKind::GlobDelegation(expander) => match expander.expand(self.cx)
{
ExpandResult::Ready(suffixes) => suffixes,
ExpandResult::Retry(()) => {
// Reassemble the original invocation for retrying.
return ExpandResult::Retry(Invocation {
kind: InvocationKind::GlobDelegation { item },
..invoc
});
}
}
},
SyntaxExtensionKind::LegacyBang(..) => {
let msg = "expanded a dummy glob delegation";
let guar = self.cx.dcx().span_delayed_bug(span, msg);
Expand Down

0 comments on commit 64058f4

Please sign in to comment.