coverage: Make BcbCounter
module-private
This commit is contained in:
parent
68301a6a96
commit
3f90bb15ed
2 changed files with 6 additions and 10 deletions
|
@ -13,13 +13,13 @@ use crate::coverage::graph::{BasicCoverageBlock, CoverageGraph, TraverseCoverage
|
||||||
/// The coverage counter or counter expression associated with a particular
|
/// The coverage counter or counter expression associated with a particular
|
||||||
/// BCB node or BCB edge.
|
/// BCB node or BCB edge.
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
pub(super) enum BcbCounter {
|
enum BcbCounter {
|
||||||
Counter { id: CounterId },
|
Counter { id: CounterId },
|
||||||
Expression { id: ExpressionId },
|
Expression { id: ExpressionId },
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BcbCounter {
|
impl BcbCounter {
|
||||||
pub(super) fn as_term(&self) -> CovTerm {
|
fn as_term(&self) -> CovTerm {
|
||||||
match *self {
|
match *self {
|
||||||
BcbCounter::Counter { id, .. } => CovTerm::Counter(id),
|
BcbCounter::Counter { id, .. } => CovTerm::Counter(id),
|
||||||
BcbCounter::Expression { id, .. } => CovTerm::Expression(id),
|
BcbCounter::Expression { id, .. } => CovTerm::Expression(id),
|
||||||
|
@ -218,8 +218,8 @@ impl CoverageCounters {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn bcb_counter(&self, bcb: BasicCoverageBlock) -> Option<BcbCounter> {
|
pub(super) fn term_for_bcb(&self, bcb: BasicCoverageBlock) -> Option<CovTerm> {
|
||||||
self.bcb_counters[bcb]
|
self.bcb_counters[bcb].map(|counter| counter.as_term())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over all the nodes/edges in the coverage graph that
|
/// Returns an iterator over all the nodes/edges in the coverage graph that
|
||||||
|
|
|
@ -153,12 +153,8 @@ fn create_mappings<'tcx>(
|
||||||
&source_file.name.for_scope(tcx.sess, RemapPathScopeComponents::MACRO).to_string_lossy(),
|
&source_file.name.for_scope(tcx.sess, RemapPathScopeComponents::MACRO).to_string_lossy(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let term_for_bcb = |bcb| {
|
let term_for_bcb =
|
||||||
coverage_counters
|
|bcb| coverage_counters.term_for_bcb(bcb).expect("all BCBs with spans were given counters");
|
||||||
.bcb_counter(bcb)
|
|
||||||
.expect("all BCBs with spans were given counters")
|
|
||||||
.as_term()
|
|
||||||
};
|
|
||||||
let region_for_span = |span: Span| make_source_region(source_map, file_name, span, body_span);
|
let region_for_span = |span: Span| make_source_region(source_map, file_name, span, body_span);
|
||||||
|
|
||||||
// Fully destructure the mappings struct to make sure we don't miss any kinds.
|
// Fully destructure the mappings struct to make sure we don't miss any kinds.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue