summaryrefslogtreecommitdiff
path: root/compiler/rustc_expand
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-05-01 10:57:08 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2024-05-03 09:06:26 +1000
commitae7e32880af6b4f2de26ee8842e9995896de21a0 (patch)
treeb66450b2f36e057eb0e3bf6b34388e26bb4c9f56 /compiler/rustc_expand
parent1c15b6ae9c8745cb775b80a48d655c2234135f71 (diff)
Introduce `Invocation::span_mut`.
Alongside the existing `Invocation::span`.
Diffstat (limited to 'compiler/rustc_expand')
-rw-r--r--compiler/rustc_expand/src/expand.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs
index 2b93732e28b..f61cebc0256 100644
--- a/compiler/rustc_expand/src/expand.rs
+++ b/compiler/rustc_expand/src/expand.rs
@@ -372,6 +372,14 @@ impl Invocation {
InvocationKind::Derive { path, .. } => path.span,
}
}
+
+ fn span_mut(&mut self) -> &mut Span {
+ match &mut self.kind {
+ InvocationKind::Bang { span, .. } => span,
+ InvocationKind::Attr { attr, .. } => &mut attr.span,
+ InvocationKind::Derive { path, .. } => &mut path.span,
+ }
+ }
}
pub struct MacroExpander<'a, 'b> {
@@ -590,11 +598,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
for (invoc, _) in invocations.iter_mut() {
let expn_id = invoc.expansion_data.id;
let parent_def = self.cx.resolver.invocation_parent(expn_id);
- let span = match &mut invoc.kind {
- InvocationKind::Bang { span, .. } => span,
- InvocationKind::Attr { attr, .. } => &mut attr.span,
- InvocationKind::Derive { path, .. } => &mut path.span,
- };
+ let span = invoc.span_mut();
*span = span.with_parent(Some(parent_def));
}
}