about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-10-09 10:00:54 +0000
committerbors <bors@rust-lang.org>2021-10-09 10:00:54 +0000
commitbb918d0a5bf22211df0423f7474e4e4056978007 (patch)
treee04106a063fb7c42b2a898f95024ff6ce29fe4ac /library/std/src
parent910692de742e9c0b1a57b7c5e467b8b85d903269 (diff)
parent2e5a5e22b215b9dc59386315f5562c0517cec064 (diff)
downloadrust-bb918d0a5bf22211df0423f7474e4e4056978007.tar.gz
rust-bb918d0a5bf22211df0423f7474e4e4056978007.zip
Auto merge of #89698 - matthiaskrgr:rollup-gna54x6, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #88707 (String.split_terminator: Add an example when using a slice of chars)
 - #89605 (Fix stabilization version for `bindings_after_at`)
 - #89634 (rustc_driver: Enable the `WARN` log level by default)
 - #89641 (make #[target_feature] work with `asm` register classes)
 - #89678 (Fix minor std::thread documentation typo)
 - #89684 (Fix asm docs typo)
 - #89687 (Move `read2_abbreviated` function into read2.rs)
 - #89693 (Add #[must_use] to stdin/stdout/stderr locks)
 - #89694 (Add #[must_use] to string/char transformation methods)
 - #89697 (Fix min LLVM version for bpf-types test)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/ffi/os_str.rs2
-rw-r--r--library/std/src/io/stdio.rs3
-rw-r--r--library/std/src/thread/mod.rs6
3 files changed, 8 insertions, 3 deletions
diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs
index 7e70901076c..c305519dd44 100644
--- a/library/std/src/ffi/os_str.rs
+++ b/library/std/src/ffi/os_str.rs
@@ -777,6 +777,7 @@ impl OsStr {
     ///
     /// assert_eq!("grüße, jürgen ❤", s.to_ascii_lowercase());
     /// ```
+    #[must_use = "to lowercase the value in-place, use `make_ascii_lowercase`"]
     #[stable(feature = "osstring_ascii", since = "1.53.0")]
     pub fn to_ascii_lowercase(&self) -> OsString {
         OsString::from_inner(self.inner.to_ascii_lowercase())
@@ -798,6 +799,7 @@ impl OsStr {
     ///
     /// assert_eq!("GRüßE, JüRGEN ❤", s.to_ascii_uppercase());
     /// ```
+    #[must_use = "to uppercase the value in-place, use `make_ascii_uppercase`"]
     #[stable(feature = "osstring_ascii", since = "1.53.0")]
     pub fn to_ascii_uppercase(&self) -> OsString {
         OsString::from_inner(self.inner.to_ascii_uppercase())
diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs
index 14a63303711..1ac3bbc95c6 100644
--- a/library/std/src/io/stdio.rs
+++ b/library/std/src/io/stdio.rs
@@ -256,6 +256,7 @@ pub struct Stdin {
 ///     Ok(())
 /// }
 /// ```
+#[must_use = "if unused stdin will immediately unlock"]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct StdinLock<'a> {
     inner: MutexGuard<'a, BufReader<StdinRaw>>,
@@ -624,6 +625,7 @@ pub struct Stdout {
 /// When operating in a console, the Windows implementation of this stream does not support
 /// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return
 /// an error.
+#[must_use = "if unused stdout will immediately unlock"]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct StdoutLock<'a> {
     inner: ReentrantMutexGuard<'a, RefCell<LineWriter<StdoutRaw>>>,
@@ -907,6 +909,7 @@ pub struct Stderr {
 /// When operating in a console, the Windows implementation of this stream does not support
 /// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return
 /// an error.
+#[must_use = "if unused stderr will immediately unlock"]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct StderrLock<'a> {
     inner: ReentrantMutexGuard<'a, RefCell<StderrRaw>>,
diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs
index 707a55b6258..7d404aff30e 100644
--- a/library/std/src/thread/mod.rs
+++ b/library/std/src/thread/mod.rs
@@ -412,9 +412,9 @@ impl Builder {
     ///
     /// # Safety
     ///
-    /// The caller has to ensure that no references in the supplied thread closure
-    /// or its return type can outlive the spawned thread's lifetime. This can be
-    /// guaranteed in two ways:
+    /// The caller has to ensure that the spawned thread does not outlive any
+    /// references in the supplied thread closure and its return type.
+    /// This can be guaranteed in two ways:
     ///
     /// - ensure that [`join`][`JoinHandle::join`] is called before any referenced
     /// data is dropped