diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-10-31 13:20:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-31 13:20:07 +0100 |
| commit | 455a79acab1b2fe1263100a7889a1f2a52256c8d (patch) | |
| tree | 8361dcb08d27436f72fff5f61b8bd54c975e7ac7 /library/std/src/os | |
| parent | 26f505c433fc38d0b28b7861a7e194202baa5cc9 (diff) | |
| parent | a81d4b18ea7ee03733e983974400816684f78ebe (diff) | |
| download | rust-455a79acab1b2fe1263100a7889a1f2a52256c8d.tar.gz rust-455a79acab1b2fe1263100a7889a1f2a52256c8d.zip | |
Rollup merge of #90431 - jkugelman:must-use-std-o-through-z, r=joshtriplett
Add #[must_use] to remaining std functions (O-Z) I've run out of compelling reasons to group functions together across crates so I'm just going to go module-by-module. This is half of the remaining items from the `std` crate, from O-Z. `panicking::take_hook` has a side effect: it unregisters the current panic hook, returning it. I almost ignored it, but the documentation example shows `let _ = panic::take_hook();`, so following suit I went ahead and added a `#[must_use]`. ```rust std::panicking fn take_hook() -> Box<dyn Fn(&PanicInfo<'_>) + 'static + Sync + Send>; ``` I added these functions that clippy did not flag: ```rust std::path::Path fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool; std::path::Path fn ends_with<P: AsRef<Path>>(&self, child: P) -> bool; std::path::Path fn with_file_name<S: AsRef<OsStr>>(&self, file_name: S) -> PathBuf; std::path::Path fn with_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf; ``` Parent issue: #89692 r? `@joshtriplett`
Diffstat (limited to 'library/std/src/os')
| -rw-r--r-- | library/std/src/os/unix/net/ancillary.rs | 6 | ||||
| -rw-r--r-- | library/std/src/os/unix/net/listener.rs | 1 | ||||
| -rw-r--r-- | library/std/src/os/unix/process.rs | 1 |
3 files changed, 8 insertions, 0 deletions
diff --git a/library/std/src/os/unix/net/ancillary.rs b/library/std/src/os/unix/net/ancillary.rs index 353bf2f1166..6e6f5212b46 100644 --- a/library/std/src/os/unix/net/ancillary.rs +++ b/library/std/src/os/unix/net/ancillary.rs @@ -201,6 +201,7 @@ impl SocketCred { } /// Get the current PID. + #[must_use] #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] pub fn get_pid(&self) -> libc::pid_t { self.0.pid @@ -213,6 +214,7 @@ impl SocketCred { } /// Get the current UID. + #[must_use] #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] pub fn get_uid(&self) -> libc::uid_t { self.0.uid @@ -225,6 +227,7 @@ impl SocketCred { } /// Get the current GID. + #[must_use] #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] pub fn get_gid(&self) -> libc::gid_t { self.0.gid @@ -330,6 +333,7 @@ impl<'a> AncillaryData<'a> { } /// This struct is used to iterate through the control messages. +#[must_use = "iterators are lazy and do nothing unless consumed"] #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] pub struct Messages<'a> { buffer: &'a [u8], @@ -425,6 +429,7 @@ impl<'a> SocketAncillary<'a> { } /// Returns the capacity of the buffer. + #[must_use] #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] pub fn capacity(&self) -> usize { self.buffer.len() @@ -473,6 +478,7 @@ impl<'a> SocketAncillary<'a> { /// Ok(()) /// } /// ``` + #[must_use] #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] pub fn truncated(&self) -> bool { self.truncated diff --git a/library/std/src/os/unix/net/listener.rs b/library/std/src/os/unix/net/listener.rs index 97348afe7de..b23dd6062f6 100644 --- a/library/std/src/os/unix/net/listener.rs +++ b/library/std/src/os/unix/net/listener.rs @@ -365,6 +365,7 @@ impl<'a> IntoIterator for &'a UnixListener { /// } /// ``` #[derive(Debug)] +#[must_use = "iterators are lazy and do nothing unless consumed"] #[stable(feature = "unix_socket", since = "1.10.0")] pub struct Incoming<'a> { listener: &'a UnixListener, diff --git a/library/std/src/os/unix/process.rs b/library/std/src/os/unix/process.rs index 9b94615d247..286a7c3b386 100644 --- a/library/std/src/os/unix/process.rs +++ b/library/std/src/os/unix/process.rs @@ -436,6 +436,7 @@ impl From<crate::process::ChildStderr> for OwnedFd { } /// Returns the OS-assigned process identifier associated with this process's parent. +#[must_use] #[stable(feature = "unix_ppid", since = "1.27.0")] pub fn parent_id() -> u32 { crate::sys::os::getppid() |
