diff options
Diffstat (limited to 'compiler/rustc_arena/src/lib.rs')
| -rw-r--r-- | compiler/rustc_arena/src/lib.rs | 13 |
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. /// |
