]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_metadata/index.rs
Rollup merge of #61409 - varkor:condition-trait-param-ice, r=oli-obk
[rust.git] / src / librustc_metadata / index.rs
index 934e871559c79939010ffb30377007afc5b96ba6..dd2f59922ef9238ca34d6276dce219ab8fed9f03 100644 (file)
@@ -2,6 +2,7 @@
 
 use rustc::hir::def_id::{DefId, DefIndex};
 use rustc_serialize::opaque::Encoder;
+use std::marker::PhantomData;
 use std::u32;
 use log::debug;
 
@@ -74,23 +75,25 @@ fn write_to_bytes(self, b: &mut [u8]) {
 /// `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();
@@ -105,7 +108,7 @@ pub fn record_index(&mut self, item: DefIndex, entry: Lazy<Entry<'_>>) {
         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 ...
@@ -116,7 +119,7 @@ pub fn write_index(&self, buf: &mut Encoder) -> LazySeq<Index> {
     }
 }
 
-impl<'tcx> LazySeq<Index> {
+impl LazySeq<Index<'tcx>> {
     /// Given the metadata, extract out the offset of a particular
     /// DefIndex (if any).
     #[inline(never)]