diff options
| author | John Kugelman <john@kugelman.name> | 2021-10-30 22:58:27 -0400 |
|---|---|---|
| committer | John Kugelman <john@kugelman.name> | 2021-10-30 23:44:02 -0400 |
| commit | e129d49f88a69d4bb8cb0f45a0a674c17393f4e9 (patch) | |
| tree | b04e94e7af3aa049512a2dbdaa8ae8ca0c1583ff /library/std/src/io | |
| parent | e249ce6b2345587d6e11052779c86adbad626dff (diff) | |
| download | rust-e129d49f88a69d4bb8cb0f45a0a674c17393f4e9.tar.gz rust-e129d49f88a69d4bb8cb0f45a0a674c17393f4e9.zip | |
Add #[must_use] to remaining std functions (A-N)
Diffstat (limited to 'library/std/src/io')
| -rw-r--r-- | library/std/src/io/error.rs | 5 | ||||
| -rw-r--r-- | library/std/src/io/mod.rs | 3 | ||||
| -rw-r--r-- | library/std/src/io/stdio.rs | 3 | ||||
| -rw-r--r-- | library/std/src/io/util.rs | 3 |
4 files changed, 14 insertions, 0 deletions
diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 59a9cd781cb..3da28695b34 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -442,6 +442,7 @@ impl Error { /// println!("last OS error: {:?}", Error::last_os_error()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[must_use] #[inline] pub fn last_os_error() -> Error { Error::from_raw_os_error(sys::os::errno() as i32) @@ -509,6 +510,7 @@ impl Error { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[must_use] #[inline] pub fn raw_os_error(&self) -> Option<i32> { match self.repr { @@ -547,6 +549,7 @@ impl Error { /// } /// ``` #[stable(feature = "io_error_inner", since = "1.3.0")] + #[must_use] #[inline] pub fn get_ref(&self) -> Option<&(dyn error::Error + Send + Sync + 'static)> { match self.repr { @@ -620,6 +623,7 @@ impl Error { /// } /// ``` #[stable(feature = "io_error_inner", since = "1.3.0")] + #[must_use] #[inline] pub fn get_mut(&mut self) -> Option<&mut (dyn error::Error + Send + Sync + 'static)> { match self.repr { @@ -688,6 +692,7 @@ impl Error { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[must_use] #[inline] pub fn kind(&self) -> ErrorKind { match self.repr { diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index abe29ba0f7c..f421185c2c5 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -1310,6 +1310,7 @@ pub struct Initializer(bool); impl Initializer { /// Returns a new `Initializer` which will zero out buffers. #[unstable(feature = "read_initializer", issue = "42788")] + #[must_use] #[inline] pub fn zeroing() -> Initializer { Initializer(true) @@ -1324,6 +1325,7 @@ impl Initializer { /// the method accurately reflects the number of bytes that have been /// written to the head of the buffer. #[unstable(feature = "read_initializer", issue = "42788")] + #[must_use] #[inline] pub unsafe fn nop() -> Initializer { Initializer(false) @@ -1331,6 +1333,7 @@ impl Initializer { /// Indicates if a buffer should be initialized. #[unstable(feature = "read_initializer", issue = "42788")] + #[must_use] #[inline] pub fn should_initialize(&self) -> bool { self.0 diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index 9389501e012..f471693774c 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -301,6 +301,7 @@ pub struct StdinLock<'a> { /// Ok(()) /// } /// ``` +#[must_use] #[stable(feature = "rust1", since = "1.0.0")] pub fn stdin() -> Stdin { static INSTANCE: SyncOnceCell<Mutex<BufReader<StdinRaw>>> = SyncOnceCell::new(); @@ -673,6 +674,7 @@ static STDOUT: SyncOnceCell<ReentrantMutex<RefCell<LineWriter<StdoutRaw>>>> = Sy /// Ok(()) /// } /// ``` +#[must_use] #[stable(feature = "rust1", since = "1.0.0")] pub fn stdout() -> Stdout { Stdout { @@ -953,6 +955,7 @@ pub struct StderrLock<'a> { /// Ok(()) /// } /// ``` +#[must_use] #[stable(feature = "rust1", since = "1.0.0")] pub fn stderr() -> Stderr { // Note that unlike `stdout()` we don't use `at_exit` here to register a diff --git a/library/std/src/io/util.rs b/library/std/src/io/util.rs index 2f3520ae7a5..9cd7c514849 100644 --- a/library/std/src/io/util.rs +++ b/library/std/src/io/util.rs @@ -32,6 +32,7 @@ pub struct Empty; /// io::empty().read_to_string(&mut buffer).unwrap(); /// assert!(buffer.is_empty()); /// ``` +#[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_io_structs", issue = "78812")] pub const fn empty() -> Empty { @@ -112,6 +113,7 @@ pub struct Repeat { /// io::repeat(0b101).read_exact(&mut buffer).unwrap(); /// assert_eq!(buffer, [0b101, 0b101, 0b101]); /// ``` +#[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_io_structs", issue = "78812")] pub const fn repeat(byte: u8) -> Repeat { @@ -192,6 +194,7 @@ pub struct Sink; /// let num_bytes = io::sink().write(&buffer).unwrap(); /// assert_eq!(num_bytes, 5); /// ``` +#[must_use] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_io_structs", issue = "78812")] pub const fn sink() -> Sink { |
