Skip to content

Commit fdbb346

Browse files
committed
Generate ScopeId using newtype_index macro
1 parent 7cc713e commit fdbb346

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
@@ -47,7 +47,8 @@ macro_rules! newtype_index {
4747

4848
impl $name {
4949
// HACK use for constants
50-
pub const fn const_new(x: u32) -> Self {
50+
#[allow(unused)]
51+
const fn const_new(x: u32) -> Self {
5152
$name(x)
5253
}
5354
}

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)