use rustc::hir::def_id::{DefId, DefIndex};
use rustc_serialize::opaque::Encoder;
+use std::marker::PhantomData;
use std::u32;
use log::debug;
/// `u32::MAX`. Whenever an index is visited, we fill in the
/// appropriate spot by calling `record_position`. We should never
/// visit the same index twice.
-pub struct Index {
+pub struct Index<'tcx> {
positions: Vec<u8>,
+ _marker: PhantomData<&'tcx ()>,
}
-impl Index {
- pub fn new(max_index: usize) -> Index {
+impl Index<'tcx> {
+ pub fn new(max_index: usize) -> Self {
Index {
positions: vec![0xff; max_index * 4],
+ _marker: PhantomData,
}
}
- pub fn record(&mut self, def_id: DefId, entry: Lazy<Entry<'_>>) {
+ pub fn record(&mut self, def_id: DefId, entry: Lazy<Entry<'tcx>>) {
assert!(def_id.is_local());
self.record_index(def_id.index, entry);
}
- pub fn record_index(&mut self, item: DefIndex, entry: Lazy<Entry<'_>>) {
+ pub fn record_index(&mut self, item: DefIndex, entry: Lazy<Entry<'tcx>>) {
assert!(entry.position < (u32::MAX as usize));
let position = entry.position as u32;
let array_index = item.index();
position.write_to_bytes_at(positions, array_index)
}
- pub fn write_index(&self, buf: &mut Encoder) -> LazySeq<Index> {
+ pub fn write_index(&self, buf: &mut Encoder) -> LazySeq<Self> {
let pos = buf.position();
// First we write the length of the lower range ...
}
}
-impl<'tcx> LazySeq<Index> {
+impl LazySeq<Index<'tcx>> {
/// Given the metadata, extract out the offset of a particular
/// DefIndex (if any).
#[inline(never)]