rustc: Remove private enum variants
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
This commit is contained in:
parent
83351fa02e
commit
5cfbc0e7ae
27 changed files with 31 additions and 198 deletions
|
|
@ -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,
|
||||
}
|
||||
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
mod super_sekrit {
|
||||
pub enum sooper_sekrit {
|
||||
quux, priv baz
|
||||
quux, baz
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct cat {
|
||||
priv meows : uint,
|
||||
meows : uint,
|
||||
|
||||
how_hungry : int,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ trait noisy {
|
|||
}
|
||||
|
||||
struct cat {
|
||||
priv meows : uint,
|
||||
meows : uint,
|
||||
|
||||
how_hungry : int,
|
||||
name : ~str,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct cat {
|
||||
priv meows : uint,
|
||||
meows : uint,
|
||||
}
|
||||
|
||||
impl cat {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ mod bar {
|
|||
impl B for int { fn foo() -> int { 3 } }
|
||||
|
||||
pub enum Enum {
|
||||
priv Priv,
|
||||
Pub
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +63,6 @@ mod bar {
|
|||
}
|
||||
|
||||
fn test() {
|
||||
self::Priv;
|
||||
self::Pub;
|
||||
unsafe {
|
||||
epriv();
|
||||
|
|
@ -120,7 +118,6 @@ mod foo {
|
|||
//~^ NOTE: trait `B` is private
|
||||
::lol();
|
||||
|
||||
::bar::Priv; //~ ERROR: variant `Priv` is private
|
||||
::bar::Pub;
|
||||
|
||||
unsafe {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
mod kitties {
|
||||
pub struct cat {
|
||||
priv meows : uint,
|
||||
meows : uint,
|
||||
|
||||
how_hungry : int,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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: ()
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ fn main() {
|
|||
}
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:private_variant_1.rs
|
||||
// aux-build:unreachable-variant.rs
|
||||
|
||||
extern crate private_variant_1;
|
||||
extern crate other = "unreachable-variant";
|
||||
|
||||
fn main() {
|
||||
let _x = private_variant_1::super_sekrit::baz; //~ ERROR is private
|
||||
let _x = other::super_sekrit::baz; //~ ERROR is private
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue