mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-23 05:55:25 +00:00
Generate ScopeId using newtype_index macro
This commit is contained in:
parent
8ee16f4352
commit
271a492cb2
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user