about summary refs log tree commit diff
path: root/library/std/src/io
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2021-06-24 04:16:11 -0400
committerJacob Pratt <jacob@jhpratt.dev>2021-06-24 04:16:11 -0400
commit3f14f4b3cec811017079564e16a92a1dc9870f41 (patch)
tree6f8c9207dd0c8cefa35d69a7d15ce756772586ca /library/std/src/io
parent6a758ea7e48416b968955535094479dc2e7cc9e1 (diff)
downloadrust-3f14f4b3cec811017079564e16a92a1dc9870f41.tar.gz
rust-3f14f4b3cec811017079564e16a92a1dc9870f41.zip
Use `#[non_exhaustive]` where appropriate
Due to the std/alloc split, it is not possible to make
`alloc::collections::TryReserveError::AllocError` non-exhaustive without
having an unstable, doc-hidden method to construct (which negates the
benefits from `#[non_exhaustive]`.
Diffstat (limited to 'library/std/src/io')
-rw-r--r--library/std/src/io/util.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/library/std/src/io/util.rs b/library/std/src/io/util.rs
index f3bff391fb3..fd52de7430a 100644
--- a/library/std/src/io/util.rs
+++ b/library/std/src/io/util.rs
@@ -13,9 +13,8 @@ use crate::io::{
 /// This struct is generally created by calling [`empty()`]. Please see
 /// the documentation of [`empty()`] for more details.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub struct Empty {
-    _priv: (),
-}
+#[non_exhaustive]
+pub struct Empty;
 
 /// Constructs a new handle to an empty reader.
 ///
@@ -35,7 +34,7 @@ pub struct Empty {
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_const_unstable(feature = "const_io_structs", issue = "78812")]
 pub const fn empty() -> Empty {
-    Empty { _priv: () }
+    Empty
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -172,9 +171,8 @@ impl fmt::Debug for Repeat {
 /// This struct is generally created by calling [`sink`]. Please
 /// see the documentation of [`sink()`] for more details.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub struct Sink {
-    _priv: (),
-}
+#[non_exhaustive]
+pub struct Sink;
 
 /// Creates an instance of a writer which will successfully consume all data.
 ///
@@ -195,7 +193,7 @@ pub struct Sink {
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_const_unstable(feature = "const_io_structs", issue = "78812")]
 pub const fn sink() -> Sink {
-    Sink { _priv: () }
+    Sink
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]