Skip to content

Commit e27bfb6

Browse files
committed
Add #[must_use] to stdin/stdout/stderr locks
1 parent f875143 commit e27bfb6

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)