Skip to content

Commit ae7e328

Browse files
committed
Introduce Invocation::span_mut.
Alongside the existing `Invocation::span`.
1 parent 1c15b6a commit ae7e328

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

compiler/rustc_expand/src/expand.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,14 @@ impl Invocation {
372372
InvocationKind::Derive { path, .. } => path.span,
373373
}
374374
}
375+
376+
fn span_mut(&mut self) -> &mut Span {
377+
match &mut self.kind {
378+
InvocationKind::Bang { span, .. } => span,
379+
InvocationKind::Attr { attr, .. } => &mut attr.span,
380+
InvocationKind::Derive { path, .. } => &mut path.span,
381+
}
382+
}
375383
}
376384

377385
pub struct MacroExpander<'a, 'b> {
@@ -590,11 +598,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
590598
for (invoc, _) in invocations.iter_mut() {
591599
let expn_id = invoc.expansion_data.id;
592600
let parent_def = self.cx.resolver.invocation_parent(expn_id);
593-
let span = match &mut invoc.kind {
594-
InvocationKind::Bang { span, .. } => span,
595-
InvocationKind::Attr { attr, .. } => &mut attr.span,
596-
InvocationKind::Derive { path, .. } => &mut path.span,
597-
};
601+
let span = invoc.span_mut();
598602
*span = span.with_parent(Some(parent_def));
599603
}
600604
}

0 commit comments

Comments
 (0)