Skip to content

Commit bea4966

Browse files
committed
Move newtype_index to rustc_data_structures
1 parent a6c107c commit bea4966

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

src/librustc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ extern crate graphviz;
7171
extern crate libc;
7272
extern crate owning_ref;
7373
extern crate rustc_back;
74-
extern crate rustc_data_structures;
74+
#[macro_use] extern crate rustc_data_structures;
7575
extern crate serialize;
7676
extern crate rustc_const_math;
7777
extern crate rustc_errors as errors;

src/librustc/mir/mod.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,6 @@ pub mod visit;
4343
pub mod transform;
4444
pub mod traversal;
4545

46-
macro_rules! newtype_index {
47-
($name:ident, $debug_name:expr) => (
48-
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord,
49-
RustcEncodable, RustcDecodable)]
50-
pub struct $name(u32);
51-
52-
impl Idx for $name {
53-
fn new(value: usize) -> Self {
54-
assert!(value < (u32::MAX) as usize);
55-
$name(value as u32)
56-
}
57-
fn index(self) -> usize {
58-
self.0 as usize
59-
}
60-
}
61-
62-
impl Debug for $name {
63-
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
64-
write!(fmt, "{}{}", $debug_name, self.0)
65-
}
66-
}
67-
)
68-
}
69-
7046
/// Types for locals
7147
type LocalDecls<'tcx> = IndexVec<Local, LocalDecl<'tcx>>;
7248

src/librustc_data_structures/indexed_vec.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,31 @@ impl Idx for u32 {
3838
fn index(self) -> usize { self as usize }
3939
}
4040

41+
#[macro_export]
42+
macro_rules! newtype_index {
43+
($name:ident, $debug_name:expr) => (
44+
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord,
45+
RustcEncodable, RustcDecodable)]
46+
pub struct $name(u32);
47+
48+
impl Idx for $name {
49+
fn new(value: usize) -> Self {
50+
assert!(value < (u32::MAX) as usize);
51+
$name(value as u32)
52+
}
53+
fn index(self) -> usize {
54+
self.0 as usize
55+
}
56+
}
57+
58+
impl Debug for $name {
59+
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
60+
write!(fmt, "{}{}", $debug_name, self.0)
61+
}
62+
}
63+
)
64+
}
65+
4166
#[derive(Clone, PartialEq, Eq)]
4267
pub struct IndexVec<I: Idx, T> {
4368
pub raw: Vec<T>,

0 commit comments

Comments
 (0)