Rollup merge of #90430 - jkugelman:must-use-std-a-through-n, r=joshtriplett
Add #[must_use] to remaining std functions (A-N) 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 A-N. I added these functions myself. Clippy predictably ignored the `mut` ones, but I don't know why the rest weren't flagged. Check them closely, please? Maybe I overlooked good reasons. ```rust std::backtrace::Backtrace const fn disabled() -> Backtrace; std::backtrace::Backtrace<'a> fn frames(&'a self) -> &'a [BacktraceFrame]; std::collections::hash_map::RawOccupiedEntryMut<'a, K, V> fn key_mut(&mut self) -> &mut K; std::collections::hash_map::RawOccupiedEntryMut<'a, K, V> fn get_mut(&mut self) -> &mut V; std::collections::hash_map::RawOccupiedEntryMut<'a, K, V> fn get_key_value(&mut self) -> (&K, &V); std::collections::hash_map::RawOccupiedEntryMut<'a, K, V> fn get_key_value_mut(&mut self) -> (&mut K, &mut V); std::env fn var_os<K: AsRef<OsStr>>(key: K) -> Option<OsString>; std::env fn split_paths<T: AsRef<OsStr> + ?Sized>(unparsed: &T) -> SplitPaths<'_>; std::io::Error fn get_mut(&mut self) -> Option<&mut (dyn error::Error + Send + Sync + 'static)>; ``` Parent issue: #89692 r? `@joshtriplett`
This commit is contained in:
@@ -374,6 +374,7 @@ impl File {
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[unstable(feature = "with_options", issue = "65439")]
|
||||
pub fn with_options() -> OpenOptions {
|
||||
OpenOptions::new()
|
||||
@@ -983,6 +984,7 @@ impl Metadata {
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "file_type", since = "1.1.0")]
|
||||
pub fn file_type(&self) -> FileType {
|
||||
FileType(self.0.file_type())
|
||||
@@ -1100,6 +1102,7 @@ impl Metadata {
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn permissions(&self) -> Permissions {
|
||||
Permissions(self.0.perm())
|
||||
@@ -1247,6 +1250,7 @@ impl Permissions {
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[must_use = "call `set_readonly` to modify the readonly flag"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn readonly(&self) -> bool {
|
||||
self.0.readonly()
|
||||
@@ -1441,6 +1445,7 @@ impl DirEntry {
|
||||
/// ```
|
||||
///
|
||||
/// The exact text, of course, depends on what files you have in `.`.
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn path(&self) -> PathBuf {
|
||||
self.0.path()
|
||||
@@ -1536,6 +1541,7 @@ impl DirEntry {
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "dir_entry_ext", since = "1.1.0")]
|
||||
pub fn file_name(&self) -> OsString {
|
||||
self.0.file_name()
|
||||
|
||||
Reference in New Issue
Block a user