Module rustc_mir_transform::coverage::spans::from_mir
source · Structs
Functions
- If the MIR
Statementhas a span contributive to computing coverage spans, return it; otherwise returnNone. - If the MIR
Terminatorhas a span contributive to computing coverage spans, return it; otherwise returnNone. - 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. - When a span corresponds to a macro invocation that is visible from the function body, split it into two parts. The first part covers just the macro name plus
!, and the second part covers the rest of the macro invocation. This seems to give better results for code that uses macros. - Walks through the expansion ancestors of
original_spanto find a span that is contained inbody_spanand has the sameSyntaxContextasbody_span. The ancestor that was traversed just before the matching span (if any) is also returned. - Returns an extrapolated span (pre-expansion) corresponding to a range within the function’s body source. This span is guaranteed to be contained within, or equal to, the
body_span. If the extrapolated span is not contained within thebody_span,Noneis returned.