diff options
| author | Nikolai Vazquez <nvazquez1297@gmail.com> | 2017-09-28 10:59:12 -0400 |
|---|---|---|
| committer | Nikolai Vazquez <nvazquez1297@gmail.com> | 2017-09-28 10:59:12 -0400 |
| commit | cb2a656cdfb6400ac0200c661267f91fabf237e2 (patch) | |
| tree | 0292f2e9cc0d872db8ddd74199721699b48332cb /src/libstd/path.rs | |
| parent | c7b4a96909e535cbd61b9357740ed22c9bbb7ea6 (diff) | |
| download | rust-cb2a656cdfb6400ac0200c661267f91fabf237e2.tar.gz rust-cb2a656cdfb6400ac0200c661267f91fabf237e2.zip | |
Fix errors in Box<Path> conversions
Diffstat (limited to 'src/libstd/path.rs')
| -rw-r--r-- | src/libstd/path.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 9003b368ebe..294743ed2cc 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1341,7 +1341,8 @@ impl PathBuf { #[stable(feature = "box_from_path", since = "1.17.0")] impl<'a> From<&'a Path> for Box<Path> { fn from(path: &'a Path) -> Box<Path> { - let rw = Box::into_raw(Box::from(&path.inner)) as *mut Path; + let boxed: Box<OsStr> = path.inner.into(); + let rw = Box::into_raw(boxed) as *mut Path; unsafe { Box::from_raw(rw) } } } @@ -2313,7 +2314,8 @@ impl Path { #[stable(feature = "into_boxed_path", since = "1.20.0")] pub fn into_path_buf(self: Box<Path>) -> PathBuf { let rw = Box::into_raw(self) as *mut OsStr; - unsafe { Box::from_raw(rw) } + let inner = unsafe { Box::from_raw(rw) }; + PathBuf { inner: OsString::from(inner) } } } |
