Skip to content

Commit 271a492

Browse files
committed
Generate ScopeId using newtype_index macro
1 parent 8ee16f4 commit 271a492

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

src/librustc_data_structures/indexed_vec.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ macro_rules! newtype_index {
5151

5252
impl $name {
5353
// HACK use for constants
54-
pub const fn const_new(x: u32) -> Self {
54+
#[allow(unused)]
55+
const fn const_new(x: u32) -> Self {
5556
$name(x)
5657
}
5758
}

src/librustc_mir/build/mod.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -311,19 +311,7 @@ struct CFG<'tcx> {
311311
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
312312
}
313313

314-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
315-
pub struct ScopeId(u32);
316-
317-
impl Idx for ScopeId {
318-
fn new(index: usize) -> ScopeId {
319-
assert!(index < (u32::MAX as usize));
320-
ScopeId(index as u32)
321-
}
322-
323-
fn index(self) -> usize {
324-
self.0 as usize
325-
}
326-
}
314+
newtype_index!(ScopeId);
327315

328316
///////////////////////////////////////////////////////////////////////////
329317
/// The `BlockAnd` "monad" packages up the new basic block along with a

0 commit comments

Comments
 (0)