Function rustc_mir_transform::coverage::make_source_region

source ·
fn make_source_region(
    source_map: &SourceMap,
    file_name: Symbol,
    span: Span,
    body_span: Span,
) -> Option<SourceRegion>
Expand description

Convert the Span into its file name, start line and column, and end line and column.

Line numbers and column numbers are 1-based. Unlike most column numbers emitted by the compiler, these column numbers are denoted in bytes, because that’s what LLVM’s llvm-cov tool expects to see in coverage maps.

Returns None if the conversion failed for some reason. This shouldn’t happen, but it’s hard to rule out entirely (especially in the presence of complex macros or other expansions), and if it does happen then skipping a span or function is better than an ICE or llvm-cov failure that the user might have no way to avoid.