Skip to content

Commit e266c0f

Browse files
committed
Generate Idx in nll using newtype_index!
1 parent bea4966 commit e266c0f

File tree

4 files changed

+7
-16
lines changed

4 files changed

+7
-16
lines changed

src/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/librustc_mir/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ rustc_const_eval = { path = "../librustc_const_eval" }
1717
rustc_const_math = { path = "../librustc_const_math" }
1818
rustc_data_structures = { path = "../librustc_data_structures" }
1919
rustc_errors = { path = "../librustc_errors" }
20+
serialize = { path = "../libserialize" }
2021
syntax = { path = "../libsyntax" }
2122
syntax_pos = { path = "../libsyntax_pos" }

src/librustc_mir/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ extern crate bitflags;
3030
extern crate graphviz as dot;
3131
#[macro_use]
3232
extern crate rustc;
33-
extern crate rustc_data_structures;
33+
#[macro_use] extern crate rustc_data_structures;
34+
extern crate serialize as rustc_serialize;
3435
extern crate rustc_errors;
3536
#[macro_use]
3637
extern crate syntax;

src/librustc_mir/transform/nll.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use rustc::util::nodemap::FxHashSet;
1919
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
2020
use syntax_pos::DUMMY_SP;
2121
use std::collections::HashMap;
22+
use std::fmt::{self, Debug, Formatter};
23+
use std::u32;
2224

2325
#[allow(dead_code)]
2426
struct NLLVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
@@ -155,18 +157,4 @@ struct Region {
155157
points: FxHashSet<Location>,
156158
}
157159

158-
#[derive(Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd, Debug)]
159-
pub struct RegionIndex(pub u32);
160-
161-
impl Idx for RegionIndex {
162-
#[inline]
163-
fn new(idx: usize) -> Self {
164-
assert!(idx <= ::std::u32::MAX as usize);
165-
RegionIndex(idx as u32)
166-
}
167-
168-
#[inline]
169-
fn index(self) -> usize {
170-
self.0 as usize
171-
}
172-
}
160+
newtype_index!(RegionIndex, "region_index");

0 commit comments

Comments
 (0)