Access alloc field directly in Arc/Rc::into_raw_with_allocator.

... since fn allocator doesn't exist yet.
This commit is contained in:
Zachary S 2024-05-16 21:09:05 -05:00
parent 28cb2d7dfb
commit c895f6e958
2 changed files with 4 additions and 4 deletions

View File

@ -1379,7 +1379,7 @@ pub fn into_raw_with_allocator(this: Self) -> (*const T, A) {
let this = mem::ManuallyDrop::new(this); let this = mem::ManuallyDrop::new(this);
let ptr = Self::as_ptr(&this); let ptr = Self::as_ptr(&this);
// Safety: `this` is ManuallyDrop so the allocator will not be double-dropped // Safety: `this` is ManuallyDrop so the allocator will not be double-dropped
let alloc = unsafe { ptr::read(Self::allocator(&this)) }; let alloc = unsafe { ptr::read(&this.alloc) };
(ptr, alloc) (ptr, alloc)
} }
@ -3061,7 +3061,7 @@ pub fn into_raw_with_allocator(self) -> (*const T, A) {
let this = mem::ManuallyDrop::new(self); let this = mem::ManuallyDrop::new(self);
let result = this.as_ptr(); let result = this.as_ptr();
// Safety: `this` is ManuallyDrop so the allocator will not be double-dropped // Safety: `this` is ManuallyDrop so the allocator will not be double-dropped
let alloc = unsafe { ptr::read(this.allocator()) }; let alloc = unsafe { ptr::read(&this.alloc) };
(result, alloc) (result, alloc)
} }

View File

@ -1520,7 +1520,7 @@ pub fn into_raw_with_allocator(this: Self) -> (*const T, A) {
let this = mem::ManuallyDrop::new(this); let this = mem::ManuallyDrop::new(this);
let ptr = Self::as_ptr(&this); let ptr = Self::as_ptr(&this);
// Safety: `this` is ManuallyDrop so the allocator will not be double-dropped // Safety: `this` is ManuallyDrop so the allocator will not be double-dropped
let alloc = unsafe { ptr::read(Self::allocator(&this)) }; let alloc = unsafe { ptr::read(&this.alloc) };
(ptr, alloc) (ptr, alloc)
} }
@ -2803,7 +2803,7 @@ pub fn into_raw_with_allocator(self) -> (*const T, A) {
let this = mem::ManuallyDrop::new(self); let this = mem::ManuallyDrop::new(self);
let result = this.as_ptr(); let result = this.as_ptr();
// Safety: `this` is ManuallyDrop so the allocator will not be double-dropped // Safety: `this` is ManuallyDrop so the allocator will not be double-dropped
let alloc = unsafe { ptr::read(Self::allocator(&this)) }; let alloc = unsafe { ptr::read(&this.alloc) };
(result, alloc) (result, alloc)
} }