Use ManuallyDrop instead of forget

This commit is contained in:
Jakub Konka
2019-06-29 11:21:48 +02:00
committed by Dan Gohman
parent 7287767a3f
commit b4280d6cd6

View File

@@ -79,10 +79,9 @@ pub unsafe fn determine_type_rights(
host::__wasi_errno_t, host::__wasi_errno_t,
> { > {
let (ty, rights_base, rights_inheriting) = { let (ty, rights_base, rights_inheriting) = {
let file = File::from_raw_fd(rawfd);
let ft = file.metadata().unwrap().file_type();
// we just make a `File` here for convenience; we don't want it to close when it drops // we just make a `File` here for convenience; we don't want it to close when it drops
std::mem::forget(file); let file = std::mem::ManuallyDrop::new(File::from_raw_fd(rawfd));
let ft = file.metadata().unwrap().file_type();
if ft.is_block_device() { if ft.is_block_device() {
( (
host::__WASI_FILETYPE_BLOCK_DEVICE, host::__WASI_FILETYPE_BLOCK_DEVICE,