Unbox and unwrap the contents of StatementKind::Coverage
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.
This commit is contained in:
parent
c3b05c6e5b
commit
ab92699f4a
15 changed files with 44 additions and 68 deletions
|
@ -1,7 +1,7 @@
|
|||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use rustc_middle::mir::coverage::{CounterId, CoverageKind};
|
||||
use rustc_middle::mir::{Body, Coverage, CoverageIdsInfo, Statement, StatementKind};
|
||||
use rustc_middle::mir::{Body, CoverageIdsInfo, Statement, StatementKind};
|
||||
use rustc_middle::query::TyCtxtAt;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_middle::util::Providers;
|
||||
|
@ -54,7 +54,7 @@ fn coverage_ids_info<'tcx>(
|
|||
let mir_body = tcx.instance_mir(instance_def);
|
||||
|
||||
let max_counter_id = all_coverage_in_mir_body(mir_body)
|
||||
.filter_map(|coverage| match coverage.kind {
|
||||
.filter_map(|kind| match *kind {
|
||||
CoverageKind::CounterIncrement { id } => Some(id),
|
||||
_ => None,
|
||||
})
|
||||
|
@ -66,12 +66,10 @@ fn coverage_ids_info<'tcx>(
|
|||
|
||||
fn all_coverage_in_mir_body<'a, 'tcx>(
|
||||
body: &'a Body<'tcx>,
|
||||
) -> impl Iterator<Item = &'a Coverage> + Captures<'tcx> {
|
||||
) -> impl Iterator<Item = &'a CoverageKind> + Captures<'tcx> {
|
||||
body.basic_blocks.iter().flat_map(|bb_data| &bb_data.statements).filter_map(|statement| {
|
||||
match statement.kind {
|
||||
StatementKind::Coverage(box ref coverage) if !is_inlined(body, statement) => {
|
||||
Some(coverage)
|
||||
}
|
||||
StatementKind::Coverage(ref kind) if !is_inlined(body, statement) => Some(kind),
|
||||
_ => None,
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue