Skip to content

Commit fbb2079

Browse files
committed
Use CoverageKind::as_operand_id instead of manually reimplementing it
1 parent 2a15bda commit fbb2079

File tree

1 file changed

+2
-15
lines changed
  • compiler/rustc_mir_transform/src/coverage

1 file changed

+2
-15
lines changed

compiler/rustc_mir_transform/src/coverage/debug.rs

+2-15
Original file line numberDiff line numberDiff line change
@@ -277,14 +277,7 @@ impl DebugCounters {
277277

278278
pub fn add_counter(&mut self, counter_kind: &CoverageKind, some_block_label: Option<String>) {
279279
if let Some(counters) = &mut self.some_counters {
280-
let id: ExpressionOperandId = match *counter_kind {
281-
CoverageKind::Counter { id, .. } => id.into(),
282-
CoverageKind::Expression { id, .. } => id.into(),
283-
_ => bug!(
284-
"the given `CoverageKind` is not an counter or expression: {:?}",
285-
counter_kind
286-
),
287-
};
280+
let id = counter_kind.as_operand_id();
288281
counters
289282
.try_insert(id, DebugCounter::new(counter_kind.clone(), some_block_label))
290283
.expect("attempt to add the same counter_kind to DebugCounters more than once");
@@ -330,13 +323,7 @@ impl DebugCounters {
330323
}
331324
}
332325

333-
let id: ExpressionOperandId = match *counter_kind {
334-
CoverageKind::Counter { id, .. } => id.into(),
335-
CoverageKind::Expression { id, .. } => id.into(),
336-
_ => {
337-
bug!("the given `CoverageKind` is not an counter or expression: {:?}", counter_kind)
338-
}
339-
};
326+
let id = counter_kind.as_operand_id();
340327
if self.some_counters.is_some() && (counter_format.block || !counter_format.id) {
341328
let counters = self.some_counters.as_ref().unwrap();
342329
if let Some(DebugCounter { some_block_label: Some(block_label), .. }) =

0 commit comments

Comments
 (0)