diff options
| author | Zachary S <zasample18+github@gmail.com> | 2024-07-10 13:08:24 -0500 |
|---|---|---|
| committer | Zachary S <zasample18+github@gmail.com> | 2024-07-10 13:08:24 -0500 |
| commit | 6d477d3a9de714d877a9eda48b0eda3e12e301be (patch) | |
| tree | f4cc62660535617b2ed7806940e392f9d717d8fe /library/std/src | |
| parent | 0d49862998b3695297dffba21c80b35fb73e245d (diff) | |
| download | rust-6d477d3a9de714d877a9eda48b0eda3e12e301be.tar.gz rust-6d477d3a9de714d877a9eda48b0eda3e12e301be.zip | |
Add `must_use` to IntoRawFd/IntoRawSocket/IntoRawHandle's methods.
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/os/fd/raw.rs | 1 | ||||
| -rw-r--r-- | library/std/src/os/solid/io.rs | 1 | ||||
| -rw-r--r-- | library/std/src/os/windows/io/raw.rs | 2 |
3 files changed, 4 insertions, 0 deletions
diff --git a/library/std/src/os/fd/raw.rs b/library/std/src/os/fd/raw.rs index ef896ea95c9..9d6fcaa3634 100644 --- a/library/std/src/os/fd/raw.rs +++ b/library/std/src/os/fd/raw.rs @@ -138,6 +138,7 @@ pub trait IntoRawFd { /// let raw_fd: RawFd = f.into_raw_fd(); /// # Ok::<(), io::Error>(()) /// ``` + #[must_use = "losing the raw file descriptor may leak resources"] #[stable(feature = "into_raw_os", since = "1.4.0")] fn into_raw_fd(self) -> RawFd; } diff --git a/library/std/src/os/solid/io.rs b/library/std/src/os/solid/io.rs index 19b4fe22093..13d8419830d 100644 --- a/library/std/src/os/solid/io.rs +++ b/library/std/src/os/solid/io.rs @@ -347,6 +347,7 @@ pub trait IntoRawFd { /// This function **transfers ownership** of the underlying file descriptor /// to the caller. Callers are then the unique owners of the file descriptor /// and must close the descriptor once it's no longer needed. + #[must_use = "losing the raw file descriptor may leak resources"] fn into_raw_fd(self) -> RawFd; } diff --git a/library/std/src/os/windows/io/raw.rs b/library/std/src/os/windows/io/raw.rs index 770583a9ce3..e76650be742 100644 --- a/library/std/src/os/windows/io/raw.rs +++ b/library/std/src/os/windows/io/raw.rs @@ -89,6 +89,7 @@ pub trait IntoRawHandle { /// However, transferring ownership is not strictly required. Use a /// `Into<OwnedHandle>::into` implementation for an API which strictly /// transfers ownership. + #[must_use = "losing the raw handle may leak resources"] #[stable(feature = "into_raw_os", since = "1.4.0")] fn into_raw_handle(self) -> RawHandle; } @@ -230,6 +231,7 @@ pub trait IntoRawSocket { /// However, transferring ownership is not strictly required. Use a /// `Into<OwnedSocket>::into` implementation for an API which strictly /// transfers ownership. + #[must_use = "losing the raw socket may leak resources"] #[stable(feature = "into_raw_os", since = "1.4.0")] fn into_raw_socket(self) -> RawSocket; } |
