We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Invocation::span_mut
1 parent 1c15b6a commit ae7e328Copy full SHA for ae7e328
compiler/rustc_expand/src/expand.rs
@@ -372,6 +372,14 @@ impl Invocation {
372
InvocationKind::Derive { path, .. } => path.span,
373
}
374
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
383
384
385
pub struct MacroExpander<'a, 'b> {
@@ -590,11 +598,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
590
598
for (invoc, _) in invocations.iter_mut() {
591
599
let expn_id = invoc.expansion_data.id;
592
600
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();
602
*span = span.with_parent(Some(parent_def));
603
604
0 commit comments