Add must_use to IntoRawFd/IntoRawSocket/IntoRawHandle's methods. · model-checking/verify-rust-std@1cb5354 (original) (raw)

3 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -138,6 +138,7 @@ pub trait IntoRawFd {
138 138 /// let raw_fd: RawFd = f.into_raw_fd();
139 139 /// # Ok::<(), io::Error>(())
140 140 /// ```
141 + #[must_use = "losing the raw file descriptor may leak resources"]
141 142 #[stable(feature = "into_raw_os", since = "1.4.0")]
142 143 fn into_raw_fd(self) -> RawFd;
143 144 }
Original file line number Diff line number Diff line change
@@ -347,6 +347,7 @@ pub trait IntoRawFd {
347 347 /// This function **transfers ownership** of the underlying file descriptor
348 348 /// to the caller. Callers are then the unique owners of the file descriptor
349 349 /// and must close the descriptor once it's no longer needed.
350 + #[must_use = "losing the raw file descriptor may leak resources"]
350 351 fn into_raw_fd(self) -> RawFd;
351 352 }
352 353
Original file line number Diff line number Diff line change
@@ -89,6 +89,7 @@ pub trait IntoRawHandle {
89 89 /// However, transferring ownership is not strictly required. Use a
90 90 /// `Into::into` implementation for an API which strictly
91 91 /// transfers ownership.
92 + #[must_use = "losing the raw handle may leak resources"]
92 93 #[stable(feature = "into_raw_os", since = "1.4.0")]
93 94 fn into_raw_handle(self) -> RawHandle;
94 95 }
@@ -230,6 +231,7 @@ pub trait IntoRawSocket {
230 231 /// However, transferring ownership is not strictly required. Use a
231 232 /// `Into::into` implementation for an API which strictly
232 233 /// transfers ownership.
234 + #[must_use = "losing the raw socket may leak resources"]
233 235 #[stable(feature = "into_raw_os", since = "1.4.0")]
234 236 fn into_raw_socket(self) -> RawSocket;
235 237 }