From 8ea7b88c9b8de8d750b42ceb46b3ec667e21e881 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 14 Jan 2016 17:08:35 +0300 Subject: [PATCH] Require stability annotations on fields of tuple variants --- src/libcollections/borrow.rs | 6 ++++-- src/libcollections/btree/map.rs | 8 ++++++-- src/libcore/option.rs | 2 +- src/libcore/result.rs | 4 ++-- src/librustc/middle/stability.rs | 16 +--------------- src/libstd/collections/hash/map.rs | 8 ++++++-- src/libstd/env.rs | 2 +- src/libstd/io/mod.rs | 6 +++--- src/libstd/net/addr.rs | 4 ++-- src/libstd/path.rs | 24 ++++++++++++++++-------- src/libstd/sync/mpsc/mod.rs | 4 ++-- src/libstd/sys/common/poison.rs | 2 +- 12 files changed, 45 insertions(+), 41 deletions(-) diff --git a/src/libcollections/borrow.rs b/src/libcollections/borrow.rs index bfd4c2e96b5..25bfbb04a90 100644 --- a/src/libcollections/borrow.rs +++ b/src/libcollections/borrow.rs @@ -95,11 +95,13 @@ pub enum Cow<'a, B: ?Sized + 'a> { /// Borrowed data. #[stable(feature = "rust1", since = "1.0.0")] - Borrowed(&'a B), + Borrowed(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] &'a B), /// Owned data. #[stable(feature = "rust1", since = "1.0.0")] - Owned(::Owned), + Owned( + #[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] ::Owned + ), } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index f87f5e6c2e6..74895f16596 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -126,11 +126,15 @@ pub struct RangeMut<'a, K: 'a, V: 'a> { pub enum Entry<'a, K: 'a, V: 'a> { /// A vacant Entry #[stable(feature = "rust1", since = "1.0.0")] - Vacant(VacantEntry<'a, K, V>), + Vacant( + #[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] VacantEntry<'a, K, V> + ), /// An occupied Entry #[stable(feature = "rust1", since = "1.0.0")] - Occupied(OccupiedEntry<'a, K, V>), + Occupied( + #[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] OccupiedEntry<'a, K, V> + ), } /// A vacant Entry. diff --git a/src/libcore/option.rs b/src/libcore/option.rs index aca36d85626..8d40faf3bc6 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -169,7 +169,7 @@ pub enum Option { None, /// Some value `T` #[stable(feature = "rust1", since = "1.0.0")] - Some(T) + Some(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] T) } ///////////////////////////////////////////////////////////////////////////// diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 015887e3772..6ec76c821b3 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -250,11 +250,11 @@ use option::Option::{self, None, Some}; pub enum Result { /// Contains the success value #[stable(feature = "rust1", since = "1.0.0")] - Ok(T), + Ok(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] T), /// Contains the error value #[stable(feature = "rust1", since = "1.0.0")] - Err(E) + Err(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] E) } ///////////////////////////////////////////////////////////////////////////// diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 8d5c0c98885..87bc8bb8855 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -77,7 +77,6 @@ struct Annotator<'a, 'tcx: 'a> { parent_depr: Option, access_levels: &'a AccessLevels, in_trait_impl: bool, - in_enum: bool, } impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> { @@ -208,7 +207,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Annotator<'a, 'tcx> { fn visit_item(&mut self, i: &Item) { let orig_in_trait_impl = self.in_trait_impl; - let orig_in_enum = self.in_enum; let mut kind = AnnotationKind::Required; match i.node { // Inherent impls and foreign modules serve only as containers for other items, @@ -223,14 +221,10 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Annotator<'a, 'tcx> { self.in_trait_impl = true; } hir::ItemStruct(ref sd, _) => { - self.in_enum = false; if !sd.is_struct() { self.annotate(sd.id(), &i.attrs, i.span, AnnotationKind::Required, |_| {}) } } - hir::ItemEnum(..) => { - self.in_enum = true; - } _ => {} } @@ -238,7 +232,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Annotator<'a, 'tcx> { intravisit::walk_item(v, i) }); self.in_trait_impl = orig_in_trait_impl; - self.in_enum = orig_in_enum; } fn visit_trait_item(&mut self, ti: &hir::TraitItem) { @@ -265,13 +258,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Annotator<'a, 'tcx> { } fn visit_struct_field(&mut self, s: &StructField) { - // FIXME: This is temporary, can't use attributes with tuple variant fields until snapshot - let kind = if self.in_enum && s.node.kind.is_unnamed() { - AnnotationKind::Prohibited - } else { - AnnotationKind::Required - }; - self.annotate(s.node.id, &s.node.attrs, s.span, kind, |v| { + self.annotate(s.node.id, &s.node.attrs, s.span, AnnotationKind::Required, |v| { intravisit::walk_struct_field(v, s); }); } @@ -299,7 +286,6 @@ impl<'tcx> Index<'tcx> { parent_depr: None, access_levels: access_levels, in_trait_impl: false, - in_enum: false, }; annotator.annotate(ast::CRATE_NODE_ID, &krate.attrs, krate.span, AnnotationKind::Required, |v| intravisit::walk_crate(v, krate)); diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 9ab440f289e..e43101b7c9d 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1346,11 +1346,15 @@ pub struct VacantEntry<'a, K: 'a, V: 'a> { pub enum Entry<'a, K: 'a, V: 'a> { /// An occupied Entry. #[stable(feature = "rust1", since = "1.0.0")] - Occupied(OccupiedEntry<'a, K, V>), + Occupied( + #[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] OccupiedEntry<'a, K, V> + ), /// A vacant Entry. #[stable(feature = "rust1", since = "1.0.0")] - Vacant(VacantEntry<'a, K, V>), + Vacant( + #[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] VacantEntry<'a, K, V> + ), } /// Possible states of a VacantEntry. diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 760733872ea..55c4027d373 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -218,7 +218,7 @@ pub enum VarError { /// valid unicode data. The found data is returned as a payload of this /// variant. #[stable(feature = "env", since = "1.0.0")] - NotUnicode(OsString), + NotUnicode(#[cfg_attr(not(stage0), stable(feature = "env", since = "1.0.0"))] OsString), } #[stable(feature = "env", since = "1.0.0")] diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index b5ba6ff54c0..f8ae6228527 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1175,7 +1175,7 @@ pub trait Seek { pub enum SeekFrom { /// Set the offset to the provided number of bytes. #[stable(feature = "rust1", since = "1.0.0")] - Start(u64), + Start(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] u64), /// Set the offset to the size of this object plus the specified number of /// bytes. @@ -1183,7 +1183,7 @@ pub enum SeekFrom { /// It is possible to seek beyond the end of an object, but it's an error to /// seek before byte 0. #[stable(feature = "rust1", since = "1.0.0")] - End(i64), + End(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] i64), /// Set the offset to the current position plus the specified number of /// bytes. @@ -1191,7 +1191,7 @@ pub enum SeekFrom { /// It is possible to seek beyond the end of an object, but it's an error to /// seek before byte 0. #[stable(feature = "rust1", since = "1.0.0")] - Current(i64), + Current(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] i64), } fn read_until(r: &mut R, delim: u8, buf: &mut Vec) diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index 74d308dbf0c..7ae389615ac 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -32,10 +32,10 @@ use vec; pub enum SocketAddr { /// An IPv4 socket address which is a (ip, port) combination. #[stable(feature = "rust1", since = "1.0.0")] - V4(SocketAddrV4), + V4(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] SocketAddrV4), /// An IPv6 socket address #[stable(feature = "rust1", since = "1.0.0")] - V6(SocketAddrV6), + V6(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] SocketAddrV6), } /// An IPv4 socket address which is a (ip, port) combination. diff --git a/src/libstd/path.rs b/src/libstd/path.rs index d0b9cc4c460..3956f948eb9 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -266,27 +266,33 @@ mod platform { pub enum Prefix<'a> { /// Prefix `\\?\`, together with the given component immediately following it. #[stable(feature = "rust1", since = "1.0.0")] - Verbatim(&'a OsStr), + Verbatim(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] &'a OsStr), /// Prefix `\\?\UNC\`, with the "server" and "share" components following it. #[stable(feature = "rust1", since = "1.0.0")] - VerbatimUNC(&'a OsStr, &'a OsStr), + VerbatimUNC( + #[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] &'a OsStr, + #[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] &'a OsStr, + ), /// Prefix like `\\?\C:\`, for the given drive letter #[stable(feature = "rust1", since = "1.0.0")] - VerbatimDisk(u8), + VerbatimDisk(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] u8), /// Prefix `\\.\`, together with the given component immediately following it. #[stable(feature = "rust1", since = "1.0.0")] - DeviceNS(&'a OsStr), + DeviceNS(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] &'a OsStr), /// Prefix `\\server\share`, with the given "server" and "share" components. #[stable(feature = "rust1", since = "1.0.0")] - UNC(&'a OsStr, &'a OsStr), + UNC( + #[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] &'a OsStr, + #[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] &'a OsStr, + ), /// Prefix `C:` for the given disk drive. #[stable(feature = "rust1", since = "1.0.0")] - Disk(u8), + Disk(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] u8), } impl<'a> Prefix<'a> { @@ -528,7 +534,9 @@ pub enum Component<'a> { /// /// Does not occur on Unix. #[stable(feature = "rust1", since = "1.0.0")] - Prefix(PrefixComponent<'a>), + Prefix( + #[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] PrefixComponent<'a> + ), /// The root directory component, appears after any prefix and before anything else #[stable(feature = "rust1", since = "1.0.0")] @@ -544,7 +552,7 @@ pub enum Component<'a> { /// A normal component, i.e. `a` and `b` in `a/b` #[stable(feature = "rust1", since = "1.0.0")] - Normal(&'a OsStr), + Normal(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] &'a OsStr), } impl<'a> Component<'a> { diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index e87ae19c583..3eb5db09bc0 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -385,12 +385,12 @@ pub enum TrySendError { /// this is not a buffered channel, then there is no receiver available to /// acquire the data. #[stable(feature = "rust1", since = "1.0.0")] - Full(T), + Full(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] T), /// This channel's receiving half has disconnected, so the data could not be /// sent. The data is returned back to the callee in this case. #[stable(feature = "rust1", since = "1.0.0")] - Disconnected(T), + Disconnected(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] T), } enum Flavor { diff --git a/src/libstd/sys/common/poison.rs b/src/libstd/sys/common/poison.rs index 446a4445b2d..2cfa04c843b 100644 --- a/src/libstd/sys/common/poison.rs +++ b/src/libstd/sys/common/poison.rs @@ -71,7 +71,7 @@ pub enum TryLockError { /// The lock could not be acquired because another thread failed while holding /// the lock. #[stable(feature = "rust1", since = "1.0.0")] - Poisoned(PoisonError), + Poisoned(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] PoisonError), /// The lock could not be acquired at this time because the operation would /// otherwise block. #[stable(feature = "rust1", since = "1.0.0")]