Generate DepNodeIndexNew using newtype_index macro

This commit is contained in:
Santiago Pastorino 2017-09-28 15:56:28 -03:00
parent 3502bec032
commit b5a5556dd4
4 changed files with 10 additions and 1 deletions

View File

@ -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());

View File

@ -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))]

View File

@ -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);

View File

@ -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)]