about summary refs log tree commit diff
path: root/compiler/rustc_index/src
diff options
context:
space:
mode:
authorLiu Dingming <liudingming@bytedance.com>2024-07-04 04:52:01 +0800
committerLiu Dingming <liudingming@bytedance.com>2024-07-04 05:09:23 +0800
commita9194f30eb5b80bd659f3f8e8357fd19b771063e (patch)
tree8cf288b4c5f98aec114c362f70c90d8e562ba04a /compiler/rustc_index/src
parent2db4ff40af2b9f93b6240dbd67ed7f2f34b19776 (diff)
Use `IndexVec` for coroutine local mapping
Diffstat (limited to 'compiler/rustc_index/src')
-rw-r--r--compiler/rustc_index/src/vec.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_index/src/vec.rs b/compiler/rustc_index/src/vec.rs
index 88298150a79..b866c8b8433 100644
--- a/compiler/rustc_index/src/vec.rs
+++ b/compiler/rustc_index/src/vec.rs
@@ -208,6 +208,11 @@ impl<I: Idx, T> IndexVec<I, Option<T>> {
     pub fn remove(&mut self, index: I) -> Option<T> {
         self.get_mut(index)?.take()
     }
+
+    #[inline]
+    pub fn contains(&self, index: I) -> bool {
+        self.get(index).and_then(Option::as_ref).is_some()
+    }
 }
 
 impl<I: Idx, T: fmt::Debug> fmt::Debug for IndexVec<I, T> {