diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2017-09-27 19:47:41 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2017-10-04 23:50:53 -0300 |
| commit | 3d230af80b01ebe62d27de8436832d0e7ab9ed94 (patch) | |
| tree | 9ccd8e970d32be3baa66a3cd8c687e7dedb3198a /src | |
| parent | f5cef21569115d41171114ec07bb144a3875afc3 (diff) | |
| download | rust-3d230af80b01ebe62d27de8436832d0e7ab9ed94.tar.gz rust-3d230af80b01ebe62d27de8436832d0e7ab9ed94.zip | |
Move newtype_index to rustc_data_structures
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/lib.rs | 2 | ||||
| -rw-r--r-- | src/librustc/mir/mod.rs | 24 | ||||
| -rw-r--r-- | src/librustc_data_structures/indexed_vec.rs | 25 |
3 files changed, 26 insertions, 25 deletions
diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 1e90aa47267..3322142c9cf 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -71,7 +71,7 @@ extern crate graphviz; extern crate libc; extern crate owning_ref; extern crate rustc_back; -extern crate rustc_data_structures; +#[macro_use] extern crate rustc_data_structures; extern crate serialize; extern crate rustc_const_math; extern crate rustc_errors as errors; diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index ba221ef6ae1..b909269e153 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -43,30 +43,6 @@ pub mod visit; pub mod transform; pub mod traversal; -macro_rules! newtype_index { - ($name:ident, $debug_name:expr) => ( - #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, - RustcEncodable, RustcDecodable)] - pub struct $name(u32); - - impl Idx for $name { - fn new(value: usize) -> Self { - assert!(value < (u32::MAX) as usize); - $name(value as u32) - } - fn index(self) -> usize { - self.0 as usize - } - } - - impl Debug for $name { - fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { - write!(fmt, "{}{}", $debug_name, self.0) - } - } - ) -} - /// Types for locals type LocalDecls<'tcx> = IndexVec<Local, LocalDecl<'tcx>>; diff --git a/src/librustc_data_structures/indexed_vec.rs b/src/librustc_data_structures/indexed_vec.rs index 1d0e88ee328..7674018075c 100644 --- a/src/librustc_data_structures/indexed_vec.rs +++ b/src/librustc_data_structures/indexed_vec.rs @@ -38,6 +38,31 @@ impl Idx for u32 { fn index(self) -> usize { self as usize } } +#[macro_export] +macro_rules! newtype_index { + ($name:ident, $debug_name:expr) => ( + #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, + RustcEncodable, RustcDecodable)] + pub struct $name(u32); + + impl Idx for $name { + fn new(value: usize) -> Self { + assert!(value < (u32::MAX) as usize); + $name(value as u32) + } + fn index(self) -> usize { + self.0 as usize + } + } + + impl Debug for $name { + fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { + write!(fmt, "{}{}", $debug_name, self.0) + } + } + ) +} + #[derive(Clone, PartialEq, Eq)] pub struct IndexVec<I: Idx, T> { pub raw: Vec<T>, |
