@@ -43,8 +43,9 @@ struct BcbExpression {
43
43
rhs : BcbCounter ,
44
44
}
45
45
46
- #[ derive( Debug ) ]
47
- pub ( super ) enum CounterIncrementSite {
46
+ /// Enum representing either a node or an edge in the coverage graph.
47
+ #[ derive( Clone , Copy , Debug ) ]
48
+ pub ( super ) enum Site {
48
49
Node { bcb : BasicCoverageBlock } ,
49
50
Edge { from_bcb : BasicCoverageBlock , to_bcb : BasicCoverageBlock } ,
50
51
}
@@ -54,7 +55,7 @@ pub(super) enum CounterIncrementSite {
54
55
pub ( super ) struct CoverageCounters {
55
56
/// List of places where a counter-increment statement should be injected
56
57
/// into MIR, each with its corresponding counter ID.
57
- counter_increment_sites : IndexVec < CounterId , CounterIncrementSite > ,
58
+ counter_increment_sites : IndexVec < CounterId , Site > ,
58
59
59
60
/// Coverage counters/expressions that are associated with individual BCBs.
60
61
node_counters : IndexVec < BasicCoverageBlock , Option < BcbCounter > > ,
@@ -98,14 +99,14 @@ impl CoverageCounters {
98
99
99
100
/// Shared helper used by [`Self::make_phys_node_counter`] and
100
101
/// [`Self::make_phys_edge_counter`]. Don't call this directly.
101
- fn make_counter_inner ( & mut self , site : CounterIncrementSite ) -> BcbCounter {
102
+ fn make_counter_inner ( & mut self , site : Site ) -> BcbCounter {
102
103
let id = self . counter_increment_sites . push ( site) ;
103
104
BcbCounter :: Counter { id }
104
105
}
105
106
106
107
/// Creates a new physical counter for a BCB node.
107
108
fn make_phys_node_counter ( & mut self , bcb : BasicCoverageBlock ) -> BcbCounter {
108
- self . make_counter_inner ( CounterIncrementSite :: Node { bcb } )
109
+ self . make_counter_inner ( Site :: Node { bcb } )
109
110
}
110
111
111
112
/// Creates a new physical counter for a BCB edge.
@@ -114,7 +115,7 @@ impl CoverageCounters {
114
115
from_bcb : BasicCoverageBlock ,
115
116
to_bcb : BasicCoverageBlock ,
116
117
) -> BcbCounter {
117
- self . make_counter_inner ( CounterIncrementSite :: Edge { from_bcb, to_bcb } )
118
+ self . make_counter_inner ( Site :: Edge { from_bcb, to_bcb } )
118
119
}
119
120
120
121
fn make_expression ( & mut self , lhs : BcbCounter , op : Op , rhs : BcbCounter ) -> BcbCounter {
@@ -224,8 +225,8 @@ impl CoverageCounters {
224
225
/// each site's corresponding counter ID.
225
226
pub ( super ) fn counter_increment_sites (
226
227
& self ,
227
- ) -> impl Iterator < Item = ( CounterId , & CounterIncrementSite ) > {
228
- self . counter_increment_sites . iter_enumerated ( )
228
+ ) -> impl Iterator < Item = ( CounterId , Site ) > + Captures < ' _ > {
229
+ self . counter_increment_sites . iter_enumerated ( ) . map ( | ( id , & site ) | ( id , site ) )
229
230
}
230
231
231
232
/// Returns an iterator over the subset of BCB nodes that have been associated
0 commit comments