Auto merge of #30898 - petrochenkov:tvarfstab, r=alexcrichton

This wasn't done in https://github.com/rust-lang/rust/pull/29083 because attributes weren't parsed on fields of tuple variant back then.

r? @alexcrichton
This commit is contained in:
bors 2016-01-15 15:39:39 +00:00
commit e51661b888
12 changed files with 45 additions and 41 deletions

View File

@ -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(<B as ToOwned>::Owned),
Owned(
#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] <B as ToOwned>::Owned
),
}
#[stable(feature = "rust1", since = "1.0.0")]

View File

@ -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.

View File

@ -169,7 +169,7 @@ pub enum Option<T> {
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)
}
/////////////////////////////////////////////////////////////////////////////

View File

@ -250,11 +250,11 @@ use option::Option::{self, None, Some};
pub enum Result<T, E> {
/// 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)
}
/////////////////////////////////////////////////////////////////////////////

View File

@ -77,7 +77,6 @@ struct Annotator<'a, 'tcx: 'a> {
parent_depr: Option<Deprecation>,
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));

View File

@ -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.

View File

@ -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")]

View File

@ -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: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>)

View File

@ -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.

View File

@ -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> {

View File

@ -385,12 +385,12 @@ pub enum TrySendError<T> {
/// 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<T> {

View File

@ -71,7 +71,7 @@ pub enum TryLockError<T> {
/// The lock could not be acquired because another thread failed while holding
/// the lock.
#[stable(feature = "rust1", since = "1.0.0")]
Poisoned(PoisonError<T>),
Poisoned(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] PoisonError<T>),
/// The lock could not be acquired at this time because the operation would
/// otherwise block.
#[stable(feature = "rust1", since = "1.0.0")]