Skip to content

Commit b5a5556

Browse files
committed
Generate DepNodeIndexNew using newtype_index macro
1 parent 3502bec commit b5a5556

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

src/librustc/dep_graph/graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ impl DepGraph {
406406
for (current_dep_node_index, edges) in current_dep_graph.edges.iter_enumerated() {
407407
let start = edge_list_data.len() as u32;
408408
// This should really just be a memcpy :/
409-
edge_list_data.extend(edges.iter().map(|i| SerializedDepNodeIndex(i.index)));
409+
edge_list_data.extend(edges.iter().map(|i| SerializedDepNodeIndex(i.index() as u32)));
410410
let end = edge_list_data.len() as u32;
411411

412412
debug_assert_eq!(current_dep_node_index.index(), edge_list_indices.len());

src/librustc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#![feature(box_patterns)]
4444
#![feature(box_syntax)]
4545
#![feature(conservative_impl_trait)]
46+
#![feature(const_fn)]
4647
#![feature(core_intrinsics)]
4748
#![feature(i128_type)]
4849
#![cfg_attr(windows, feature(libc))]

src/librustc_data_structures/indexed_vec.rs

+7
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ macro_rules! newtype_index {
4949
RustcEncodable, RustcDecodable)]
5050
pub struct $name(u32);
5151

52+
impl $name {
53+
// HACK use for constants
54+
pub const fn const_new(x: u32) -> Self {
55+
$name(x)
56+
}
57+
}
58+
5259
impl Idx for $name {
5360
fn new(value: usize) -> Self {
5461
assert!(value < (::std::u32::MAX) as usize);

src/librustc_mir/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
1818

1919
#![feature(box_patterns)]
2020
#![feature(box_syntax)]
21+
#![feature(const_fn)]
2122
#![feature(core_intrinsics)]
2223
#![feature(i128_type)]
2324
#![feature(rustc_diagnostic_macros)]

0 commit comments

Comments
 (0)