mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
RawVec::into_box: avoid unnecessary intermediate reference
This commit is contained in:
parent
cdb775cab5
commit
81ebaf27cb
@ -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))
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user