@@ -2,6 +2,7 @@ use crate::schema::*;
22
33use rustc:: hir:: def_id:: { DefId , DefIndex , DefIndexAddressSpace } ;
44use rustc_serialize:: opaque:: Encoder ;
5+ use std:: marker:: PhantomData ;
56use std:: u32;
67use log:: debug;
78
@@ -12,24 +13,26 @@ use log::debug;
1213/// `u32::MAX`. Whenever an index is visited, we fill in the
1314/// appropriate spot by calling `record_position`. We should never
1415/// visit the same index twice.
15- pub struct Index {
16- positions : [ Vec < u8 > ; 2 ]
16+ pub struct Index < ' tcx > {
17+ positions : [ Vec < u8 > ; 2 ] ,
18+ _marker : PhantomData < & ' tcx ( ) > ,
1719}
1820
19- impl Index {
20- pub fn new ( ( max_index_lo, max_index_hi) : ( usize , usize ) ) -> Index {
21+ impl Index < ' tcx > {
22+ pub fn new ( ( max_index_lo, max_index_hi) : ( usize , usize ) ) -> Self {
2123 Index {
2224 positions : [ vec ! [ 0xff ; max_index_lo * 4 ] ,
2325 vec ! [ 0xff ; max_index_hi * 4 ] ] ,
26+ _marker : PhantomData ,
2427 }
2528 }
2629
27- pub fn record ( & mut self , def_id : DefId , entry : Lazy < Entry < ' _ > > ) {
30+ pub fn record ( & mut self , def_id : DefId , entry : Lazy < Entry < ' tcx > > ) {
2831 assert ! ( def_id. is_local( ) ) ;
2932 self . record_index ( def_id. index , entry) ;
3033 }
3134
32- pub fn record_index ( & mut self , item : DefIndex , entry : Lazy < Entry < ' _ > > ) {
35+ pub fn record_index ( & mut self , item : DefIndex , entry : Lazy < Entry < ' tcx > > ) {
3336 assert ! ( entry. position < ( u32 :: MAX as usize ) ) ;
3437 let position = entry. position as u32 ;
3538 let space_index = item. address_space ( ) . index ( ) ;
@@ -45,7 +48,7 @@ impl Index {
4548 write_le_u32 ( destination, position) ;
4649 }
4750
48- pub fn write_index ( & self , buf : & mut Encoder ) -> LazySeq < Index > {
51+ pub fn write_index ( & self , buf : & mut Encoder ) -> LazySeq < Self > {
4952 let pos = buf. position ( ) ;
5053
5154 // First we write the length of the lower range ...
@@ -59,7 +62,7 @@ impl Index {
5962 }
6063}
6164
62- impl < ' tcx > LazySeq < Index > {
65+ impl LazySeq < Index < ' tcx > > {
6366 /// Given the metadata, extract out the offset of a particular
6467 /// DefIndex (if any).
6568 #[ inline( never) ]
0 commit comments