rustc_mir_transform::coverage::spans

Function remove_unwanted_expansion_spans

source
fn remove_unwanted_expansion_spans(covspans: &mut Vec<SpanFromMir>)
Expand description

Macros that expand into branches (e.g. assert!, trace!) tend to generate multiple condition/consequent blocks that have the span of the whole macro invocation, which is unhelpful. Keeping only the first such span seems to give better mappings, so remove the others.

Similarly, await expands to a branch on the discriminant of Poll, which leads to incorrect coverage if the Future is immediately ready (#98712).

(The input spans should be sorted in BCB dominator order, so that the retained “first” span is likely to dominate the others.)