From c895f6e958ee34f6c52b612156e70465d18bd81a Mon Sep 17 00:00:00 2001 From: Zachary S Date: Thu, 16 May 2024 21:09:05 -0500 Subject: [PATCH] Access alloc field directly in Arc/Rc::into_raw_with_allocator. ... since fn allocator doesn't exist yet. --- library/alloc/src/rc.rs | 4 ++-- library/alloc/src/sync.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index de7b36c922c..18fb1e24f22 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -1379,7 +1379,7 @@ pub fn into_raw_with_allocator(this: Self) -> (*const T, A) { let this = mem::ManuallyDrop::new(this); let ptr = Self::as_ptr(&this); // 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) } @@ -3061,7 +3061,7 @@ pub fn into_raw_with_allocator(self) -> (*const T, A) { let this = mem::ManuallyDrop::new(self); let result = this.as_ptr(); // 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) } diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 0df94e9e2ca..d4b7be8762c 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -1520,7 +1520,7 @@ pub fn into_raw_with_allocator(this: Self) -> (*const T, A) { let this = mem::ManuallyDrop::new(this); let ptr = Self::as_ptr(&this); // 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) } @@ -2803,7 +2803,7 @@ pub fn into_raw_with_allocator(self) -> (*const T, A) { let this = mem::ManuallyDrop::new(self); let result = this.as_ptr(); // 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) }