rustc_mir_transform::coverage

Function make_source_region

Source
fn make_source_region(
    source_map: &SourceMap,
    hir_info: &ExtractedHirInfo,
    file: &SourceFile,
    span: Span,
) -> Option<SourceRegion>
Expand description

Converts the span into its 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.