Use CoverageKind::as_operand_id
instead of manually reimplementing it
This commit is contained in:
parent
2a15bdaaa1
commit
fbb2079a24
@ -277,14 +277,7 @@ pub fn is_enabled(&self) -> bool {
|
|||||||
|
|
||||||
pub fn add_counter(&mut self, counter_kind: &CoverageKind, some_block_label: Option<String>) {
|
pub fn add_counter(&mut self, counter_kind: &CoverageKind, some_block_label: Option<String>) {
|
||||||
if let Some(counters) = &mut self.some_counters {
|
if let Some(counters) = &mut self.some_counters {
|
||||||
let id: ExpressionOperandId = match *counter_kind {
|
let id = counter_kind.as_operand_id();
|
||||||
CoverageKind::Counter { id, .. } => id.into(),
|
|
||||||
CoverageKind::Expression { id, .. } => id.into(),
|
|
||||||
_ => bug!(
|
|
||||||
"the given `CoverageKind` is not an counter or expression: {:?}",
|
|
||||||
counter_kind
|
|
||||||
),
|
|
||||||
};
|
|
||||||
counters
|
counters
|
||||||
.try_insert(id, DebugCounter::new(counter_kind.clone(), some_block_label))
|
.try_insert(id, DebugCounter::new(counter_kind.clone(), some_block_label))
|
||||||
.expect("attempt to add the same counter_kind to DebugCounters more than once");
|
.expect("attempt to add the same counter_kind to DebugCounters more than once");
|
||||||
@ -330,13 +323,7 @@ fn format_counter_kind(&self, counter_kind: &CoverageKind) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let id: ExpressionOperandId = match *counter_kind {
|
let id = counter_kind.as_operand_id();
|
||||||
CoverageKind::Counter { id, .. } => id.into(),
|
|
||||||
CoverageKind::Expression { id, .. } => id.into(),
|
|
||||||
_ => {
|
|
||||||
bug!("the given `CoverageKind` is not an counter or expression: {:?}", counter_kind)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if self.some_counters.is_some() && (counter_format.block || !counter_format.id) {
|
if self.some_counters.is_some() && (counter_format.block || !counter_format.id) {
|
||||||
let counters = self.some_counters.as_ref().unwrap();
|
let counters = self.some_counters.as_ref().unwrap();
|
||||||
if let Some(DebugCounter { some_block_label: Some(block_label), .. }) =
|
if let Some(DebugCounter { some_block_label: Some(block_label), .. }) =
|
||||||
|
Loading…
Reference in New Issue
Block a user