diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2023-12-28 14:07:18 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2024-01-11 16:43:12 +1100 |
| commit | 124fff0777014323be34f0a990c78c5cfe9f40db (patch) | |
| tree | 57bdce1c03284b41f0a6a214b79bf867650e65b3 /compiler/rustc_mir_transform/src/coverage/spans.rs | |
| parent | c5932182adfe57f38438f6b7509d1f8b9f95fd73 (diff) | |
| download | rust-124fff0777014323be34f0a990c78c5cfe9f40db.tar.gz rust-124fff0777014323be34f0a990c78c5cfe9f40db.zip | |
coverage: Add enums to accommodate other kinds of coverage mappings
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/spans.rs')
| -rw-r--r-- | compiler/rustc_mir_transform/src/coverage/spans.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/compiler/rustc_mir_transform/src/coverage/spans.rs b/compiler/rustc_mir_transform/src/coverage/spans.rs index be52f5b1129..81f6c831206 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans.rs @@ -8,9 +8,15 @@ use crate::coverage::ExtractedHirInfo; mod from_mir; +#[derive(Clone, Copy, Debug)] +pub(super) enum BcbMappingKind { + /// Associates an ordinary executable code span with its corresponding BCB. + Code(BasicCoverageBlock), +} + #[derive(Debug)] pub(super) struct BcbMapping { - pub(super) bcb: BasicCoverageBlock, + pub(super) kind: BcbMappingKind, pub(super) span: Span, } @@ -38,7 +44,7 @@ impl CoverageSpans { ); mappings.extend(coverage_spans.into_iter().map(|CoverageSpan { bcb, span, .. }| { // Each span produced by the generator represents an ordinary code region. - BcbMapping { bcb, span } + BcbMapping { kind: BcbMappingKind::Code(bcb), span } })); if mappings.is_empty() { @@ -47,8 +53,13 @@ impl CoverageSpans { // Identify which BCBs have one or more mappings. let mut bcb_has_mappings = BitSet::new_empty(basic_coverage_blocks.num_nodes()); - for &BcbMapping { bcb, span: _ } in &mappings { + let mut insert = |bcb| { bcb_has_mappings.insert(bcb); + }; + for &BcbMapping { kind, span: _ } in &mappings { + match kind { + BcbMappingKind::Code(bcb) => insert(bcb), + } } Some(Self { bcb_has_mappings, mappings }) |
