Generate ScopeId using newtype_index macro

This commit is contained in:
Santiago Pastorino 2017-09-28 17:08:28 -03:00
parent 8ee16f4352
commit 271a492cb2
2 changed files with 3 additions and 14 deletions

View File

@ -51,7 +51,8 @@ macro_rules! newtype_index {
impl $name {
// HACK use for constants
pub const fn const_new(x: u32) -> Self {
#[allow(unused)]
const fn const_new(x: u32) -> Self {
$name(x)
}
}

View File

@ -311,19 +311,7 @@ struct CFG<'tcx> {
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct ScopeId(u32);
impl Idx for ScopeId {
fn new(index: usize) -> ScopeId {
assert!(index < (u32::MAX as usize));
ScopeId(index as u32)
}
fn index(self) -> usize {
self.0 as usize
}
}
newtype_index!(ScopeId);
///////////////////////////////////////////////////////////////////////////
/// The `BlockAnd` "monad" packages up the new basic block along with a