about summary refs log tree commit diff
path: root/library/std/src/os/windows/io/socket.rs
diff options
context:
space:
mode:
authorDan Gohman <dev@sunfishcode.online>2022-05-11 07:17:52 -0700
committerDan Gohman <dev@sunfishcode.online>2022-05-11 07:26:49 -0700
commit90ff6fcd4ec4a91b9d0a4956d3fd8459931f2de4 (patch)
tree1658c667bcc8a8245c9d24d591cbc4c74e35fb11 /library/std/src/os/windows/io/socket.rs
parentecd44958e0a21110d09862ee080d95a4ca6c52f8 (diff)
downloadrust-90ff6fcd4ec4a91b9d0a4956d3fd8459931f2de4.tar.gz
rust-90ff6fcd4ec4a91b9d0a4956d3fd8459931f2de4.zip
Add rustc_nonnull_optimization_guaranteed to Owned/Borrowed Fd/Socket
PR #94586 added support for using
`rustc_nonnull_optimization_guaranteed` on values where the "null" value
is the all-ones bitpattern.

Now that #94586 has made it to the stage0 compiler, add
`rustc_nonnull_optimization_guaranteed` to `OwnedFd`, `BorrowedFd`,
`OwnedSocket`, and `BorrowedSocket`, since these types all exclude
all-ones bitpatterns.

This allows `Option<OwnedFd>`, `Option<BorrowedFd>`, `Option<OwnedSocket>`,
and `Option<BorrowedSocket>` to be used in FFI declarations, as described
in the [I/O safety RFC].

[I/O safety RFC]: https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md#ownedfd-and-borrowedfdfd-1
Diffstat (limited to 'library/std/src/os/windows/io/socket.rs')
-rw-r--r--library/std/src/os/windows/io/socket.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/library/std/src/os/windows/io/socket.rs b/library/std/src/os/windows/io/socket.rs
index c14a1d6192f..baae92c19f2 100644
--- a/library/std/src/os/windows/io/socket.rs
+++ b/library/std/src/os/windows/io/socket.rs
@@ -34,6 +34,7 @@ use crate::sys::cvt;
     target_pointer_width = "64",
     rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FF_FF_FF_FF_FE)
 )]
+#[rustc_nonnull_optimization_guaranteed]
 #[unstable(feature = "io_safety", issue = "87074")]
 pub struct BorrowedSocket<'socket> {
     socket: RawSocket,
@@ -56,6 +57,7 @@ pub struct BorrowedSocket<'socket> {
     target_pointer_width = "64",
     rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FF_FF_FF_FF_FE)
 )]
+#[rustc_nonnull_optimization_guaranteed]
 #[unstable(feature = "io_safety", issue = "87074")]
 pub struct OwnedSocket {
     socket: RawSocket,