@@ -16,13 +16,14 @@ use rustc::mir::visit::{MutVisitor, Lookup};
16
16
use rustc:: mir:: transform:: { MirPass , MirSource } ;
17
17
use rustc:: infer:: { self , InferCtxt } ;
18
18
use rustc:: util:: nodemap:: FxHashSet ;
19
+ use rustc_data_structures:: indexed_vec:: { IndexVec , Idx } ;
19
20
use syntax_pos:: DUMMY_SP ;
20
21
use std:: collections:: HashMap ;
21
22
22
23
#[ allow( dead_code) ]
23
24
struct NLLVisitor < ' a , ' gcx : ' a + ' tcx , ' tcx : ' a > {
24
25
lookup_map : HashMap < RegionVid , Lookup > ,
25
- regions : Vec < Region > ,
26
+ regions : IndexVec < RegionIndex , Region > ,
26
27
infcx : InferCtxt < ' a , ' gcx , ' tcx > ,
27
28
}
28
29
@@ -31,7 +32,7 @@ impl<'a, 'gcx, 'tcx> NLLVisitor<'a, 'gcx, 'tcx> {
31
32
NLLVisitor {
32
33
infcx,
33
34
lookup_map : HashMap :: new ( ) ,
34
- regions : vec ! [ ] ,
35
+ regions : IndexVec :: new ( ) ,
35
36
}
36
37
}
37
38
@@ -153,3 +154,19 @@ impl MirPass for NLL {
153
154
struct Region {
154
155
points : FxHashSet < Location > ,
155
156
}
157
+
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
+ }
0 commit comments