Skip to content

Commit 92b7a45

Browse files
committed
auto merge of #6488 : sammykim/rust/issue-6430, r=sanxiyn
Fix issue #6430.
2 parents 62caa1e + f097f43 commit 92b7a45

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/libcore/vec.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2546,23 +2546,29 @@ pub mod raw {
25462546
* would also make any pointers to it invalid.
25472547
*/
25482548
#[inline(always)]
2549-
pub unsafe fn to_ptr<T>(v: &[T]) -> *T {
2550-
let repr: **SliceRepr = transmute(&v);
2551-
transmute(&((**repr).data))
2549+
pub fn to_ptr<T>(v: &[T]) -> *T {
2550+
unsafe {
2551+
let repr: **SliceRepr = transmute(&v);
2552+
transmute(&((**repr).data))
2553+
}
25522554
}
25532555

25542556
/** see `to_ptr()` */
25552557
#[inline(always)]
2556-
pub unsafe fn to_const_ptr<T>(v: &const [T]) -> *const T {
2557-
let repr: **SliceRepr = transmute(&v);
2558-
transmute(&((**repr).data))
2558+
pub fn to_const_ptr<T>(v: &const [T]) -> *const T {
2559+
unsafe {
2560+
let repr: **SliceRepr = transmute(&v);
2561+
transmute(&((**repr).data))
2562+
}
25592563
}
25602564

25612565
/** see `to_ptr()` */
25622566
#[inline(always)]
2563-
pub unsafe fn to_mut_ptr<T>(v: &mut [T]) -> *mut T {
2564-
let repr: **SliceRepr = transmute(&v);
2565-
transmute(&((**repr).data))
2567+
pub fn to_mut_ptr<T>(v: &mut [T]) -> *mut T {
2568+
unsafe {
2569+
let repr: **SliceRepr = transmute(&v);
2570+
transmute(&((**repr).data))
2571+
}
25662572
}
25672573

25682574
/**

0 commit comments

Comments
 (0)