diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-10-09 11:56:07 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-09 11:56:07 +0200 |
| commit | ee804594c8385c769dfde983a9ba455999a2f83e (patch) | |
| tree | 653632bd10a7e582b04227e9536d2f322a41339e /library/std/src | |
| parent | a06c664328c2b2793c9d6a390ec3f63a28ef7e1b (diff) | |
| parent | e27bfb6e23774b61619b0d83a66e7f079c3ada37 (diff) | |
| download | rust-ee804594c8385c769dfde983a9ba455999a2f83e.tar.gz rust-ee804594c8385c769dfde983a9ba455999a2f83e.zip | |
Rollup merge of #89693 - jkugelman:must-use-stdin-stdout-stderr-locks, r=joshtriplett
Add #[must_use] to stdin/stdout/stderr locks Affected methods: ```rust std::io fn stdin_locked() -> StdinLock<'static>; std::io::Stdin fn lock(&self) -> StdinLock<'_>; std::io fn stdout_locked() -> StdoutLock<'static>; std::io::Stdout fn lock(&self) -> StdoutLock<'_>; std::io fn stderr_locked() -> StderrLock<'static>; std::io::Stderr fn lock(&self) -> StderrLock<'_>; ``` Parent issue: https://github.com/rust-lang/rust/issues/89692
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/io/stdio.rs | 3 |
1 files changed, 3 insertions, 0 deletions
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>>, |
