mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00

The payload of coverage statements was historically a structure with several fields, so it was boxed to avoid bloating `StatementKind`. Now that the payload is a single relatively-small enum, we can replace `Box<Coverage>` with just `CoverageKind`. This patch also adds a size assertion for `StatementKind`, to avoid accidentally bloating it in the future.
21 lines
679 B
Rust
21 lines
679 B
Rust
use crate::traits::*;
|
|
|
|
use rustc_middle::mir::coverage::CoverageKind;
|
|
use rustc_middle::mir::SourceScope;
|
|
|
|
use super::FunctionCx;
|
|
|
|
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|
pub fn codegen_coverage(&self, bx: &mut Bx, kind: &CoverageKind, scope: SourceScope) {
|
|
// Determine the instance that coverage data was originally generated for.
|
|
let instance = if let Some(inlined) = scope.inlined_instance(&self.mir.source_scopes) {
|
|
self.monomorphize(inlined)
|
|
} else {
|
|
self.instance
|
|
};
|
|
|
|
// Handle the coverage info in a backend-specific way.
|
|
bx.add_coverage(instance, kind);
|
|
}
|
|
}
|