Module rustc_mir_transform::coverage::spans::from_mir

source Β·

Structs§

Functions§

  • If the MIR Statement has a span contributive to computing coverage spans, return it; otherwise return None.
  • If the MIR Terminator has a span contributive to computing coverage spans, return it; otherwise return None.
  • is_closure_like πŸ”’
  • Traverses the MIR body to produce an initial collection of coverage-relevant spans, each associated with a node in the coverage graph (BCB) and possibly other metadata.
  • 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_span to find a span that is contained in body_span and has the same SyntaxContext as body_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 the body_span, None is returned.