diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2017-09-28 17:08:28 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2017-10-04 23:51:43 -0300 |
| commit | 271a492cb2028090c0198e893c18024c19bb6fc7 (patch) | |
| tree | a0c91f823ac97cec4ac769a547ac33d98a3b78d6 /src | |
| parent | 8ee16f4352f3621be75084167185c1f9617859eb (diff) | |
| download | rust-271a492cb2028090c0198e893c18024c19bb6fc7.tar.gz rust-271a492cb2028090c0198e893c18024c19bb6fc7.zip | |
Generate ScopeId using newtype_index macro
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_data_structures/indexed_vec.rs | 3 | ||||
| -rw-r--r-- | src/librustc_mir/build/mod.rs | 14 |
2 files changed, 3 insertions, 14 deletions
diff --git a/src/librustc_data_structures/indexed_vec.rs b/src/librustc_data_structures/indexed_vec.rs index ce2468fb9f1..4b7f55eba06 100644 --- a/src/librustc_data_structures/indexed_vec.rs +++ b/src/librustc_data_structures/indexed_vec.rs @@ -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) } } diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index 68ef646184c..46a5e5abbdd 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -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 |
