Skip to content
/ rust Public
forked from rust-lang/rust

Commit 81ebaf2

Browse files
committed
RawVec::into_box: avoid unnecessary intermediate reference
1 parent cdb775c commit 81ebaf2

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

library/alloc/src/raw_vec.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use core::cmp;
55
use core::hint;
66
use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties};
77
use core::ptr::{self, NonNull, Unique};
8-
use core::slice;
98

109
#[cfg(not(no_global_oom_handling))]
1110
use crate::alloc::handle_alloc_error;
@@ -192,7 +191,7 @@ impl<T, A: Allocator> RawVec<T, A> {
192191

193192
let me = ManuallyDrop::new(self);
194193
unsafe {
195-
let slice = slice::from_raw_parts_mut(me.ptr() as *mut MaybeUninit<T>, len);
194+
let slice = ptr::slice_from_raw_parts_mut(me.ptr() as *mut MaybeUninit<T>, len);
196195
Box::from_raw_in(slice, ptr::read(&me.alloc))
197196
}
198197
}

tests/ui/hygiene/panic-location.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ run-fail
22
//@ check-run-results
33
//@ exec-env:RUST_BACKTRACE=0
4+
//@ normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC"
45
//
56
// Regression test for issue #70963
67
// The captured stderr from this test reports a location
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
thread 'main' panicked at library/alloc/src/raw_vec.rs:26:5:
1+
thread 'main' panicked at library/alloc/src/raw_vec.rs:LL:CC:
22
capacity overflow
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

0 commit comments

Comments
 (0)