coverage: Quietly skip functions that end up having no mappings

In codegen, a used function with `FunctionCoverageInfo` but no mappings has
historically indicated a bug. However, that will no longer be the case after
moving some fallible span-processing steps into codegen.
This commit is contained in:
Zalathar 2024-12-18 21:23:48 +11:00
parent d416cead5a
commit c3780e1d22

View file

@ -10,7 +10,6 @@ use rustc_abi::Align;
use rustc_codegen_ssa::traits::{
BaseTypeCodegenMethods, ConstCodegenMethods, StaticCodegenMethods,
};
use rustc_middle::bug;
use rustc_middle::mir::coverage::{
CovTerm, CoverageIdsInfo, Expression, FunctionCoverageInfo, Mapping, MappingKind, Op,
};
@ -67,12 +66,8 @@ pub(crate) fn prepare_covfun_record<'tcx>(
fill_region_tables(tcx, global_file_table, fn_cov_info, ids_info, &mut covfun);
if covfun.regions.has_no_regions() {
if covfun.is_used {
bug!("a used function should have had coverage mapping data but did not: {covfun:?}");
} else {
debug!(?covfun, "unused function had no coverage mapping data");
return None;
}
debug!(?covfun, "function has no mappings to embed; skipping");
return None;
}
Some(covfun)