Skip to content

Commit cb2a656

Browse files
committed
Fix errors in Box<Path> conversions
1 parent c7b4a96 commit cb2a656

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/libstd/path.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,8 @@ impl PathBuf {
13411341
#[stable(feature = "box_from_path", since = "1.17.0")]
13421342
impl<'a> From<&'a Path> for Box<Path> {
13431343
fn from(path: &'a Path) -> Box<Path> {
1344-
let rw = Box::into_raw(Box::from(&path.inner)) as *mut Path;
1344+
let boxed: Box<OsStr> = path.inner.into();
1345+
let rw = Box::into_raw(boxed) as *mut Path;
13451346
unsafe { Box::from_raw(rw) }
13461347
}
13471348
}
@@ -2313,7 +2314,8 @@ impl Path {
23132314
#[stable(feature = "into_boxed_path", since = "1.20.0")]
23142315
pub fn into_path_buf(self: Box<Path>) -> PathBuf {
23152316
let rw = Box::into_raw(self) as *mut OsStr;
2316-
unsafe { Box::from_raw(rw) }
2317+
let inner = unsafe { Box::from_raw(rw) };
2318+
PathBuf { inner: OsString::from(inner) }
23172319
}
23182320
}
23192321

0 commit comments

Comments
 (0)