about summary refs log tree commit diff
path: root/library/alloc
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2024-03-11 03:47:21 -0400
committerGitHub <noreply@github.com>2024-03-11 03:47:21 -0400
commiteb1ebbfc923eca5f9d9def8d28bf54169b7c3169 (patch)
tree1dd819e79338a4c6aa742e67a60c5d32aec07d52 /library/alloc
parent9b30f01c0c63a28c81b84409dc07d5f6af50d482 (diff)
parenta7443f554215b76ef1f911b1d6d07b4b7ebbb23c (diff)
downloadrust-eb1ebbfc923eca5f9d9def8d28bf54169b7c3169.tar.gz
rust-eb1ebbfc923eca5f9d9def8d28bf54169b7c3169.zip
Rollup merge of #122298 - RalfJung:raw-vec-into-box, r=cuviper
RawVec::into_box: avoid unnecessary intermediate reference

Fixes the problem described [here](https://github.com/rust-lang/miri/issues/3341#issuecomment-1987207195).
Diffstat (limited to 'library/alloc')
-rw-r--r--library/alloc/src/raw_vec.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/library/alloc/src/raw_vec.rs b/library/alloc/src/raw_vec.rs
index ace73c0fdaa..0ee293db73a 100644
--- a/library/alloc/src/raw_vec.rs
+++ b/library/alloc/src/raw_vec.rs
@@ -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))
         }
     }