@@ -129,16 +129,14 @@ impl CoverageSpan {
129129 /// If the span is part of a macro, and the macro is visible (expands directly to the given
130130 /// body_span), returns the macro name symbol.
131131 pub fn visible_macro ( & self , body_span : Span ) -> Option < Symbol > {
132- if let Some ( current_macro) = self . current_macro ( )
133- && self
134- . expn_span
135- . parent_callsite ( )
136- . unwrap_or_else ( || bug ! ( "macro must have a parent" ) )
137- . eq_ctxt ( body_span)
138- {
139- return Some ( current_macro) ;
140- }
141- None
132+ let current_macro = self . current_macro ( ) ?;
133+ let parent_callsite = self . expn_span . parent_callsite ( ) ?;
134+
135+ // In addition to matching the context of the body span, the parent callsite
136+ // must also be the source callsite, i.e. the parent must have no parent.
137+ let is_visible_macro =
138+ parent_callsite. parent_callsite ( ) . is_none ( ) && parent_callsite. eq_ctxt ( body_span) ;
139+ is_visible_macro. then_some ( current_macro)
142140 }
143141
144142 pub fn is_macro_expansion ( & self ) -> bool {
@@ -384,10 +382,10 @@ impl<'a> CoverageSpansGenerator<'a> {
384382 let split_point_after_macro_bang = self . curr_original_span . lo ( )
385383 + BytePos ( visible_macro. as_str ( ) . len ( ) as u32 )
386384 + BytePos ( 1 ) ; // add 1 for the `!`
385+ debug_assert ! ( split_point_after_macro_bang <= curr. span. hi( ) ) ;
387386 if split_point_after_macro_bang > curr. span . hi ( ) {
388387 // Something is wrong with the macro name span;
389388 // return now to avoid emitting malformed mappings.
390- // FIXME(#117788): Track down why this happens.
391389 return ;
392390 }
393391
0 commit comments