mirror of
https://github.com/rust-lang/rust
synced 2024-07-01 09:10:30 +00:00
Auto merge of #124432 - zetanumbers:non_copy_into_raw_with_alloc, r=Nilstrieb
Some checks failed
CI / Calculate job matrix (push) Failing after 15s
CI / master (push) Has been skipped
CI / bors build finished (push) Has been skipped
CI / ${{ matrix.name }} (push) Has been skipped
Bump dependencies in Cargo.lock / skip if S-waiting-on-bors (push) Has been skipped
Bump dependencies in Cargo.lock / amend PR (push) Has been skipped
Bump dependencies in Cargo.lock / update dependencies (push) Has been skipped
Some checks failed
CI / Calculate job matrix (push) Failing after 15s
CI / master (push) Has been skipped
CI / bors build finished (push) Has been skipped
CI / ${{ matrix.name }} (push) Has been skipped
Bump dependencies in Cargo.lock / skip if S-waiting-on-bors (push) Has been skipped
Bump dependencies in Cargo.lock / amend PR (push) Has been skipped
Bump dependencies in Cargo.lock / update dependencies (push) Has been skipped
Relax `A: Clone` bound for `rc::Weak::into_raw_and_alloc` Makes this method to behave the same way as [`Box::into_raw_with_allocator`](https://doc.rust-lang.org/1.77.2/alloc/boxed/struct.Box.html#method.into_raw_with_allocator) and [`Vec::into_raw_parts_with_alloc`](https://doc.rust-lang.org/1.77.2/alloc/vec/struct.Vec.html#method.into_raw_parts_with_alloc). I have also noticed the inconsistent presence and naming, should probably be addressed in the future.
This commit is contained in:
commit
61a1dbd751
|
@ -3029,13 +3029,10 @@ pub fn into_raw(self) -> *const T {
|
|||
/// [`as_ptr`]: Weak::as_ptr
|
||||
#[inline]
|
||||
#[unstable(feature = "allocator_api", issue = "32838")]
|
||||
pub fn into_raw_and_alloc(self) -> (*const T, A)
|
||||
where
|
||||
A: Clone,
|
||||
{
|
||||
let result = self.as_ptr();
|
||||
let alloc = self.alloc.clone();
|
||||
mem::forget(self);
|
||||
pub fn into_raw_and_alloc(self) -> (*const T, A) {
|
||||
let rc = mem::ManuallyDrop::new(self);
|
||||
let result = rc.as_ptr();
|
||||
let alloc = unsafe { ptr::read(&rc.alloc) };
|
||||
(result, alloc)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user