Skip to content

Commit

Permalink
Add must_use to IntoRawFd/IntoRawSocket/IntoRawHandle's methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
zachs18 committed Jul 10, 2024
1 parent 697377a commit 1cb5354
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions std/src/os/fd/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions std/src/os/solid/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions std/src/os/windows/io/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 1cb5354

Please sign in to comment.