rustc_codegen_llvm::coverageinfo::mapgen::spans

Function make_coverage_span

Source
pub(crate) fn make_coverage_span(
    file_id: LocalFileId,
    source_map: &SourceMap,
    fn_cov_info: &FunctionCoverageInfo,
    file: &SourceFile,
    span: Span,
) -> Option<CoverageSpan>
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.