about summary refs log tree commit diff
path: root/compiler/rustc_index/src
diff options
context:
space:
mode:
authorardi <oriongonza@gmail.com>2024-01-10 18:28:42 +0100
committerardi <oriongonza@gmail.com>2024-01-10 18:28:42 +0100
commitee8510e4e13e723639e904cdc218e6f3013f0bb4 (patch)
treeb923ec585b648ac00c64854a5fadfe0241a1d40b /compiler/rustc_index/src
parent1bf3aee3811b92d5833154fd35b98159a233b938 (diff)
downloadrust-ee8510e4e13e723639e904cdc218e6f3013f0bb4.tar.gz
rust-ee8510e4e13e723639e904cdc218e6f3013f0bb4.zip
Fix some mistakes + new doc
Diffstat (limited to 'compiler/rustc_index/src')
-rw-r--r--compiler/rustc_index/src/vec.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/compiler/rustc_index/src/vec.rs b/compiler/rustc_index/src/vec.rs
index 3c66e6dde1c..73265eb8996 100644
--- a/compiler/rustc_index/src/vec.rs
+++ b/compiler/rustc_index/src/vec.rs
@@ -17,15 +17,13 @@ use crate::{Idx, IndexSlice};
 /// While it's possible to use `u32` or `usize` directly for `I`,
 /// you almost certainly want to use a [`newtype_index!`]-generated type instead.
 ///
-/// This allows to index the IndexVec with the new index type
-///
-///
+/// This allows to index the IndexVec with the new index type.
 /// [`newtype_index!`]: ../macro.newtype_index.html
 #[derive(Clone, PartialEq, Eq, Hash)]
 #[repr(transparent)]
 pub struct IndexVec<I: Idx, T> {
     pub raw: Vec<T>,
-    _marker: PhantomData<I>,
+    _marker: PhantomData<fn(&I)>,
 }
 
 impl<I: Idx, T> IndexVec<I, T> {
@@ -35,7 +33,7 @@ impl<I: Idx, T> IndexVec<I, T> {
         IndexVec::from_raw(Vec::new())
     }
 
-    /// Constructs a new `IndexVec<I, T>` from a `Vec<T>`
+    /// Constructs a new `IndexVec<I, T>` from a `Vec<T>`.
     #[inline]
     pub const fn from_raw(raw: Vec<T>) -> Self {
         IndexVec { raw, _marker: PhantomData }
@@ -65,7 +63,7 @@ impl<I: Idx, T> IndexVec<I, T> {
         IndexVec::from_raw(vec![elem; universe.len()])
     }
 
-    /// Creates a new IndexVec
+    /// Creates a new IndexVec with n copies of the `elem`.
     #[inline]
     pub fn from_elem_n(elem: T, n: usize) -> Self
     where
@@ -92,6 +90,7 @@ impl<I: Idx, T> IndexVec<I, T> {
         IndexSlice::from_raw_mut(&mut self.raw)
     }
 
+    /// Pushes an element to the array returning the index where it was pushed to.
     #[inline]
     pub fn push(&mut self, d: T) -> I {
         let idx = self.next_index();