Skip to content

Commit

Permalink
coverage: Remove next_id methods from counter/expression IDs
Browse files Browse the repository at this point in the history
When these methods were originally written, I wasn't aware that
`newtype_index!` already supports addition with ordinary numbers, without
needing to unwrap and re-wrap.
  • Loading branch information
Zalathar committed Oct 3, 2023
1 parent b1cf0c8 commit 053c4f9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
10 changes: 0 additions & 10 deletions compiler/rustc_middle/src/mir/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ rustc_index::newtype_index! {

impl CounterId {
pub const START: Self = Self::from_u32(0);

#[inline(always)]
pub fn next_id(self) -> Self {
Self::from_u32(self.as_u32() + 1)
}
}

rustc_index::newtype_index! {
Expand All @@ -38,11 +33,6 @@ rustc_index::newtype_index! {

impl ExpressionId {
pub const START: Self = Self::from_u32(0);

#[inline(always)]
pub fn next_id(self) -> Self {
Self::from_u32(self.as_u32() + 1)
}
}

/// Operand of a coverage-counter expression.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_transform/src/coverage/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ impl CoverageCounters {
/// Counter IDs start from one and go up.
fn next_counter(&mut self) -> CounterId {
let next = self.next_counter_id;
self.next_counter_id = next.next_id();
self.next_counter_id = self.next_counter_id + 1;
next
}

/// Expression IDs start from 0 and go up.
/// (Counter IDs and Expression IDs are distinguished by the `Operand` enum.)
fn next_expression(&mut self) -> ExpressionId {
let next = self.next_expression_id;
self.next_expression_id = next.next_id();
self.next_expression_id = self.next_expression_id + 1;
next
}

Expand Down

0 comments on commit 053c4f9

Please sign in to comment.