]> git.lizzy.rs Git - rust.git/commit
Use `HandleOrNull` and `HandleOrInvalid` in the Windows FFI bindings.
authorDan Gohman <dev@sunfishcode.online>
Thu, 3 Mar 2022 19:07:23 +0000 (11:07 -0800)
committerDan Gohman <dev@sunfishcode.online>
Thu, 3 Mar 2022 19:20:49 +0000 (11:20 -0800)
commit35606490abf83f2bd6c4adddc3b3c13a2a8b783b
tree46637ce27c8e03ce767ef469c157add997a4fc09
parent32cbc7630b2d6b7141e2588f91380c1a58cf0016
Use `HandleOrNull` and `HandleOrInvalid` in the Windows FFI bindings.

Use the new `HandleOrNull` and `HandleOrInvalid` types that were introduced
as part of [I/O safety] in a few functions in the Windows FFI bindings.

This factors out an `unsafe` block and two `unsafe` function calls in the
Windows implementation code.

And, it helps test `HandleOrNull` and `HandleOrInvalid`, which indeed turned
up a bug: `OwnedHandle` also needs to be `#[repr(transparent)]`, as it's
used inside of `HandleOrNull` and `HandleOrInvalid` which are also
`#[repr(transparent)]`.

[I/O safety]: https://github.com/rust-lang/rust/issues/87074
library/std/src/os/windows/io/handle.rs
library/std/src/sys/windows/c.rs
library/std/src/sys/windows/fs.rs
library/std/src/sys/windows/handle.rs
library/std/src/sys/windows/thread.rs