diff options
| author | bors <bors@rust-lang.org> | 2014-04-16 08:16:35 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-04-16 08:16:35 -0700 |
| commit | 72869b6579154d7aa322ddd0f9e3d89fd8abe8c4 (patch) | |
| tree | 8c7b32c4ee341498f46345898c6882643145cb31 /src/libsyntax | |
| parent | 12391df5b78a7a904112c0056aa28773abecb65d (diff) | |
| parent | a0347d5224977c8a271fbae64d084a5c5347d22b (diff) | |
| download | rust-72869b6579154d7aa322ddd0f9e3d89fd8abe8c4.tar.gz rust-72869b6579154d7aa322ddd0f9e3d89fd8abe8c4.zip | |
auto merge of #13547 : alexcrichton/rust/remove-priv, r=huonw
See [RFC 6](https://github.com/rust-lang/rfcs/blob/e0c741f1c6e372d0fd31c5978fcf8c7bd7c3e973/active/0006-remove-priv.md)
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 36 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/util/small_vector.rs | 59 |
5 files changed, 54 insertions, 53 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 1674902fb96..33c0f2c46bb 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1038,7 +1038,6 @@ pub struct TraitRef { #[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)] pub enum Visibility { Public, - Private, Inherited, } @@ -1046,7 +1045,7 @@ impl Visibility { pub fn inherit_from(&self, parent_visibility: Visibility) -> Visibility { match self { &Inherited => parent_visibility, - &Public | &Private => *self + &Public => *self } } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 88480c1b336..634e1c77c6a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -39,7 +39,7 @@ use ast::{MutImmutable, MutMutable, Mac_, MacInvocTT, Matcher, MatchNonterminal} use ast::{MatchSeq, MatchTok, Method, MutTy, BiMul, Mutability}; use ast::{NamedField, UnNeg, NoReturn, UnNot, P, Pat, PatEnum}; use ast::{PatIdent, PatLit, PatRange, PatRegion, PatStruct}; -use ast::{PatTup, PatUniq, PatWild, PatWildMulti, Private}; +use ast::{PatTup, PatUniq, PatWild, PatWildMulti}; use ast::{BiRem, Required}; use ast::{RetStyle, Return, BiShl, BiShr, Stmt, StmtDecl}; use ast::{StmtExpr, StmtSemi, StmtMac, StructDef, StructField}; @@ -3953,10 +3953,6 @@ impl<'a> Parser<'a> { let attrs = self.parse_outer_attributes(); - if self.eat_keyword(keywords::Priv) { - return self.parse_single_struct_field(Private, attrs); - } - if self.eat_keyword(keywords::Pub) { return self.parse_single_struct_field(Public, attrs); } @@ -3967,7 +3963,6 @@ impl<'a> Parser<'a> { // parse visiility: PUB, PRIV, or nothing fn parse_visibility(&mut self) -> Visibility { if self.eat_keyword(keywords::Pub) { Public } - else if self.eat_keyword(keywords::Priv) { Private } else { Inherited } } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 101c748b1ec..de6dacbe766 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -461,29 +461,29 @@ declare_special_idents_and_keywords! { (25, Mod, "mod"); (26, Mut, "mut"); (27, Once, "once"); - (28, Priv, "priv"); - (29, Pub, "pub"); - (30, Ref, "ref"); - (31, Return, "return"); + (28, Pub, "pub"); + (29, Ref, "ref"); + (30, Return, "return"); // Static and Self are also special idents (prefill de-dupes) (super::STATIC_KEYWORD_NAME, Static, "static"); (super::SELF_KEYWORD_NAME, Self, "self"); - (32, Struct, "struct"); - (33, Super, "super"); - (34, True, "true"); - (35, Trait, "trait"); - (36, Type, "type"); - (37, Unsafe, "unsafe"); - (38, Use, "use"); - (39, While, "while"); - (40, Continue, "continue"); - (41, Proc, "proc"); - (42, Box, "box"); + (31, Struct, "struct"); + (32, Super, "super"); + (33, True, "true"); + (34, Trait, "trait"); + (35, Type, "type"); + (36, Unsafe, "unsafe"); + (37, Use, "use"); + (38, While, "while"); + (39, Continue, "continue"); + (40, Proc, "proc"); + (41, Box, "box"); 'reserved: - (43, Alignof, "alignof"); - (44, Be, "be"); - (45, Offsetof, "offsetof"); + (42, Alignof, "alignof"); + (43, Be, "be"); + (44, Offsetof, "offsetof"); + (45, Priv, "priv"); (46, Pure, "pure"); (47, Sizeof, "sizeof"); (48, Typeof, "typeof"); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index cedcb4e988b..928ec09b3ae 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -230,7 +230,6 @@ pub fn variant_to_str(var: &ast::Variant) -> ~str { pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> ~str { match vis { - ast::Private => format!("priv {}", s), ast::Public => format!("pub {}", s), ast::Inherited => s.to_owned() } @@ -731,7 +730,6 @@ impl<'a> State<'a> { pub fn print_visibility(&mut self, vis: ast::Visibility) -> IoResult<()> { match vis { - ast::Private => self.word_nbsp("priv"), ast::Public => self.word_nbsp("pub"), ast::Inherited => Ok(()) } diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index 1dcebd7a016..792673e3298 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -12,15 +12,19 @@ use std::mem; use std::vec; /// A vector type optimized for cases where the size is almost always 0 or 1 -pub enum SmallVector<T> { - priv Zero, - priv One(T), - priv Many(Vec<T> ), +pub struct SmallVector<T> { + repr: SmallVectorRepr<T>, +} + +enum SmallVectorRepr<T> { + Zero, + One(T), + Many(Vec<T> ), } impl<T> Container for SmallVector<T> { fn len(&self) -> uint { - match *self { + match self.repr { Zero => 0, One(..) => 1, Many(ref vals) => vals.len() @@ -30,7 +34,7 @@ impl<T> Container for SmallVector<T> { impl<T> FromIterator<T> for SmallVector<T> { fn from_iter<I: Iterator<T>>(iter: I) -> SmallVector<T> { - let mut v = Zero; + let mut v = SmallVector::zero(); v.extend(iter); v } @@ -46,24 +50,24 @@ impl<T> Extendable<T> for SmallVector<T> { impl<T> SmallVector<T> { pub fn zero() -> SmallVector<T> { - Zero + SmallVector { repr: Zero } } pub fn one(v: T) -> SmallVector<T> { - One(v) + SmallVector { repr: One(v) } } - pub fn many(vs: Vec<T> ) -> SmallVector<T> { - Many(vs) + pub fn many(vs: Vec<T>) -> SmallVector<T> { + SmallVector { repr: Many(vs) } } pub fn push(&mut self, v: T) { - match *self { - Zero => *self = One(v), + match self.repr { + Zero => self.repr = One(v), One(..) => { - let one = mem::replace(self, Zero); + let one = mem::replace(&mut self.repr, Zero); match one { - One(v1) => mem::replace(self, Many(vec!(v1, v))), + One(v1) => mem::replace(&mut self.repr, Many(vec!(v1, v))), _ => unreachable!() }; } @@ -78,7 +82,7 @@ impl<T> SmallVector<T> { } pub fn get<'a>(&'a self, idx: uint) -> &'a T { - match *self { + match self.repr { One(ref v) if idx == 0 => v, Many(ref vs) => vs.get(idx), _ => fail!("out of bounds access") @@ -86,7 +90,7 @@ impl<T> SmallVector<T> { } pub fn expect_one(self, err: &'static str) -> T { - match self { + match self.repr { One(v) => v, Many(v) => { if v.len() == 1 { @@ -100,27 +104,32 @@ impl<T> SmallVector<T> { } pub fn move_iter(self) -> MoveItems<T> { - match self { + let repr = match self.repr { Zero => ZeroIterator, One(v) => OneIterator(v), Many(vs) => ManyIterator(vs.move_iter()) - } + }; + MoveItems { repr: repr } } } -pub enum MoveItems<T> { - priv ZeroIterator, - priv OneIterator(T), - priv ManyIterator(vec::MoveItems<T>), +pub struct MoveItems<T> { + repr: MoveItemsRepr<T>, +} + +enum MoveItemsRepr<T> { + ZeroIterator, + OneIterator(T), + ManyIterator(vec::MoveItems<T>), } impl<T> Iterator<T> for MoveItems<T> { fn next(&mut self) -> Option<T> { - match *self { + match self.repr { ZeroIterator => None, OneIterator(..) => { let mut replacement = ZeroIterator; - mem::swap(self, &mut replacement); + mem::swap(&mut self.repr, &mut replacement); match replacement { OneIterator(v) => Some(v), _ => unreachable!() @@ -131,7 +140,7 @@ impl<T> Iterator<T> for MoveItems<T> { } fn size_hint(&self) -> (uint, Option<uint>) { - match *self { + match self.repr { ZeroIterator => (0, Some(0)), OneIterator(..) => (1, Some(1)), ManyIterator(ref inner) => inner.size_hint() |
