about summary refs log tree commit diff
path: root/compiler/rustc_arena
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-01-19 09:42:51 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-01-19 09:42:51 +0000
commit61361c16aac632367c0137ce74f6d3248edd8932 (patch)
treec691de5ba8611b18d0a2eaec605ec7570fd78c04 /compiler/rustc_arena
parent06a9dbe5e80c55b20f79aac6d32ad7a81cf544d2 (diff)
downloadrust-61361c16aac632367c0137ce74f6d3248edd8932.tar.gz
rust-61361c16aac632367c0137ce74f6d3248edd8932.zip
Fix `Stable` trait and its impls to work with the new `with_tables`
Diffstat (limited to 'compiler/rustc_arena')
-rw-r--r--compiler/rustc_arena/src/lib.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs
index 621516af9c0..90ddeec4bc7 100644
--- a/compiler/rustc_arena/src/lib.rs
+++ b/compiler/rustc_arena/src/lib.rs
@@ -484,6 +484,19 @@ impl DroplessArena {
         }
     }
 
+    /// Used by `Lift` to check whether this slice is allocated
+    /// in this arena.
+    #[inline]
+    pub fn contains_slice<T>(&self, slice: &[T]) -> bool {
+        for chunk in self.chunks.borrow_mut().iter_mut() {
+            let ptr = slice.as_ptr().cast::<u8>().cast_mut();
+            if chunk.start() <= ptr && chunk.end() >= ptr {
+                return true;
+            }
+        }
+        false
+    }
+
     /// Allocates a string slice that is copied into the `DroplessArena`, returning a
     /// reference to it. Will panic if passed an empty string.
     ///