about summary refs log tree commit diff
path: root/src/libstd/fmt
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-03-31 15:51:33 -0700
committerbors <bors@rust-lang.org>2014-03-31 15:51:33 -0700
commitb8ef9fd9c9f642ce7b8aed82782a1ed745d08d64 (patch)
tree1e66451d207e19694d62608a8e1724c71796dc00 /src/libstd/fmt
parenta7e057d402a345f547e67a326871621472d04035 (diff)
parent37a3131640d0fa2633aa26db7f849d110250ce51 (diff)
downloadrust-b8ef9fd9c9f642ce7b8aed82782a1ed745d08d64.tar.gz
rust-b8ef9fd9c9f642ce7b8aed82782a1ed745d08d64.zip
auto merge of #13184 : alexcrichton/rust/priv-fields, r=brson
This is an implementation of a portion of [RFC #4](https://github.com/rust-lang/rfcs/blob/master/active/0004-private-fields.md). This PR makes named struct fields private by default (as opposed to inherited by default).

The only real meaty change is the first commit to `rustc`, all other commits are just fallout of that change.

Summary of changes made:

* Named fields are private by default *everywhere*
* The `priv` keyword is now default-deny on named fields (done in a "lint" pass in privacy)

Changes yet to be done (before the RFC is closed)

* Change tuple structs to have private fields by default
* Remove `priv` enum variants
* Make `priv` a reserved keyword
Diffstat (limited to 'src/libstd/fmt')
-rw-r--r--src/libstd/fmt/mod.rs24
-rw-r--r--src/libstd/fmt/num.rs2
-rw-r--r--src/libstd/fmt/parse.rs34
-rw-r--r--src/libstd/fmt/rt.rs24
4 files changed, 42 insertions, 42 deletions
diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs
index c2a6510d656..5f8a043b830 100644
--- a/src/libstd/fmt/mod.rs
+++ b/src/libstd/fmt/mod.rs
@@ -508,20 +508,20 @@ pub type Result = io::IoResult<()>;
 /// traits.
 pub struct Formatter<'a> {
     /// Flags for formatting (packed version of rt::Flag)
-    flags: uint,
+    pub flags: uint,
     /// Character used as 'fill' whenever there is alignment
-    fill: char,
+    pub fill: char,
     /// Boolean indication of whether the output should be left-aligned
-    align: parse::Alignment,
+    pub align: parse::Alignment,
     /// Optionally specified integer width that the output should be
-    width: Option<uint>,
+    pub width: Option<uint>,
     /// Optionally specified precision for numeric types
-    precision: Option<uint>,
+    pub precision: Option<uint>,
 
     /// Output buffer.
-    buf: &'a mut io::Writer,
-    priv curarg: slice::Items<'a, Argument<'a>>,
-    priv args: &'a [Argument<'a>],
+    pub buf: &'a mut io::Writer,
+    curarg: slice::Items<'a, Argument<'a>>,
+    args: &'a [Argument<'a>],
 }
 
 /// This struct represents the generic "argument" which is taken by the Xprintf
@@ -529,8 +529,8 @@ pub struct Formatter<'a> {
 /// compile time it is ensured that the function and the value have the correct
 /// types, and then this struct is used to canonicalize arguments to one type.
 pub struct Argument<'a> {
-    priv formatter: extern "Rust" fn(&any::Void, &mut Formatter) -> Result,
-    priv value: &'a any::Void,
+    formatter: extern "Rust" fn(&any::Void, &mut Formatter) -> Result,
+    value: &'a any::Void,
 }
 
 impl<'a> Arguments<'a> {
@@ -555,8 +555,8 @@ impl<'a> Arguments<'a> {
 /// string at compile-time so usage of the `write` and `format` functions can
 /// be safely performed.
 pub struct Arguments<'a> {
-    priv fmt: &'a [rt::Piece<'a>],
-    priv args: &'a [Argument<'a>],
+    fmt: &'a [rt::Piece<'a>],
+    args: &'a [Argument<'a>],
 }
 
 /// When a format is not otherwise specified, types are formatted by ascribing
diff --git a/src/libstd/fmt/num.rs b/src/libstd/fmt/num.rs
index 4b35a7596c9..b10a9584df9 100644
--- a/src/libstd/fmt/num.rs
+++ b/src/libstd/fmt/num.rs
@@ -108,7 +108,7 @@ radix!(UpperHex, 16, "0x", x @  0 .. 9 => '0' as u8 + x,
 /// A radix with in the range of `2..36`.
 #[deriving(Clone, Eq)]
 pub struct Radix {
-    priv base: u8,
+    base: u8,
 }
 
 impl Radix {
diff --git a/src/libstd/fmt/parse.rs b/src/libstd/fmt/parse.rs
index 384e2ff2380..4752f3a75f4 100644
--- a/src/libstd/fmt/parse.rs
+++ b/src/libstd/fmt/parse.rs
@@ -37,30 +37,30 @@ pub enum Piece<'a> {
 #[deriving(Eq)]
 pub struct Argument<'a> {
     /// Where to find this argument
-    position: Position<'a>,
+    pub position: Position<'a>,
     /// How to format the argument
-    format: FormatSpec<'a>,
+    pub format: FormatSpec<'a>,
     /// If not `None`, what method to invoke on the argument
-    method: Option<~Method<'a>>
+    pub method: Option<~Method<'a>>
 }
 
 /// Specification for the formatting of an argument in the format string.
 #[deriving(Eq)]
 pub struct FormatSpec<'a> {
     /// Optionally specified character to fill alignment with
-    fill: Option<char>,
+    pub fill: Option<char>,
     /// Optionally specified alignment
-    align: Alignment,
+    pub align: Alignment,
     /// Packed version of various flags provided
-    flags: uint,
+    pub flags: uint,
     /// The integer precision to use
-    precision: Count<'a>,
+    pub precision: Count<'a>,
     /// The string width requested for the resulting format
-    width: Count<'a>,
+    pub width: Count<'a>,
     /// The descriptor string representing the name of the format desired for
     /// this argument, this can be empty or any number of characters, although
     /// it is required to be one word.
-    ty: &'a str
+    pub ty: &'a str
 }
 
 /// Enum describing where an argument for a format can be located.
@@ -154,9 +154,9 @@ pub enum PluralSelector {
 pub struct PluralArm<'a> {
     /// A selector can either be specified by a keyword or with an integer
     /// literal.
-    selector: PluralSelector,
+    pub selector: PluralSelector,
     /// Array of pieces which are the format of this arm
-    result: ~[Piece<'a>],
+    pub result: ~[Piece<'a>],
 }
 
 /// Enum of the 5 CLDR plural keywords. There is one more, "other", but that
@@ -182,9 +182,9 @@ pub enum PluralKeyword {
 #[deriving(Eq)]
 pub struct SelectArm<'a> {
     /// String selector which guards this arm
-    selector: &'a str,
+    pub selector: &'a str,
     /// Array of pieces which are the format of this arm
-    result: ~[Piece<'a>],
+    pub result: ~[Piece<'a>],
 }
 
 /// The parser structure for interpreting the input format string. This is
@@ -194,11 +194,11 @@ pub struct SelectArm<'a> {
 /// This is a recursive-descent parser for the sake of simplicity, and if
 /// necessary there's probably lots of room for improvement performance-wise.
 pub struct Parser<'a> {
-    priv input: &'a str,
-    priv cur: str::CharOffsets<'a>,
-    priv depth: uint,
+    input: &'a str,
+    cur: str::CharOffsets<'a>,
+    depth: uint,
     /// Error messages accumulated during parsing
-    errors: ~[~str],
+    pub errors: ~[~str],
 }
 
 impl<'a> Iterator<Piece<'a>> for Parser<'a> {
diff --git a/src/libstd/fmt/rt.rs b/src/libstd/fmt/rt.rs
index 2a2515754b4..01c2c06c3fb 100644
--- a/src/libstd/fmt/rt.rs
+++ b/src/libstd/fmt/rt.rs
@@ -28,17 +28,17 @@ pub enum Piece<'a> {
 }
 
 pub struct Argument<'a> {
-    position: Position,
-    format: FormatSpec,
-    method: Option<&'a Method<'a>>
+    pub position: Position,
+    pub format: FormatSpec,
+    pub method: Option<&'a Method<'a>>
 }
 
 pub struct FormatSpec {
-    fill: char,
-    align: parse::Alignment,
-    flags: uint,
-    precision: Count,
-    width: Count,
+    pub fill: char,
+    pub align: parse::Alignment,
+    pub flags: uint,
+    pub precision: Count,
+    pub width: Count,
 }
 
 pub enum Count {
@@ -60,11 +60,11 @@ pub enum PluralSelector {
 }
 
 pub struct PluralArm<'a> {
-    selector: PluralSelector,
-    result: &'a [Piece<'a>],
+    pub selector: PluralSelector,
+    pub result: &'a [Piece<'a>],
 }
 
 pub struct SelectArm<'a> {
-    selector: &'a str,
-    result: &'a [Piece<'a>],
+    pub selector: &'a str,
+    pub result: &'a [Piece<'a>],
 }