RawVec::into_box: avoid unnecessary intermediate reference

This commit is contained in:
Ralf Jung 2024-03-10 17:12:27 +01:00
parent cdb775cab5
commit 81ebaf27cb
3 changed files with 3 additions and 3 deletions

View File

@ -5,7 +5,6 @@ use core::cmp;
use core::hint;
use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties};
use core::ptr::{self, NonNull, Unique};
use core::slice;
#[cfg(not(no_global_oom_handling))]
use crate::alloc::handle_alloc_error;
@ -192,7 +191,7 @@ impl<T, A: Allocator> RawVec<T, A> {
let me = ManuallyDrop::new(self);
unsafe {
let slice = slice::from_raw_parts_mut(me.ptr() as *mut MaybeUninit<T>, len);
let slice = ptr::slice_from_raw_parts_mut(me.ptr() as *mut MaybeUninit<T>, len);
Box::from_raw_in(slice, ptr::read(&me.alloc))
}
}

View File

@ -1,6 +1,7 @@
//@ run-fail
//@ check-run-results
//@ exec-env:RUST_BACKTRACE=0
//@ normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC"
//
// Regression test for issue #70963
// The captured stderr from this test reports a location

View File

@ -1,3 +1,3 @@
thread 'main' panicked at library/alloc/src/raw_vec.rs:26:5:
thread 'main' panicked at library/alloc/src/raw_vec.rs:LL:CC:
capacity overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace