about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-08-17 00:13:26 +0800
committerGitHub <noreply@github.com>2018-08-17 00:13:26 +0800
commit6e98ed9650dd392adbfe0b973e03964d0d069863 (patch)
treee7892f4f45a649736f4e65fec9b53b46f341439a /src/libstd
parent0c9e0e33b4e54b84706e23032a99c9efcff0774c (diff)
parent27f2a8420f3208d7ecc007094a2b9189ccf00f7b (diff)
downloadrust-6e98ed9650dd392adbfe0b973e03964d0d069863.tar.gz
rust-6e98ed9650dd392adbfe0b973e03964d0d069863.zip
Rollup merge of #53395 - varkor:__Nonexhaustive-to-non_exhaustive, r=shepmaster
Use #[non_exhaustive] on internal enums

This replaces `__Nonexhaustive` variants (and variants thereof)  with `#[non_exhaustive]`. These were mostly unstable previously, with the exception of the `cloudabi` enums and `Level` in proc_macro: these were `#[doc(hidden)]`, so clearly intended not to be used directly. It should be safe to replace all of these.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/error.rs11
-rw-r--r--src/libstd/lib.rs1
-rw-r--r--src/libstd/sys/cloudabi/abi/cloudabi.rs18
3 files changed, 11 insertions, 19 deletions
diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs
index 02a3ce8b9c4..3e50988a68b 100644
--- a/src/libstd/io/error.rs
+++ b/src/libstd/io/error.rs
@@ -97,6 +97,7 @@ struct Custom {
 #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
 #[stable(feature = "rust1", since = "1.0.0")]
 #[allow(deprecated)]
+#[non_exhaustive]
 pub enum ErrorKind {
     /// An entity was not found, often a file.
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -180,15 +181,6 @@ pub enum ErrorKind {
     /// read.
     #[stable(feature = "read_exact", since = "1.6.0")]
     UnexpectedEof,
-
-    /// A marker variant that tells the compiler that users of this enum cannot
-    /// match it exhaustively.
-    #[unstable(feature = "io_error_internals",
-               reason = "better expressed through extensible enums that this \
-                         enum cannot be exhaustively matched against",
-               issue = "0")]
-    #[doc(hidden)]
-    __Nonexhaustive,
 }
 
 impl ErrorKind {
@@ -212,7 +204,6 @@ impl ErrorKind {
             ErrorKind::Interrupted => "operation interrupted",
             ErrorKind::Other => "other os error",
             ErrorKind::UnexpectedEof => "unexpected end of file",
-            ErrorKind::__Nonexhaustive => unreachable!()
         }
     }
 }
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index 5d463225ae9..60ad330bb9b 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -311,6 +311,7 @@
 #![feature(doc_keyword)]
 #![feature(panic_info_message)]
 #![feature(panic_implementation)]
+#![feature(non_exhaustive)]
 
 #![default_lib_allocator]
 
diff --git a/src/libstd/sys/cloudabi/abi/cloudabi.rs b/src/libstd/sys/cloudabi/abi/cloudabi.rs
index 2909db5098e..cd9a5ad448f 100644
--- a/src/libstd/sys/cloudabi/abi/cloudabi.rs
+++ b/src/libstd/sys/cloudabi/abi/cloudabi.rs
@@ -121,6 +121,7 @@ include!("bitflags.rs");
 /// File or memory access pattern advisory information.
 #[repr(u8)]
 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+#[non_exhaustive]
 pub enum advice {
   /// The application expects that it will not access the
   /// specified data in the near future.
@@ -140,12 +141,12 @@ pub enum advice {
   /// The application expects to access the specified data
   /// in the near future.
   WILLNEED   = 6,
-  #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
 }
 
 /// Enumeration describing the kind of value stored in [`auxv`](struct.auxv.html).
 #[repr(u32)]
 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+#[non_exhaustive]
 pub enum auxtype {
   /// Base address of the binary argument data provided to
   /// [`proc_exec()`](fn.proc_exec.html).
@@ -210,12 +211,12 @@ pub enum auxtype {
   SYSINFO_EHDR = 262,
   /// Thread ID of the initial thread of the process.
   TID          = 261,
-  #[doc(hidden)] _NonExhaustive = -1 as isize as u32,
 }
 
 /// Identifiers for clocks.
 #[repr(u32)]
 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+#[non_exhaustive]
 pub enum clockid {
   /// The system-wide monotonic clock, which is defined as a
   /// clock measuring real time, whose value cannot be
@@ -232,7 +233,6 @@ pub enum clockid {
   REALTIME           = 3,
   /// The CPU-time clock associated with the current thread.
   THREAD_CPUTIME_ID  = 4,
-  #[doc(hidden)] _NonExhaustive = -1 as isize as u32,
 }
 
 /// A userspace condition variable.
@@ -267,6 +267,7 @@ pub const DIRCOOKIE_START: dircookie = dircookie(0);
 /// exclusively or merely provided for alignment with POSIX.
 #[repr(u16)]
 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+#[non_exhaustive]
 pub enum errno {
   /// No error occurred. System call completed successfully.
   SUCCESS        =  0,
@@ -422,7 +423,6 @@ pub enum errno {
   XDEV           = 75,
   /// Extension: Capabilities insufficient.
   NOTCAPABLE     = 76,
-  #[doc(hidden)] _NonExhaustive = -1 as isize as u16,
 }
 
 bitflags! {
@@ -438,6 +438,7 @@ bitflags! {
 /// Type of a subscription to an event or its occurrence.
 #[repr(u8)]
 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+#[non_exhaustive]
 pub enum eventtype {
   /// The time value of clock [`subscription.union.clock.clock_id`](struct.subscription_clock.html#structfield.clock_id)
   /// has reached timestamp [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout).
@@ -463,7 +464,6 @@ pub enum eventtype {
   /// The process associated with process descriptor
   /// [`subscription.union.proc_terminate.fd`](struct.subscription_proc_terminate.html#structfield.fd) has terminated.
   PROC_TERMINATE = 7,
-  #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
 }
 
 /// Exit code generated by a process when exiting.
@@ -530,6 +530,7 @@ pub type filesize = u64;
 /// The type of a file descriptor or file.
 #[repr(u8)]
 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+#[non_exhaustive]
 pub enum filetype {
   /// The type of the file descriptor or file is unknown or
   /// is different from any of the other types specified.
@@ -558,7 +559,6 @@ pub enum filetype {
   SOCKET_STREAM    = 130,
   /// The file refers to a symbolic link inode.
   SYMBOLIC_LINK    = 144,
-  #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
 }
 
 bitflags! {
@@ -847,12 +847,12 @@ bitflags! {
 /// memory.
 #[repr(u8)]
 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+#[non_exhaustive]
 pub enum scope {
   /// The object is stored in private memory.
   PRIVATE = 4,
   /// The object is stored in shared memory.
   SHARED  = 8,
-  #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
 }
 
 bitflags! {
@@ -878,6 +878,7 @@ bitflags! {
 /// Signal condition.
 #[repr(u8)]
 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+#[non_exhaustive]
 pub enum signal {
   /// Process abort signal.
   ///
@@ -983,7 +984,6 @@ pub enum signal {
   ///
   /// Action: Terminates the process.
   XFSZ   = 26,
-  #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
 }
 
 bitflags! {
@@ -1049,6 +1049,7 @@ pub type userdata = u64;
 /// should be set.
 #[repr(u8)]
 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
+#[non_exhaustive]
 pub enum whence {
   /// Seek relative to current position.
   CUR = 1,
@@ -1056,7 +1057,6 @@ pub enum whence {
   END = 2,
   /// Seek relative to start-of-file.
   SET = 3,
-  #[doc(hidden)] _NonExhaustive = -1 as isize as u8,
 }
 
 /// Auxiliary vector entry.