@@ -317,10 +317,10 @@ fn iter_after<A, I, J>(mut iter: I, mut prefix: J) -> Option<I>
317
317
318
318
// See note at the top of this module to understand why these are used:
319
319
fn os_str_as_u8_slice ( s : & OsStr ) -> & [ u8 ] {
320
- unsafe { mem :: transmute ( s ) }
320
+ unsafe { & * ( s as * const OsStr as * const [ u8 ] ) }
321
321
}
322
322
unsafe fn u8_slice_as_os_str ( s : & [ u8 ] ) -> & OsStr {
323
- mem :: transmute ( s )
323
+ & * ( s as * const [ u8 ] as * const OsStr )
324
324
}
325
325
326
326
// Detect scheme on Redox
@@ -1334,15 +1334,16 @@ impl PathBuf {
1334
1334
/// [`Path`]: struct.Path.html
1335
1335
#[ stable( feature = "into_boxed_path" , since = "1.20.0" ) ]
1336
1336
pub fn into_boxed_path ( self ) -> Box < Path > {
1337
- unsafe { mem:: transmute ( self . inner . into_boxed_os_str ( ) ) }
1337
+ let rw = Box :: into_raw ( self . inner . into_boxed_os_str ( ) ) as * mut Path ;
1338
+ unsafe { Box :: from_raw ( rw) }
1338
1339
}
1339
1340
}
1340
1341
1341
1342
#[ stable( feature = "box_from_path" , since = "1.17.0" ) ]
1342
1343
impl < ' a > From < & ' a Path > for Box < Path > {
1343
1344
fn from ( path : & ' a Path ) -> Box < Path > {
1344
- let boxed : Box < OsStr > = path. inner . into ( ) ;
1345
- unsafe { mem :: transmute ( boxed ) }
1345
+ let rw = Box :: into_raw ( Box :: from ( & path. inner ) ) as * mut Path ;
1346
+ unsafe { Box :: from_raw ( rw ) }
1346
1347
}
1347
1348
}
1348
1349
@@ -1589,7 +1590,7 @@ impl Path {
1589
1590
/// ```
1590
1591
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1591
1592
pub fn new < S : AsRef < OsStr > + ?Sized > ( s : & S ) -> & Path {
1592
- unsafe { mem :: transmute ( s. as_ref ( ) ) }
1593
+ unsafe { & * ( s. as_ref ( ) as * const OsStr as * const Path ) }
1593
1594
}
1594
1595
1595
1596
/// Yields the underlying [`OsStr`] slice.
@@ -2312,8 +2313,8 @@ impl Path {
2312
2313
/// [`PathBuf`]: struct.PathBuf.html
2313
2314
#[ stable( feature = "into_boxed_path" , since = "1.20.0" ) ]
2314
2315
pub fn into_path_buf ( self : Box < Path > ) -> PathBuf {
2315
- let inner : Box < OsStr > = unsafe { mem :: transmute ( self ) } ;
2316
- PathBuf { inner : OsString :: from ( inner ) }
2316
+ let rw = Box :: into_raw ( self ) as * mut OsStr ;
2317
+ unsafe { Box :: from_raw ( rw ) }
2317
2318
}
2318
2319
}
2319
2320
0 commit comments