@@ -53,7 +53,7 @@ pub(super) struct CoverageCounters {
53
53
/// edge between two BCBs.
54
54
bcb_edge_counters : FxHashMap < ( BasicCoverageBlock , BasicCoverageBlock ) , BcbCounter > ,
55
55
/// Tracks which BCBs have a counter associated with some incoming edge.
56
- /// Only used by debug assertions, to verify that BCBs with incoming edge
56
+ /// Only used by assertions, to verify that BCBs with incoming edge
57
57
/// counters do not have their own physical counters (expressions are allowed).
58
58
bcb_has_incoming_edge_counters : BitSet < BasicCoverageBlock > ,
59
59
/// Table of expression data, associating each expression ID with its
@@ -116,13 +116,14 @@ impl CoverageCounters {
116
116
bcb : BasicCoverageBlock ,
117
117
counter_kind : BcbCounter ,
118
118
) -> Result < CovTerm , Error > {
119
- debug_assert ! (
119
+ assert ! (
120
120
// If the BCB has an edge counter (to be injected into a new `BasicBlock`), it can also
121
121
// have an expression (to be injected into an existing `BasicBlock` represented by this
122
122
// `BasicCoverageBlock`).
123
123
counter_kind. is_expression( ) || !self . bcb_has_incoming_edge_counters. contains( bcb) ,
124
124
"attempt to add a `Counter` to a BCB target with existing incoming edge counters"
125
125
) ;
126
+
126
127
let term = counter_kind. as_term ( ) ;
127
128
if let Some ( replaced) = self . bcb_counters [ bcb] . replace ( counter_kind) {
128
129
Error :: from_string ( format ! (
@@ -140,17 +141,16 @@ impl CoverageCounters {
140
141
to_bcb : BasicCoverageBlock ,
141
142
counter_kind : BcbCounter ,
142
143
) -> Result < CovTerm , Error > {
143
- if level_enabled ! ( tracing:: Level :: DEBUG ) {
144
- // If the BCB has an edge counter (to be injected into a new `BasicBlock`), it can also
145
- // have an expression (to be injected into an existing `BasicBlock` represented by this
146
- // `BasicCoverageBlock`).
147
- if self . bcb_counter ( to_bcb) . is_some_and ( |c| !c. is_expression ( ) ) {
148
- return Error :: from_string ( format ! (
149
- "attempt to add an incoming edge counter from {from_bcb:?} when the target BCB already \
150
- has a `Counter`"
151
- ) ) ;
152
- }
144
+ // If the BCB has an edge counter (to be injected into a new `BasicBlock`), it can also
145
+ // have an expression (to be injected into an existing `BasicBlock` represented by this
146
+ // `BasicCoverageBlock`).
147
+ if let Some ( node_counter) = self . bcb_counter ( to_bcb) && !node_counter. is_expression ( ) {
148
+ return Error :: from_string ( format ! (
149
+ "attempt to add an incoming edge counter from {from_bcb:?} \
150
+ when the target BCB already has {node_counter:?}"
151
+ ) ) ;
153
152
}
153
+
154
154
self . bcb_has_incoming_edge_counters . insert ( to_bcb) ;
155
155
let term = counter_kind. as_term ( ) ;
156
156
if let Some ( replaced) = self . bcb_edge_counters . insert ( ( from_bcb, to_bcb) , counter_kind) {
0 commit comments