diff options
| author | bors <bors@rust-lang.org> | 2021-10-31 09:07:09 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-10-31 09:07:09 +0000 |
| commit | 58899c4d9c63a6d27ac395ee9597ae797df7f026 (patch) | |
| tree | 8dd3927bfe5e06e4d5446333d87ede1c13c89ee6 /library/std | |
| parent | 38b01d90657a355abf81b53cb3ee0b9a7dd88f98 (diff) | |
| parent | ff6d8ecd6482587368ab0a6287009460eac536b3 (diff) | |
| download | rust-58899c4d9c63a6d27ac395ee9597ae797df7f026.tar.gz rust-58899c4d9c63a6d27ac395ee9597ae797df7f026.zip | |
Auto merge of #90434 - matthiaskrgr:rollup-xbn393a, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #89446 (Add paragraph to ControlFlow docs to menion it works with the ? operator (#88715)) - #89677 (Stabilize `is_symlink()` for `Metadata` and `Path`) - #89833 (Add #[must_use] to Rc::downgrade) - #89835 (Add #[must_use] to expensive computations) - #89839 (Add #[must_use] to mem/ptr functions) - #89897 (Add #[must_use] to remaining core functions) - #89951 (Stabilize `option_result_unwrap_unchecked`) - #90427 (Add #[must_use] to alloc functions that would leak memory) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std')
| -rw-r--r-- | library/std/src/collections/hash/set.rs | 8 | ||||
| -rw-r--r-- | library/std/src/ffi/os_str.rs | 1 | ||||
| -rw-r--r-- | library/std/src/fs.rs | 3 | ||||
| -rw-r--r-- | library/std/src/io/stdio.rs | 1 | ||||
| -rw-r--r-- | library/std/src/path.rs | 11 |
5 files changed, 19 insertions, 5 deletions
diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index 546c43faecf..1fc1d39b181 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -1320,6 +1320,8 @@ where /// /// let mut intersection = a.intersection(&b); /// ``` +#[must_use = "this returns the intersection as an iterator, \ + without modifying either input set"] #[stable(feature = "rust1", since = "1.0.0")] pub struct Intersection<'a, T: 'a, S: 'a> { // iterator of the first set @@ -1345,6 +1347,8 @@ pub struct Intersection<'a, T: 'a, S: 'a> { /// /// let mut difference = a.difference(&b); /// ``` +#[must_use = "this returns the difference as an iterator, \ + without modifying either input set"] #[stable(feature = "rust1", since = "1.0.0")] pub struct Difference<'a, T: 'a, S: 'a> { // iterator of the first set @@ -1370,6 +1374,8 @@ pub struct Difference<'a, T: 'a, S: 'a> { /// /// let mut intersection = a.symmetric_difference(&b); /// ``` +#[must_use = "this returns the difference as an iterator, \ + without modifying either input set"] #[stable(feature = "rust1", since = "1.0.0")] pub struct SymmetricDifference<'a, T: 'a, S: 'a> { iter: Chain<Difference<'a, T, S>, Difference<'a, T, S>>, @@ -1392,6 +1398,8 @@ pub struct SymmetricDifference<'a, T: 'a, S: 'a> { /// /// let mut union_iter = a.union(&b); /// ``` +#[must_use = "this returns the union as an iterator, \ + without modifying either input set"] #[stable(feature = "rust1", since = "1.0.0")] pub struct Union<'a, T: 'a, S: 'a> { iter: Chain<Iter<'a, T>, Difference<'a, T, S>>, diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 46c9aa5e627..49e268eb99b 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -829,6 +829,7 @@ impl OsStr { /// assert!(!non_ascii.is_ascii()); /// ``` #[stable(feature = "osstring_ascii", since = "1.53.0")] + #[must_use] #[inline] pub fn is_ascii(&self) -> bool { self.inner.is_ascii() diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 9f45e89aa75..2b76a411a0f 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1046,7 +1046,6 @@ impl Metadata { /// #[cfg_attr(unix, doc = "```no_run")] #[cfg_attr(not(unix), doc = "```ignore")] - /// #![feature(is_symlink)] /// use std::fs; /// use std::path::Path; /// use std::os::unix::fs::symlink; @@ -1062,7 +1061,7 @@ impl Metadata { /// } /// ``` #[must_use] - #[unstable(feature = "is_symlink", issue = "85748")] + #[stable(feature = "is_symlink", since = "1.57.0")] pub fn is_symlink(&self) -> bool { self.file_type().is_symlink() } diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index 9389501e012..96a9da24c7e 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -487,6 +487,7 @@ impl Stdin { /// println!("got a chunk: {}", String::from_utf8_lossy(&split.unwrap())); /// } /// ``` + #[must_use = "`self` will be dropped if the result is not used"] #[unstable(feature = "stdin_forwarders", issue = "87096")] pub fn split(self, byte: u8) -> Split<StdinLock<'static>> { self.into_locked().split(byte) diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 8f00d2260e4..4e547a80258 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -2751,7 +2751,7 @@ impl Path { fs::metadata(self).map(|m| m.is_dir()).unwrap_or(false) } - /// Returns true if the path exists on disk and is pointing at a symbolic link. + /// Returns `true` if the path exists on disk and is pointing at a symbolic link. /// /// This function will not traverse symbolic links. /// In case of a broken symbolic link this will also return true. @@ -2763,7 +2763,6 @@ impl Path { /// #[cfg_attr(unix, doc = "```no_run")] #[cfg_attr(not(unix), doc = "```ignore")] - /// #![feature(is_symlink)] /// use std::path::Path; /// use std::os::unix::fs::symlink; /// @@ -2772,8 +2771,14 @@ impl Path { /// assert_eq!(link_path.is_symlink(), true); /// assert_eq!(link_path.exists(), false); /// ``` - #[unstable(feature = "is_symlink", issue = "85748")] + /// + /// # See Also + /// + /// This is a convenience function that coerces errors to false. If you want to + /// check errors, call [`fs::symlink_metadata`] and handle its [`Result`]. Then call + /// [`fs::Metadata::is_symlink`] if it was [`Ok`]. #[must_use] + #[stable(feature = "is_symlink", since = "1.57.0")] pub fn is_symlink(&self) -> bool { fs::symlink_metadata(self).map(|m| m.is_symlink()).unwrap_or(false) } |
