diff options
| author | Zachary S <zasample18+github@gmail.com> | 2024-05-16 21:09:05 -0500 |
|---|---|---|
| committer | Zachary S <zasample18+github@gmail.com> | 2024-05-16 21:09:05 -0500 |
| commit | c895f6e958ee34f6c52b612156e70465d18bd81a (patch) | |
| tree | 9dcd7e4f1d183fb0ab54a8a320cb8b5447bed043 | |
| parent | 28cb2d7dfb155ccb204f4d9a60af0e3460e59f5f (diff) | |
| download | rust-c895f6e958ee34f6c52b612156e70465d18bd81a.tar.gz rust-c895f6e958ee34f6c52b612156e70465d18bd81a.zip | |
Access alloc field directly in Arc/Rc::into_raw_with_allocator.
... since fn allocator doesn't exist yet.
| -rw-r--r-- | library/alloc/src/rc.rs | 4 | ||||
| -rw-r--r-- | 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 @@ impl<T: ?Sized, A: Allocator> Rc<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 @@ impl<T: ?Sized, A: Allocator> Weak<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 @@ impl<T: ?Sized, A: Allocator> Arc<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 @@ impl<T: ?Sized, A: Allocator> Weak<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) } |
