diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2017-09-28 15:56:28 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2017-10-04 23:51:43 -0300 |
| commit | b5a5556dd4807ee97cb51ab395d5dbfc858152dd (patch) | |
| tree | 8f475d81149f5da2acb3dfe496af7b33d05af6a9 /src | |
| parent | 3502bec0322829d8bbe61b65c62bb796814e4bd3 (diff) | |
| download | rust-b5a5556dd4807ee97cb51ab395d5dbfc858152dd.tar.gz rust-b5a5556dd4807ee97cb51ab395d5dbfc858152dd.zip | |
Generate DepNodeIndexNew using newtype_index macro
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/dep_graph/graph.rs | 2 | ||||
| -rw-r--r-- | src/librustc/lib.rs | 1 | ||||
| -rw-r--r-- | src/librustc_data_structures/indexed_vec.rs | 7 | ||||
| -rw-r--r-- | src/librustc_mir/lib.rs | 1 |
4 files changed, 10 insertions, 1 deletions
diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 2d2558fd815..5057b1c6065 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -406,7 +406,7 @@ impl DepGraph { for (current_dep_node_index, edges) in current_dep_graph.edges.iter_enumerated() { let start = edge_list_data.len() as u32; // This should really just be a memcpy :/ - edge_list_data.extend(edges.iter().map(|i| SerializedDepNodeIndex(i.index))); + edge_list_data.extend(edges.iter().map(|i| SerializedDepNodeIndex(i.index() as u32))); let end = edge_list_data.len() as u32; debug_assert_eq!(current_dep_node_index.index(), edge_list_indices.len()); diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 3322142c9cf..015dbbb7aff 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -43,6 +43,7 @@ #![feature(box_patterns)] #![feature(box_syntax)] #![feature(conservative_impl_trait)] +#![feature(const_fn)] #![feature(core_intrinsics)] #![feature(i128_type)] #![cfg_attr(windows, feature(libc))] diff --git a/src/librustc_data_structures/indexed_vec.rs b/src/librustc_data_structures/indexed_vec.rs index 82882f94440..ce2468fb9f1 100644 --- a/src/librustc_data_structures/indexed_vec.rs +++ b/src/librustc_data_structures/indexed_vec.rs @@ -49,6 +49,13 @@ macro_rules! newtype_index { RustcEncodable, RustcDecodable)] pub struct $name(u32); + impl $name { + // HACK use for constants + pub const fn const_new(x: u32) -> Self { + $name(x) + } + } + impl Idx for $name { fn new(value: usize) -> Self { assert!(value < (::std::u32::MAX) as usize); diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 3339e7a2c30..7e4206e14c5 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -18,6 +18,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![feature(box_patterns)] #![feature(box_syntax)] +#![feature(const_fn)] #![feature(core_intrinsics)] #![feature(i128_type)] #![feature(rustc_diagnostic_macros)] |
