]> git.lizzy.rs Git - rust.git/commitdiff
rustc: Remove private enum variants
authorAlex Crichton <alex@alexcrichton.com>
Wed, 16 Apr 2014 01:02:58 +0000 (18:02 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 16 Apr 2014 15:12:43 +0000 (08:12 -0700)
This removes the `priv` keyword from the language and removes private enum
variants as a result. The remaining use cases of private enum variants were all
updated to be a struct with one private field that is a private enum.

RFC: 0006-remove-priv

Closes #13535

29 files changed:
src/doc/rust.md
src/librustc/metadata/decoder.rs
src/librustc/metadata/encoder.rs
src/librustc/middle/privacy.rs
src/librustc/middle/resolve.rs
src/librustdoc/doctree.rs
src/librustdoc/html/format.rs
src/libsyntax/ast.rs
src/libsyntax/parse/parser.rs
src/libsyntax/print/pprust.rs
src/test/auxiliary/private_variant_1.rs [deleted file]
src/test/auxiliary/private_variant_xc.rs [deleted file]
src/test/auxiliary/unreachable-variant.rs [new file with mode: 0644]
src/test/compile-fail/assign-to-method.rs
src/test/compile-fail/class-cast-to-trait.rs
src/test/compile-fail/class-missing-self.rs
src/test/compile-fail/issue-3993-2.rs
src/test/compile-fail/issue-9957.rs
src/test/compile-fail/lint-missing-doc.rs
src/test/compile-fail/lint-visible-private-types.rs
src/test/compile-fail/privacy1.rs
src/test/compile-fail/private-method.rs
src/test/compile-fail/private-variant-xc.rs [deleted file]
src/test/compile-fail/private-variant.rs [deleted file]
src/test/compile-fail/private_variant_2.rs [deleted file]
src/test/compile-fail/removed-syntax-priv-group.rs [deleted file]
src/test/compile-fail/unnecessary-private.rs
src/test/compile-fail/unreachable-variant.rs [new file with mode: 0644]
src/test/compile-fail/useless-priv.rs

index f2df445a5a276de6c3b800b954016662dc1cae04..778c1ce026816fbd394d0b0079ec5d91181b4236 100644 (file)
@@ -1586,10 +1586,10 @@ pub struct Bar {
     field: int
 }
 
-// Declare a public enum with public and private variants
+// Declare a public enum with two public variants
 pub enum State {
     PubliclyAccessibleState,
-    priv PrivatelyAccessibleState
+    PubliclyAccessibleState2,
 }
 ~~~~
 
index 5fe59a787737aea37253e839f1c1065e25579bc1..ee7ce817a3f202dbf8f88794483fe80adc640db8 100644 (file)
@@ -124,7 +124,6 @@ enum Family {
     Trait,                 // I
     Struct,                // S
     PublicField,           // g
-    PrivateField,          // j
     InheritedField         // N
 }
 
@@ -149,7 +148,6 @@ fn item_family(item: ebml::Doc) -> Family {
       'I' => Trait,
       'S' => Struct,
       'g' => PublicField,
-      'j' => PrivateField,
       'N' => InheritedField,
        c => fail!("unexpected family char: {}", c)
     }
@@ -161,7 +159,6 @@ fn item_visibility(item: ebml::Doc) -> ast::Visibility {
         Some(visibility_doc) => {
             match reader::doc_as_u8(visibility_doc) as char {
                 'y' => ast::Public,
-                'n' => ast::Private,
                 'i' => ast::Inherited,
                 _ => fail!("unknown visibility character")
             }
@@ -364,7 +361,7 @@ fn item_to_def_like(item: ebml::Doc, did: ast::DefId, cnum: ast::CrateNum)
         Trait => DlDef(ast::DefTrait(did)),
         Enum => DlDef(ast::DefTy(did)),
         Impl => DlImpl(did),
-        PublicField | PrivateField | InheritedField => DlField,
+        PublicField | InheritedField => DlField,
     }
 }
 
@@ -962,7 +959,6 @@ pub fn get_item_attrs(cdata: Cmd,
 fn struct_field_family_to_visibility(family: Family) -> ast::Visibility {
     match family {
       PublicField => ast::Public,
-      PrivateField => ast::Private,
       InheritedField => ast::Inherited,
       _ => fail!()
     }
@@ -975,7 +971,7 @@ pub fn get_struct_fields(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId)
     let mut result = Vec::new();
     reader::tagged_docs(item, tag_item_field, |an_item| {
         let f = item_family(an_item);
-        if f == PublicField || f == PrivateField || f == InheritedField {
+        if f == PublicField || f == InheritedField {
             // FIXME #6993: name should be of type Name, not Ident
             let name = item_name(&*intr, an_item);
             let did = item_def_id(an_item, cdata);
index d5313eb2578108a521e0aa1266323aa207ad403b..085a96ea7be2f3cc31265d193758b66c0cb890c7 100644 (file)
@@ -607,7 +607,6 @@ fn encode_struct_field_family(ebml_w: &mut Encoder,
                               visibility: Visibility) {
     encode_family(ebml_w, match visibility {
         Public => 'g',
-        Private => 'j',
         Inherited => 'N'
     });
 }
@@ -616,7 +615,6 @@ fn encode_visibility(ebml_w: &mut Encoder, visibility: Visibility) {
     ebml_w.start_tag(tag_items_data_item_visibility);
     let ch = match visibility {
         Public => 'y',
-        Private => 'n',
         Inherited => 'i',
     };
     ebml_w.wr_str(str::from_char(ch));
index ee514ba5f2438f4e867f2f92fe44d42d8c9fa2e3..798fc2ffa33c097d2afed38d11988dc61fdcd54d 100644 (file)
@@ -67,18 +67,10 @@ fn visit_item(&mut self, item: &ast::Item, _: ()) {
             // they inherit privacy
             ast::ItemEnum(ref def, _) => {
                 for variant in def.variants.iter() {
-                    // If variants are private, then their logical "parent" is
-                    // the enclosing module because everyone in the enclosing
-                    // module can still use the private variant
-                    if variant.node.vis == ast::Private {
-                        self.parents.insert(variant.node.id, self.curparent);
-
-                    // Otherwise, if the variant is public, then the parent is
-                    // considered the enclosing enum because the enum will
-                    // dictate the privacy visibility of this variant instead.
-                    } else {
-                        self.parents.insert(variant.node.id, item.id);
-                    }
+                    // The parent is considered the enclosing enum because the
+                    // enum will dictate the privacy visibility of this variant
+                    // instead.
+                    self.parents.insert(variant.node.id, item.id);
                 }
             }
 
@@ -224,9 +216,7 @@ fn visit_item(&mut self, item: &ast::Item, _: ()) {
             // public all variants are public unless they're explicitly priv
             ast::ItemEnum(ref def, _) if public_first => {
                 for variant in def.variants.iter() {
-                    if variant.node.vis != ast::Private {
-                        self.exported_items.insert(variant.node.id);
-                    }
+                    self.exported_items.insert(variant.node.id);
                 }
             }
 
@@ -462,10 +452,7 @@ fn def_privacy(&self, did: ast::DefId) -> PrivacyResult {
                 Some(ast_map::NodeForeignItem(_)) => {
                     self.tcx.map.get_foreign_vis(closest_private_id)
                 }
-                Some(ast_map::NodeVariant(ref v)) => {
-                    // sadly enum variants still inherit visibility, so only
-                    // break out of this is explicitly private
-                    if v.node.vis == ast::Private { break }
+                Some(ast_map::NodeVariant(..)) => {
                     ast::Public // need to move up a level (to the enum)
                 }
                 _ => ast::Public,
@@ -997,10 +984,6 @@ fn visit_fn(&mut self, fk: &visit::FnKind, fd: &ast::FnDecl,
     fn visit_view_item(&mut self, i: &ast::ViewItem, _: ()) {
         match i.vis {
             ast::Inherited => {}
-            ast::Private => {
-                self.tcx.sess.span_err(i.span, "unnecessary visibility \
-                                                qualifier");
-            }
             ast::Public => {
                 if self.in_fn {
                     self.tcx.sess.span_err(i.span, "unnecessary `pub`, imports \
@@ -1036,25 +1019,6 @@ fn check_sane_privacy(&self, item: &ast::Item) {
                 }
             }
         };
-        let check_not_priv = |sp: Span, vis: ast::Visibility, note: &str| {
-            if vis == ast::Private {
-                tcx.sess.span_err(sp, "unnecessary `priv` qualifier");
-                if note.len() > 0 {
-                    tcx.sess.span_note(sp, note);
-                }
-            }
-        };
-        let check_struct = |def: &@ast::StructDef| {
-            for f in def.fields.iter() {
-                match f.node.kind {
-                    ast::NamedField(_, ast::Private) => {
-                        tcx.sess.span_err(f.span, "unnecessary `priv` \
-                                                   visibility");
-                    }
-                    ast::NamedField(..) | ast::UnnamedField(..) => {}
-                }
-            }
-        };
         match item.node {
             // implementations of traits don't need visibility qualifiers because
             // that's controlled by having the trait in scope.
@@ -1067,22 +1031,14 @@ fn check_sane_privacy(&self, item: &ast::Item) {
                 }
             }
 
-            ast::ItemImpl(_, _, _, ref methods) => {
+            ast::ItemImpl(..) => {
                 check_inherited(item.span, item.vis,
                                 "place qualifiers on individual methods instead");
-                for i in methods.iter() {
-                    check_not_priv(i.span, i.vis, "functions are private by \
-                                                   default");
-                }
             }
-            ast::ItemForeignMod(ref fm) => {
+            ast::ItemForeignMod(..) => {
                 check_inherited(item.span, item.vis,
                                 "place qualifiers on individual functions \
                                  instead");
-                for i in fm.items.iter() {
-                    check_not_priv(i.span, i.vis, "functions are private by \
-                                                   default");
-                }
             }
 
             ast::ItemEnum(ref def, _) => {
@@ -1094,24 +1050,11 @@ fn check_sane_privacy(&self, item: &ast::Item) {
                                                            visibility");
                             }
                         }
-                        ast::Private => {
-                            if item.vis != ast::Public {
-                                tcx.sess.span_err(v.span, "unnecessary `priv` \
-                                                           visibility");
-                            }
-                        }
                         ast::Inherited => {}
                     }
-
-                    match v.node.kind {
-                        ast::StructVariantKind(ref s) => check_struct(s),
-                        ast::TupleVariantKind(..) => {}
-                    }
                 }
             }
 
-            ast::ItemStruct(ref def, _) => check_struct(def),
-
             ast::ItemTrait(_, _, ref methods) => {
                 for m in methods.iter() {
                     match *m {
@@ -1124,12 +1067,9 @@ fn check_sane_privacy(&self, item: &ast::Item) {
                 }
             }
 
-            ast::ItemStatic(..) |
+            ast::ItemStatic(..) | ast::ItemStruct(..) |
             ast::ItemFn(..) | ast::ItemMod(..) | ast::ItemTy(..) |
-            ast::ItemMac(..) => {
-                check_not_priv(item.span, item.vis, "items are private by \
-                                                     default");
-            }
+            ast::ItemMac(..) => {}
         }
     }
 
index e5b13adb4d0dc9d827f1753b47677f605f74db0a..9c00b8adfa3311da96c389aeec09d8905a3aa54f 100644 (file)
@@ -1421,12 +1421,8 @@ fn build_reduced_graph_for_variant(&mut self,
                                        variant: &Variant,
                                        item_id: DefId,
                                        parent: ReducedGraphParent,
-                                       parent_public: bool) {
+                                       is_public: bool) {
         let ident = variant.node.name;
-        // FIXME: this is unfortunate to have to do this privacy calculation
-        //      here. This should be living in middle::privacy, but it's
-        //      necessary to keep around in some form becaues of glob imports...
-        let is_public = parent_public && variant.node.vis != ast::Private;
 
         match variant.node.kind {
             TupleVariantKind(_) => {
@@ -1668,12 +1664,11 @@ fn handle_external_def(&mut self,
             // We assume the parent is visible, or else we wouldn't have seen
             // it. Also variants are public-by-default if the parent was also
             // public.
-            let is_public = vis != ast::Private;
             if is_struct {
-                child_name_bindings.define_type(def, DUMMY_SP, is_public);
+                child_name_bindings.define_type(def, DUMMY_SP, true);
                 self.structs.insert(variant_id);
             } else {
-                child_name_bindings.define_value(def, DUMMY_SP, is_public);
+                child_name_bindings.define_value(def, DUMMY_SP, true);
             }
           }
           DefFn(..) | DefStaticMethod(..) | DefStatic(..) => {
index 5104ce81465ba829b3fc87928c7b9cf2f54a01ca..1de53ecc68f3a2346f1f5801f46fdc8025dc8d3a 100644 (file)
@@ -41,7 +41,7 @@ pub fn new(name: Option<Ident>) -> Module {
         Module {
             name       : name,
             id: 0,
-            vis: ast::Private,
+            vis: ast::Inherited,
             where: syntax::codemap::DUMMY_SP,
             attrs      : Vec::new(),
             structs    : Vec::new(),
index ca55d1f04ad2f16715d49ff9e8c04efcbf262d55..cf989f72011395b768617edc799a187c2639d3da 100644 (file)
@@ -507,7 +507,6 @@ impl fmt::Show for VisSpace {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self.get() {
             Some(ast::Public) => write!(f.buf, "pub "),
-            Some(ast::Private) => write!(f.buf, "priv "),
             Some(ast::Inherited) | None => Ok(())
         }
     }
index 1674902fb96592eeb6c38e6b25b00dd5952c7b18..33c0f2c46bb5ecbf48562d17f3f3e79e5c9deb46 100644 (file)
@@ -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
         }
     }
 }
index 88480c1b336a4a6d3cf3543bf80bc18382a721ae..634e1c77c6af33a070b4155726d05e40dd0fe3d2 100644 (file)
@@ -39,7 +39,7 @@
 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 @@ fn parse_struct_decl_field(&mut self) -> StructField {
 
         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 @@ fn parse_struct_decl_field(&mut self) -> StructField {
     // 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 }
     }
 
index f2f0df00ee4787fdd17efa2815acc1124bb5ea48..53b6c09e5a30ebe63e9df27c1784f584b0e6dfbd 100644 (file)
@@ -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 @@ pub fn print_variants(&mut self,
 
     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/test/auxiliary/private_variant_1.rs b/src/test/auxiliary/private_variant_1.rs
deleted file mode 100644 (file)
index f711af4..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-mod super_sekrit {
-    pub enum sooper_sekrit {
-        quux, priv baz
-    }
-}
diff --git a/src/test/auxiliary/private_variant_xc.rs b/src/test/auxiliary/private_variant_xc.rs
deleted file mode 100644 (file)
index f9308ff..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-pub enum Foo {
-    Bar,
-    priv Baz,
-}
diff --git a/src/test/auxiliary/unreachable-variant.rs b/src/test/auxiliary/unreachable-variant.rs
new file mode 100644 (file)
index 0000000..8ca85f2
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+mod super_sekrit {
+    pub enum sooper_sekrit {
+        quux, baz
+    }
+}
index 4a392960a6533d42a5c789916dd4e06e77082ec0..453d7ffdad5c3249945623fb8b4c651b2722fb3c 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 struct cat {
-  priv meows : uint,
+  meows : uint,
 
   how_hungry : int,
 }
index 5d8932c6e6fa8fbd677b6288f438610ea48108d3..90f977168e9276b61c19ffb01984f8d0d341162f 100644 (file)
@@ -13,7 +13,7 @@ trait noisy {
 }
 
 struct cat {
-  priv meows : uint,
+  meows : uint,
 
   how_hungry : int,
   name : ~str,
index b9e7004bd7ca42b4fc8992df980a0e5e8ea79bc5..0e75e702277a3269655d1add835706c3c917d080 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 struct cat {
-  priv meows : uint,
+  meows : uint,
 }
 
 impl cat {
index 61980abdfe7af882486be4e7f9a338485883ceac..c5453f79de24b59038f303b5192a892053969457 100644 (file)
@@ -8,12 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use zoo::{duck, goose}; //~ ERROR: variant `goose` is private
+use zoo::{duck, goose};
 
 mod zoo {
     pub enum bird {
         pub duck, //~ ERROR: unnecessary `pub` visibility
-        priv goose
+        goose
     }
 }
 
index da90c4ee7531e92f83758f6482ab429b694950f6..3c6a1a7b27557ce54a7390877cd65e9e263bd08a 100644 (file)
@@ -9,15 +9,12 @@
 // except according to those terms.
 
 pub extern crate std; //~ ERROR: `pub` visibility is not allowed
-priv extern crate std; //~ ERROR: unnecessary visibility qualifier
 extern crate std;
 
 pub use std::bool;
-priv use std::bool; //~ ERROR: unnecessary visibility qualifier
 use std::bool;
 
 fn main() {
     pub use std::bool; //~ ERROR: imports in functions are never reachable
-    priv use std::bool; //~ ERROR: unnecessary visibility qualifier
     use std::bool;
 }
index bf8933220bcd6165425e8937de703b8fd80c40c1..db145be6ebd24b9a1f8b49503aaadb0677b39e1b 100644 (file)
@@ -109,8 +109,6 @@ pub enum PubBaz { //~ ERROR: missing documentation
         pub a: int, //~ ERROR: missing documentation
         b: int
     },
-
-    priv PubBazB
 }
 
 /// dox
@@ -121,7 +119,6 @@ pub enum PubBaz2 {
         pub a: int,
         b: int
     },
-    priv PubBaz2B
 }
 
 #[allow(missing_doc)]
@@ -130,7 +127,6 @@ pub enum PubBaz3 {
         pub a: int,
         b: int
     },
-    priv PubBaz3B
 }
 
 #[doc(hidden)]
index 7c387d0cf5642cac305150c28cb5f04da7984ea5..4a4032d2ab932ddbddb3e99fc7e81d8f86427492 100644 (file)
@@ -60,11 +60,6 @@ pub enum Baz {
         pub x: Private<int>, //~ ERROR private type in exported type signature
         y: Private<int>
     },
-
-    priv Baz3(Private<int>),
-    priv Baz4 {
-        x: Private<int>,
-    }
 }
 
 enum Qux {
index 0aba36eebee8a7804d78fe71330d38d5603badb0..45d13bd7996a8eb922bc0335efa2fa4c4cf872b1 100644 (file)
@@ -38,7 +38,6 @@ trait B {
     impl B for int { fn foo() -> int { 3 } }
 
     pub enum Enum {
-        priv Priv,
         Pub
     }
 
@@ -64,7 +63,6 @@ fn bar() {}
     }
 
     fn test() {
-        self::Priv;
         self::Pub;
         unsafe {
             epriv();
@@ -120,7 +118,6 @@ fn test() {
                                 //~^ NOTE: trait `B` is private
         ::lol();
 
-        ::bar::Priv; //~ ERROR: variant `Priv` is private
         ::bar::Pub;
 
         unsafe {
index 858227655955c614005dd4e23a08c5a84c571348..88ab73e1f9dcf8a137f998c330da11b230f50f88 100644 (file)
@@ -12,7 +12,7 @@
 
 mod kitties {
     pub struct cat {
-        priv meows : uint,
+        meows : uint,
 
         how_hungry : int,
     }
diff --git a/src/test/compile-fail/private-variant-xc.rs b/src/test/compile-fail/private-variant-xc.rs
deleted file mode 100644 (file)
index fb80c31..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// aux-build:private_variant_xc.rs
-
-extern crate private_variant_xc;
-
-pub fn main() {
-    let _ = private_variant_xc::Bar;
-    let _ = private_variant_xc::Baz;    //~ ERROR variant `Baz` is private
-}
diff --git a/src/test/compile-fail/private-variant.rs b/src/test/compile-fail/private-variant.rs
deleted file mode 100644 (file)
index d63d04c..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-mod a {
-    pub enum Waffle {
-        Belgian,
-        Brussels,
-        priv Liege
-    }
-}
-
-fn main() {
-    let x = a::Liege;   //~ ERROR variant `Liege` is private
-}
diff --git a/src/test/compile-fail/private_variant_2.rs b/src/test/compile-fail/private_variant_2.rs
deleted file mode 100644 (file)
index e4dd4b7..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// aux-build:private_variant_1.rs
-
-extern crate private_variant_1;
-
-fn main() {
-    let _x = private_variant_1::super_sekrit::baz; //~ ERROR is private
-}
diff --git a/src/test/compile-fail/removed-syntax-priv-group.rs b/src/test/compile-fail/removed-syntax-priv-group.rs
deleted file mode 100644 (file)
index 8fbad2d..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-struct sss {
-    bar: int,
-    priv {
-    //~^ ERROR expected ident
-        foo: ()
-    }
-}
index 69a33922776e121e0559f79789ff9741149c4d23..abbb084dbc043ca6ada2e68da961e6ea1508b5cf 100644 (file)
@@ -19,7 +19,7 @@ pub fn foo() {} //~ ERROR: visibility has no effect
     }
 
     struct D {
-        priv foo: int, //~ ERROR: visibility has no effect
+        pub foo: int, //~ ERROR: visibility has no effect
     }
     pub fn foo() {} //~ ERROR: visibility has no effect
     pub mod bar {} //~ ERROR: visibility has no effect
diff --git a/src/test/compile-fail/unreachable-variant.rs b/src/test/compile-fail/unreachable-variant.rs
new file mode 100644 (file)
index 0000000..566b888
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:unreachable-variant.rs
+
+extern crate other = "unreachable-variant";
+
+fn main() {
+    let _x = other::super_sekrit::baz; //~ ERROR is private
+}
index 5a4dd42f49d3d892942f81b25e495c893a973e73..bb39107463e11ea1725a76a22fb46928b0a9d263 100644 (file)
@@ -9,9 +9,7 @@
 // except according to those terms.
 
 struct A { pub i: int }
-struct B { priv i: int }        //~ ERROR: unnecessary `priv`
 pub enum C { pub Variant }      //~ ERROR: unnecessary `pub`
-enum D { priv Variant2 }        //~ ERROR: unnecessary `priv`
 
 pub trait E {
     pub fn foo() {}             //~ ERROR: unnecessary visibility