Skip to content

Commit ee80459

Browse files
authored
Rollup merge of rust-lang#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: rust-lang#89692
2 parents a06c664 + e27bfb6 commit ee80459

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

library/std/src/io/stdio.rs

+3
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ pub struct Stdin {
256256
/// Ok(())
257257
/// }
258258
/// ```
259+
#[must_use = "if unused stdin will immediately unlock"]
259260
#[stable(feature = "rust1", since = "1.0.0")]
260261
pub struct StdinLock<'a> {
261262
inner: MutexGuard<'a, BufReader<StdinRaw>>,
@@ -624,6 +625,7 @@ pub struct Stdout {
624625
/// When operating in a console, the Windows implementation of this stream does not support
625626
/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return
626627
/// an error.
628+
#[must_use = "if unused stdout will immediately unlock"]
627629
#[stable(feature = "rust1", since = "1.0.0")]
628630
pub struct StdoutLock<'a> {
629631
inner: ReentrantMutexGuard<'a, RefCell<LineWriter<StdoutRaw>>>,
@@ -907,6 +909,7 @@ pub struct Stderr {
907909
/// When operating in a console, the Windows implementation of this stream does not support
908910
/// non-UTF-8 byte sequences. Attempting to write bytes that are not valid UTF-8 will return
909911
/// an error.
912+
#[must_use = "if unused stderr will immediately unlock"]
910913
#[stable(feature = "rust1", since = "1.0.0")]
911914
pub struct StderrLock<'a> {
912915
inner: ReentrantMutexGuard<'a, RefCell<StderrRaw>>,

0 commit comments

Comments
 (0)