@@ -53,21 +53,12 @@ struct BcbExpression {
5353 rhs : BcbCounter ,
5454}
5555
56- /// Enum representing either a node or an edge in the coverage graph.
57- ///
58- /// FIXME(#135481): This enum is no longer needed now that we only instrument
59- /// nodes and not edges. It can be removed in a subsequent PR.
60- #[ derive( Clone , Copy , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
61- pub ( super ) enum Site {
62- Node { bcb : BasicCoverageBlock } ,
63- }
64-
6556/// Generates and stores coverage counter and coverage expression information
66- /// associated with nodes/edges in the BCB graph.
57+ /// associated with nodes in the coverage graph.
6758pub ( super ) struct CoverageCounters {
6859 /// List of places where a counter-increment statement should be injected
6960 /// into MIR, each with its corresponding counter ID.
70- counter_increment_sites : IndexVec < CounterId , Site > ,
61+ counter_increment_sites : IndexVec < CounterId , BasicCoverageBlock > ,
7162
7263 /// Coverage counters/expressions that are associated with individual BCBs.
7364 node_counters : IndexVec < BasicCoverageBlock , Option < BcbCounter > > ,
@@ -130,9 +121,9 @@ impl CoverageCounters {
130121 }
131122 }
132123
133- /// Creates a new physical counter for a BCB node or edge .
134- fn make_phys_counter ( & mut self , site : Site ) -> BcbCounter {
135- let id = self . counter_increment_sites . push ( site ) ;
124+ /// Creates a new physical counter for a BCB node.
125+ fn make_phys_counter ( & mut self , bcb : BasicCoverageBlock ) -> BcbCounter {
126+ let id = self . counter_increment_sites . push ( bcb ) ;
136127 BcbCounter :: Counter { id }
137128 }
138129
@@ -177,12 +168,12 @@ impl CoverageCounters {
177168 self . node_counters [ bcb] . map ( |counter| counter. as_term ( ) )
178169 }
179170
180- /// Returns an iterator over all the nodes/edges in the coverage graph that
171+ /// Returns an iterator over all the nodes in the coverage graph that
181172 /// should have a counter-increment statement injected into MIR, along with
182173 /// each site's corresponding counter ID.
183174 pub ( super ) fn counter_increment_sites (
184175 & self ,
185- ) -> impl Iterator < Item = ( CounterId , Site ) > + Captures < ' _ > {
176+ ) -> impl Iterator < Item = ( CounterId , BasicCoverageBlock ) > + Captures < ' _ > {
186177 self . counter_increment_sites . iter_enumerated ( ) . map ( |( id, & site) | ( id, site) )
187178 }
188179
@@ -221,15 +212,15 @@ impl CoverageCounters {
221212struct Transcriber {
222213 old : NodeCounters < BasicCoverageBlock > ,
223214 new : CoverageCounters ,
224- phys_counter_for_site : FxHashMap < Site , BcbCounter > ,
215+ phys_counter_for_node : FxHashMap < BasicCoverageBlock , BcbCounter > ,
225216}
226217
227218impl Transcriber {
228219 fn new ( num_nodes : usize , old : NodeCounters < BasicCoverageBlock > ) -> Self {
229220 Self {
230221 old,
231222 new : CoverageCounters :: with_num_bcbs ( num_nodes) ,
232- phys_counter_for_site : FxHashMap :: default ( ) ,
223+ phys_counter_for_node : FxHashMap :: default ( ) ,
233224 }
234225 }
235226
@@ -238,7 +229,6 @@ impl Transcriber {
238229 bcb_needs_counter : & DenseBitSet < BasicCoverageBlock > ,
239230 ) -> CoverageCounters {
240231 for bcb in bcb_needs_counter. iter ( ) {
241- let site = Site :: Node { bcb } ;
242232 let ( mut pos, mut neg) : ( Vec < _ > , Vec < _ > ) =
243233 self . old . counter_expr ( bcb) . iter ( ) . partition_map (
244234 |& CounterTerm { node, op } | match op {
@@ -251,7 +241,7 @@ impl Transcriber {
251241 // If we somehow end up with no positive terms, fall back to
252242 // creating a physical counter. There's no known way for this
253243 // to happen, but we can avoid an ICE if it does.
254- debug_assert ! ( false , "{site :?} has no positive counter terms" ) ;
244+ debug_assert ! ( false , "{bcb :?} has no positive counter terms" ) ;
255245 pos = vec ! [ bcb] ;
256246 neg = vec ! [ ] ;
257247 }
@@ -260,10 +250,7 @@ impl Transcriber {
260250 neg. sort ( ) ;
261251
262252 let mut new_counters_for_sites = |sites : Vec < BasicCoverageBlock > | {
263- sites
264- . into_iter ( )
265- . map ( |node| self . ensure_phys_counter ( Site :: Node { bcb : node } ) )
266- . collect :: < Vec < _ > > ( )
253+ sites. into_iter ( ) . map ( |node| self . ensure_phys_counter ( node) ) . collect :: < Vec < _ > > ( )
267254 } ;
268255 let mut pos = new_counters_for_sites ( pos) ;
269256 let mut neg = new_counters_for_sites ( neg) ;
@@ -279,7 +266,7 @@ impl Transcriber {
279266 self . new
280267 }
281268
282- fn ensure_phys_counter ( & mut self , site : Site ) -> BcbCounter {
283- * self . phys_counter_for_site . entry ( site ) . or_insert_with ( || self . new . make_phys_counter ( site ) )
269+ fn ensure_phys_counter ( & mut self , bcb : BasicCoverageBlock ) -> BcbCounter {
270+ * self . phys_counter_for_node . entry ( bcb ) . or_insert_with ( || self . new . make_phys_counter ( bcb ) )
284271 }
285272}
0 commit comments