Skip to content

Commit aca6dba

Browse files
committed
coverage: Use a single make_phys_counter method
This is more convenient for subsequent patches.
1 parent 7ecc677 commit aca6dba

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

compiler/rustc_mir_transform/src/coverage/counters.rs

+4-19
Original file line numberDiff line numberDiff line change
@@ -97,27 +97,12 @@ impl CoverageCounters {
9797
}
9898
}
9999

100-
/// Shared helper used by [`Self::make_phys_node_counter`] and
101-
/// [`Self::make_phys_edge_counter`]. Don't call this directly.
102-
fn make_counter_inner(&mut self, site: Site) -> BcbCounter {
100+
/// Creates a new physical counter for a BCB node or edge.
101+
fn make_phys_counter(&mut self, site: Site) -> BcbCounter {
103102
let id = self.counter_increment_sites.push(site);
104103
BcbCounter::Counter { id }
105104
}
106105

107-
/// Creates a new physical counter for a BCB node.
108-
fn make_phys_node_counter(&mut self, bcb: BasicCoverageBlock) -> BcbCounter {
109-
self.make_counter_inner(Site::Node { bcb })
110-
}
111-
112-
/// Creates a new physical counter for a BCB edge.
113-
fn make_phys_edge_counter(
114-
&mut self,
115-
from_bcb: BasicCoverageBlock,
116-
to_bcb: BasicCoverageBlock,
117-
) -> BcbCounter {
118-
self.make_counter_inner(Site::Edge { from_bcb, to_bcb })
119-
}
120-
121106
fn make_expression(&mut self, lhs: BcbCounter, op: Op, rhs: BcbCounter) -> BcbCounter {
122107
let new_expr = BcbExpression { lhs, op, rhs };
123108
*self
@@ -391,7 +376,7 @@ impl<'a> CountersBuilder<'a> {
391376
// leading to infinite recursion.
392377
if predecessors.len() <= 1 || predecessors.contains(&bcb) {
393378
debug!(?bcb, ?predecessors, "node has <=1 predecessors or is its own predecessor");
394-
let counter = self.counters.make_phys_node_counter(bcb);
379+
let counter = self.counters.make_phys_counter(Site::Node { bcb });
395380
debug!(?bcb, ?counter, "node gets a physical counter");
396381
return counter;
397382
}
@@ -448,7 +433,7 @@ impl<'a> CountersBuilder<'a> {
448433
}
449434

450435
// Make a new counter to count this edge.
451-
let counter = self.counters.make_phys_edge_counter(from_bcb, to_bcb);
436+
let counter = self.counters.make_phys_counter(Site::Edge { from_bcb, to_bcb });
452437
debug!(?from_bcb, ?to_bcb, ?counter, "edge gets a physical counter");
453438
counter
454439
}

0 commit comments

Comments
 (0)