Skip to content

Commit f4968c8

Browse files
committedJan 11, 2020
Remove SyncTypedArena, SyncDroplessArena and in_arena
1 parent b21c9dd commit f4968c8

File tree

1 file changed

+0
-73
lines changed

1 file changed

+0
-73
lines changed
 

‎src/libarena/lib.rs

-73
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
extern crate alloc;
2222

2323
use rustc_data_structures::cold_path;
24-
use rustc_data_structures::sync::MTLock;
2524
use smallvec::SmallVec;
2625

2726
use std::cell::{Cell, RefCell};
@@ -116,11 +115,6 @@ impl<T> Default for TypedArena<T> {
116115
}
117116

118117
impl<T> TypedArena<T> {
119-
pub fn in_arena(&self, ptr: *const T) -> bool {
120-
let ptr = ptr as *const T as *mut T;
121-
122-
self.chunks.borrow().iter().any(|chunk| chunk.start() <= ptr && ptr < chunk.end())
123-
}
124118
/// Allocates an object in the `TypedArena`, returning a reference to it.
125119
#[inline]
126120
pub fn alloc(&self, object: T) -> &mut T {
@@ -334,12 +328,6 @@ impl Default for DroplessArena {
334328
}
335329

336330
impl DroplessArena {
337-
pub fn in_arena<T: ?Sized>(&self, ptr: *const T) -> bool {
338-
let ptr = ptr as *const u8 as *mut u8;
339-
340-
self.chunks.borrow().iter().any(|chunk| chunk.start() <= ptr && ptr < chunk.end())
341-
}
342-
343331
#[inline]
344332
fn align(&self, align: usize) {
345333
let final_address = ((self.ptr.get() as usize) + align - 1) & !(align - 1);
@@ -500,66 +488,5 @@ impl DroplessArena {
500488
}
501489
}
502490

503-
#[derive(Default)]
504-
// FIXME(@Zoxc): this type is entirely unused in rustc
505-
pub struct SyncTypedArena<T> {
506-
lock: MTLock<TypedArena<T>>,
507-
}
508-
509-
impl<T> SyncTypedArena<T> {
510-
#[inline(always)]
511-
pub fn alloc(&self, object: T) -> &mut T {
512-
// Extend the lifetime of the result since it's limited to the lock guard
513-
unsafe { &mut *(self.lock.lock().alloc(object) as *mut T) }
514-
}
515-
516-
#[inline(always)]
517-
pub fn alloc_slice(&self, slice: &[T]) -> &mut [T]
518-
where
519-
T: Copy,
520-
{
521-
// Extend the lifetime of the result since it's limited to the lock guard
522-
unsafe { &mut *(self.lock.lock().alloc_slice(slice) as *mut [T]) }
523-
}
524-
525-
#[inline(always)]
526-
pub fn clear(&mut self) {
527-
self.lock.get_mut().clear();
528-
}
529-
}
530-
531-
#[derive(Default)]
532-
pub struct SyncDroplessArena {
533-
lock: MTLock<DroplessArena>,
534-
}
535-
536-
impl SyncDroplessArena {
537-
#[inline(always)]
538-
pub fn in_arena<T: ?Sized>(&self, ptr: *const T) -> bool {
539-
self.lock.lock().in_arena(ptr)
540-
}
541-
542-
#[inline(always)]
543-
pub fn alloc_raw(&self, bytes: usize, align: usize) -> &mut [u8] {
544-
// Extend the lifetime of the result since it's limited to the lock guard
545-
unsafe { &mut *(self.lock.lock().alloc_raw(bytes, align) as *mut [u8]) }
546-
}
547-
548-
#[inline(always)]
549-
pub fn alloc<T>(&self, object: T) -> &mut T {
550-
// Extend the lifetime of the result since it's limited to the lock guard
551-
unsafe { &mut *(self.lock.lock().alloc(object) as *mut T) }
552-
}
553-
554-
#[inline(always)]
555-
pub fn alloc_slice<T>(&self, slice: &[T]) -> &mut [T]
556-
where
557-
T: Copy,
558-
{
559-
// Extend the lifetime of the result since it's limited to the lock guard
560-
unsafe { &mut *(self.lock.lock().alloc_slice(slice) as *mut [T]) }
561-
}
562-
}
563-
564491
#[cfg(test)]
565492
mod tests;

0 commit comments

Comments
 (0)
Please sign in to comment.