]> git.lizzy.rs Git - rust.git/commitdiff
Forbid `priv` where it has no effect
authorAlex Crichton <alex@alexcrichton.com>
Wed, 7 Aug 2013 06:03:31 +0000 (23:03 -0700)
committerCorey Richardson <corey@octayn.net>
Thu, 8 Aug 2013 02:41:12 +0000 (22:41 -0400)
This is everywhere except struct fields and enum variants.

17 files changed:
src/libextra/fileinput.rs
src/libextra/future.rs
src/libextra/getopts.rs
src/libextra/num/bigint.rs
src/libextra/stats.rs
src/libextra/term.rs
src/libextra/terminfo/parm.rs
src/libextra/time.rs
src/librustc/middle/typeck/rscope.rs
src/libstd/comm.rs
src/libstd/num/strconv.rs
src/libstd/run.rs
src/libstd/str.rs
src/libstd/str/ascii.rs
src/libsyntax/parse/obsolete.rs
src/libsyntax/parse/parser.rs
src/test/run-pass/class-cast-to-trait-multiple-types.rs

index 7a36b25eac57a53b32bb877c21e69bb60e97c109..14b02688cffcfc1481ff2927727b3ab5c0981a1e 100644 (file)
@@ -129,27 +129,27 @@ struct FileInput_ {
     `Some(path)` is the file represented by `path`, `None` is
     `stdin`. Consumed as the files are read.
     */
-    priv files: ~[Option<Path>],
+    files: ~[Option<Path>],
     /**
     The current file: `Some(r)` for an open file, `None` before
     starting and after reading everything.
     */
-    priv current_reader: Option<@io::Reader>,
-    priv state: FileInputState,
+    current_reader: Option<@io::Reader>,
+    state: FileInputState,
 
     /**
     Used to keep track of whether we need to insert the newline at the
     end of a file that is missing it, which is needed to separate the
     last and first lines.
     */
-    priv previous_was_newline: bool
+    previous_was_newline: bool
 }
 
 // XXX: remove this when Reader has &mut self. Should be removable via
 // "self.fi." -> "self." and renaming FileInput_. Documentation above
 // will likely have to be updated to use `let mut in = ...`.
 pub struct FileInput  {
-    priv fi: @mut FileInput_
+    fi: @mut FileInput_
 }
 
 impl FileInput {
@@ -198,7 +198,7 @@ pub fn from_args() -> FileInput {
         FileInput::from_vec(pathed)
     }
 
-    priv fn current_file_eof(&self) -> bool {
+    fn current_file_eof(&self) -> bool {
         match self.fi.current_reader {
             None => false,
             Some(r) => r.eof()
@@ -240,7 +240,7 @@ pub fn next_file(&self) -> bool {
     Returns `true` if it had to move to the next file and did
     so successfully.
     */
-    priv fn next_file_if_eof(&self) -> bool {
+    fn next_file_if_eof(&self) -> bool {
         match self.fi.current_reader {
             None => self.next_file(),
             Some(r) => {
index 7d2a0658969ab7cc62ea8273fc0c5d3d85c61432..cc65c49d73a9c2b569619591a145df84c8036d3f 100644 (file)
@@ -46,7 +46,7 @@ impl<A> Drop for Future<A> {
     fn drop(&self) {}
 }
 
-priv enum FutureState<A> {
+enum FutureState<A> {
     Pending(~fn() -> A),
     Evaluating,
     Forced(A)
index 15aac8ef47c9e660dd59ac98ab0e947f0951b1c9..8bd9d857d6957135724c0acf978926dd61bc0647 100644 (file)
@@ -708,9 +708,9 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> ~str {
      *  Fails during iteration if the string contains a non-whitespace
      *  sequence longer than the limit.
      */
-    priv fn each_split_within<'a>(ss: &'a str,
-                                lim: uint,
-                                it: &fn(&'a str) -> bool) -> bool {
+    fn each_split_within<'a>(ss: &'a str,
+                             lim: uint,
+                             it: &fn(&'a str) -> bool) -> bool {
         // Just for fun, let's write this as an state machine:
 
         enum SplitWithinState {
@@ -778,7 +778,7 @@ enum LengthLimit {
     }
 
     #[test]
-    priv fn test_split_within() {
+    fn test_split_within() {
         fn t(s: &str, i: uint, u: &[~str]) {
             let mut v = ~[];
             do each_split_within(s, i) |s| { v.push(s.to_owned()); true };
index c3737d44e385ff8f5686345b0027686e51f24d05..0c8701bd0b515b1db16a6dc7dc5f0b958cdb0558 100644 (file)
@@ -59,13 +59,13 @@ pub mod BigDigit {
     pub static bits: uint = 32;
 
     pub static base: uint = 1 << bits;
-    priv static hi_mask: uint = (-1 as uint) << bits;
-    priv static lo_mask: uint = (-1 as uint) >> bits;
+    static hi_mask: uint = (-1 as uint) << bits;
+    static lo_mask: uint = (-1 as uint) >> bits;
 
 
-    priv fn get_hi(n: uint) -> BigDigit { (n >> bits) as BigDigit }
+    fn get_hi(n: uint) -> BigDigit { (n >> bits) as BigDigit }
 
-    priv fn get_lo(n: uint) -> BigDigit { (n & lo_mask) as BigDigit }
+    fn get_lo(n: uint) -> BigDigit { (n & lo_mask) as BigDigit }
 
     /// Split one machine sized unsigned integer into two BigDigits.
 
@@ -613,7 +613,7 @@ pub fn to_uint(&self) -> uint {
     }
 
 
-    priv fn shl_unit(&self, n_unit: uint) -> BigUint {
+    fn shl_unit(&self, n_unit: uint) -> BigUint {
         if n_unit == 0 || self.is_zero() { return (*self).clone(); }
 
         return BigUint::new(vec::from_elem(n_unit, ZERO_BIG_DIGIT)
@@ -621,7 +621,7 @@ pub fn to_uint(&self) -> uint {
     }
 
 
-    priv fn shl_bits(&self, n_bits: uint) -> BigUint {
+    fn shl_bits(&self, n_bits: uint) -> BigUint {
         if n_bits == 0 || self.is_zero() { return (*self).clone(); }
 
         let mut carry = 0;
@@ -637,7 +637,7 @@ pub fn to_uint(&self) -> uint {
     }
 
 
-    priv fn shr_unit(&self, n_unit: uint) -> BigUint {
+    fn shr_unit(&self, n_unit: uint) -> BigUint {
         if n_unit == 0 { return (*self).clone(); }
         if self.data.len() < n_unit { return Zero::zero(); }
         return BigUint::from_slice(
@@ -646,7 +646,7 @@ pub fn to_uint(&self) -> uint {
     }
 
 
-    priv fn shr_bits(&self, n_bits: uint) -> BigUint {
+    fn shr_bits(&self, n_bits: uint) -> BigUint {
         if n_bits == 0 || self.data.is_empty() { return (*self).clone(); }
 
         let mut borrow = 0;
@@ -661,7 +661,7 @@ pub fn to_uint(&self) -> uint {
 
 #[cfg(target_arch = "x86_64")]
 
-priv fn get_radix_base(radix: uint) -> (uint, uint) {
+fn get_radix_base(radix: uint) -> (uint, uint) {
     assert!(1 < radix && radix <= 16);
     match radix {
         2  => (4294967296, 32),
@@ -687,7 +687,7 @@ pub fn to_uint(&self) -> uint {
 #[cfg(target_arch = "x86")]
 #[cfg(target_arch = "mips")]
 
-priv fn get_radix_base(radix: uint) -> (uint, uint) {
+fn get_radix_base(radix: uint) -> (uint, uint) {
     assert!(1 < radix && radix <= 16);
     match radix {
         2  => (65536, 16),
index 9238034cba33ccced0408caee1a27a93d0eec06e..881d931fe0acc21749287991d5826564c8ded3c8 100644 (file)
@@ -223,7 +223,7 @@ fn iqr(self) -> f64 {
 
 // Helper function: extract a value representing the `pct` percentile of a sorted sample-set, using
 // linear interpolation. If samples are not sorted, return nonsensical value.
-priv fn percentile_of_sorted(sorted_samples: &[f64],
+fn percentile_of_sorted(sorted_samples: &[f64],
                              pct: f64) -> f64 {
     assert!(sorted_samples.len() != 0);
     if sorted_samples.len() == 1 {
index 2173eb838e5ee9e65f72199944429335cd3924db..d0412b8954db2abc963e43f87979ca96503709c8 100644 (file)
@@ -75,7 +75,7 @@ pub enum Attr {
 }
 
 #[cfg(not(target_os = "win32"))]
-priv fn cap_for_attr(attr: attr::Attr) -> &'static str {
+fn cap_for_attr(attr: attr::Attr) -> &'static str {
     match attr {
         attr::Bold               => "bold",
         attr::Dim                => "dim",
@@ -234,7 +234,7 @@ pub fn reset(&self) {
         }
     }
 
-    priv fn dim_if_necessary(&self, color: color::Color) -> color::Color {
+    fn dim_if_necessary(&self, color: color::Color) -> color::Color {
         if color >= self.num_colors && color >= 8 && color < 16 {
             color-8
         } else { color }
index b619e0f33b644663bb43ba781c3688411f3f1679..0929575ee9e70bc1eb089e56b0d248d0f70f360c 100644 (file)
@@ -430,7 +430,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
 }
 
 #[deriving(Eq)]
-priv struct Flags {
+struct Flags {
     width: uint,
     precision: uint,
     alternate: bool,
@@ -440,13 +440,13 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
 }
 
 impl Flags {
-    priv fn new() -> Flags {
+    fn new() -> Flags {
         Flags{ width: 0, precision: 0, alternate: false,
                left: false, sign: false, space: false }
     }
 }
 
-priv enum FormatOp {
+enum FormatOp {
     FormatDigit,
     FormatOctal,
     FormatHex,
@@ -455,7 +455,7 @@ impl Flags {
 }
 
 impl FormatOp {
-    priv fn from_char(c: char) -> FormatOp {
+    fn from_char(c: char) -> FormatOp {
         match c {
             'd' => FormatDigit,
             'o' => FormatOctal,
@@ -465,7 +465,7 @@ impl FormatOp {
             _ => fail!("bad FormatOp char")
         }
     }
-    priv fn to_char(self) -> char {
+    fn to_char(self) -> char {
         match self {
             FormatDigit => 'd',
             FormatOctal => 'o',
@@ -476,7 +476,7 @@ impl FormatOp {
     }
 }
 
-priv fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> {
+fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> {
     let mut s = match val {
         Number(d) => {
             match op {
index efc3dc87adc00f02887a3980fb20c7931cae69f6..f6a5fd98234b58aabab5898bdc13b9137c500ee3 100644 (file)
@@ -254,7 +254,7 @@ pub fn rfc3339(&self) -> ~str {
     }
 }
 
-priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
+fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
     fn match_str(s: &str, pos: uint, needle: &str) -> bool {
         let mut i = pos;
         for ch in needle.byte_iter() {
@@ -687,7 +687,7 @@ fn parse_type(s: &str, pos: uint, ch: char, tm: &mut Tm)
     }
 }
 
-priv fn do_strftime(format: &str, tm: &Tm) -> ~str {
+fn do_strftime(format: &str, tm: &Tm) -> ~str {
     fn parse_type(ch: char, tm: &Tm) -> ~str {
         //FIXME (#2350): Implement missing types.
       let die = || fmt!("strftime: can't understand this format %c ", ch);
index bbcf42b1c5d321b600eb4a1be6fa0f7411990c5b..c9e2b8dd37b9dfb02d6a3fdc83bccc19ea0b9cfa 100644 (file)
@@ -215,7 +215,7 @@ fn named_region(&self, span: span, id: ast::ident)
 pub struct type_rscope(Option<RegionParameterization>);
 
 impl type_rscope {
-    priv fn replacement(&self) -> ty::Region {
+    fn replacement(&self) -> ty::Region {
         if self.is_some() {
             ty::re_bound(ty::br_self)
         } else {
index 4356f1143da4668f760d598aa1f1d34d50cb8120..a4de10f8c7760aae76a718f95a74aab086ad7cb7 100644 (file)
@@ -314,7 +314,7 @@ mod pipesy {
 
     #[allow(non_camel_case_types)]
     pub mod oneshot {
-        priv use std::kinds::Send;
+        use std::kinds::Send;
         use ptr::to_mut_unsafe_ptr;
 
         pub fn init<T: Send>() -> (server::Oneshot<T>, client::Oneshot<T>) {
@@ -341,7 +341,7 @@ pub struct __Buffer<T> {
         #[allow(non_camel_case_types)]
         pub mod client {
 
-            priv use std::kinds::Send;
+            use std::kinds::Send;
 
             #[allow(non_camel_case_types)]
             pub fn try_send<T: Send>(pipe: Oneshot<T>, x_0: T) ->
@@ -489,7 +489,7 @@ pub fn try_send_one<T: Send>(chan: ChanOne<T>, data: T) -> bool {
 
     #[allow(non_camel_case_types)]
     pub mod streamp {
-        priv use std::kinds::Send;
+        use std::kinds::Send;
 
         pub fn init<T: Send>() -> (server::Open<T>, client::Open<T>) {
             pub use std::pipes::HasBuffer;
@@ -501,7 +501,7 @@ pub enum Open<T> { pub data(T, server::Open<T>), }
 
         #[allow(non_camel_case_types)]
         pub mod client {
-            priv use std::kinds::Send;
+            use std::kinds::Send;
 
             #[allow(non_camel_case_types)]
             pub fn try_data<T: Send>(pipe: Open<T>, x_0: T) ->
index 7ab3c81b61f7abd4e134e8f66ecafbff0187bf26..1f22343ad9c36063b8dc392120a4b3c451c15e45 100644 (file)
@@ -422,9 +422,9 @@ pub fn float_to_str_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Float+Round+
 
 // Some constants for from_str_bytes_common's input validation,
 // they define minimum radix values for which the character is a valid digit.
-priv static DIGIT_P_RADIX: uint = ('p' as uint) - ('a' as uint) + 11u;
-priv static DIGIT_I_RADIX: uint = ('i' as uint) - ('a' as uint) + 11u;
-priv static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u;
+static DIGIT_P_RADIX: uint = ('p' as uint) - ('a' as uint) + 11u;
+static DIGIT_I_RADIX: uint = ('i' as uint) - ('a' as uint) + 11u;
+static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u;
 
 /**
  * Parses a byte slice as a number. This is meant to
index 694aa672af7b3361365c6feb6818cca6229e188c..99cf96eaae2fff4be0fcdd9d72a4714c5ff2f06b 100644 (file)
@@ -761,14 +761,14 @@ fn with_dirp<T>(d: Option<&Path>,
 }
 
 #[cfg(windows)]
-priv fn free_handle(handle: *()) {
+fn free_handle(handle: *()) {
     unsafe {
         libc::funcs::extra::kernel32::CloseHandle(cast::transmute(handle));
     }
 }
 
 #[cfg(unix)]
-priv fn free_handle(_handle: *()) {
+fn free_handle(_handle: *()) {
     // unix has no process handle object, just a pid
 }
 
@@ -823,7 +823,7 @@ pub fn process_output(prog: &str, args: &[~str]) -> ProcessOutput {
  * operate on a none-existant process or, even worse, on a newer process
  * with the same id.
  */
-priv fn waitpid(pid: pid_t) -> int {
+fn waitpid(pid: pid_t) -> int {
     return waitpid_os(pid);
 
     #[cfg(windows)]
index c4bd2c5435a28a6193304b9bffbe945d5d8b7695..fa75916fb8640e10785c53b3e70c6c69aab93a89 100644 (file)
@@ -738,7 +738,7 @@ pub fn count_bytes<'b>(s: &'b str, start: uint, n: uint) -> uint {
 }
 
 // https://tools.ietf.org/html/rfc3629
-priv static UTF8_CHAR_WIDTH: [u8, ..256] = [
+static UTF8_CHAR_WIDTH: [u8, ..256] = [
 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x1F
 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
@@ -781,15 +781,15 @@ macro_rules! utf8_acc_cont_byte(
 )
 
 // UTF-8 tags and ranges
-priv static TAG_CONT_U8: u8 = 128u8;
-priv static TAG_CONT: uint = 128u;
-priv static MAX_ONE_B: uint = 128u;
-priv static TAG_TWO_B: uint = 192u;
-priv static MAX_TWO_B: uint = 2048u;
-priv static TAG_THREE_B: uint = 224u;
-priv static MAX_THREE_B: uint = 65536u;
-priv static TAG_FOUR_B: uint = 240u;
-priv static MAX_UNICODE: uint = 1114112u;
+static TAG_CONT_U8: u8 = 128u8;
+static TAG_CONT: uint = 128u;
+static MAX_ONE_B: uint = 128u;
+static TAG_TWO_B: uint = 192u;
+static MAX_TWO_B: uint = 2048u;
+static TAG_THREE_B: uint = 224u;
+static MAX_THREE_B: uint = 65536u;
+static TAG_FOUR_B: uint = 240u;
+static MAX_UNICODE: uint = 1114112u;
 
 /// Unsafe operations
 pub mod raw {
index 1be4d07dfa477ccdf7056e1117362d7d2f6bab4c..6ededb02107d497bb77a2d0b91e1b11d70b84978 100644 (file)
@@ -274,7 +274,7 @@ pub fn to_ascii_lower(string: &str) -> ~str {
 }
 
 #[inline]
-priv fn map_bytes(string: &str, map: &'static [u8]) -> ~str {
+fn map_bytes(string: &str, map: &'static [u8]) -> ~str {
     let len = string.len();
     let mut result = str::with_capacity(len);
     unsafe {
@@ -298,7 +298,7 @@ pub fn eq_ignore_ascii_case(a: &str, b: &str) -> bool {
         |(byte_a, byte_b)| ASCII_LOWER_MAP[*byte_a] == ASCII_LOWER_MAP[*byte_b])
 }
 
-priv static ASCII_LOWER_MAP: &'static [u8] = &[
+static ASCII_LOWER_MAP: &'static [u8] = &[
     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
     0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
     0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
@@ -333,7 +333,7 @@ pub fn eq_ignore_ascii_case(a: &str, b: &str) -> bool {
     0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
 ];
 
-priv static ASCII_UPPER_MAP: &'static [u8] = &[
+static ASCII_UPPER_MAP: &'static [u8] = &[
     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
     0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
     0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
index ec956f61863765a56b25558b174fb8d7db965b97..dda5e990221eccf066d42a502637108f17bad179 100644 (file)
@@ -64,6 +64,7 @@ pub enum ObsoleteSyntax {
     ObsoleteMutWithMultipleBindings,
     ObsoleteExternVisibility,
     ObsoleteUnsafeExternFn,
+    ObsoletePrivVisibility,
 }
 
 impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -253,6 +254,10 @@ pub fn obsolete(&self, sp: span, kind: ObsoleteSyntax) {
                 "external functions are always unsafe; remove the `unsafe` \
                  keyword"
             ),
+            ObsoletePrivVisibility => (
+                "`priv` not necessary",
+                "an item without a visibility qualifier is private by default"
+            ),
         };
 
         self.report(sp, kind, kind_str, desc);
index 4902c4587ac39f8a02b3b06a09d62d45eeafb003..7d6dce22fb7b423553d034f8f718c373860d68c8 100644 (file)
@@ -85,7 +85,7 @@
 use parse::obsolete::{ObsoleteNamedExternModule, ObsoleteMultipleLocalDecl};
 use parse::obsolete::{ObsoleteMutWithMultipleBindings};
 use parse::obsolete::{ObsoleteExternVisibility, ObsoleteUnsafeExternFn};
-use parse::obsolete::{ParserObsoleteMethods};
+use parse::obsolete::{ParserObsoleteMethods, ObsoletePrivVisibility};
 use parse::token::{can_begin_expr, get_ident_interner, ident_to_str, is_ident};
 use parse::token::{is_ident_or_path};
 use parse::token::{is_plain_ident, INTERPOLATED, keywords, special_idents};
@@ -814,7 +814,7 @@ pub fn parse_trait_methods(&self) -> ~[trait_method] {
             let attrs = p.parse_outer_attributes();
             let lo = p.span.lo;
 
-            let vis = p.parse_visibility();
+            let vis = p.parse_non_priv_visibility();
             let pur = p.parse_fn_purity();
             // NB: at the moment, trait methods are public by default; this
             // could change.
@@ -3608,7 +3608,7 @@ fn parse_method(&self) -> @method {
         let attrs = self.parse_outer_attributes();
         let lo = self.span.lo;
 
-        let visa = self.parse_visibility();
+        let visa = self.parse_non_priv_visibility();
         let pur = self.parse_fn_purity();
         let ident = self.parse_ident();
         let generics = self.parse_generics();
@@ -3871,6 +3871,18 @@ fn parse_visibility(&self) -> visibility {
         else { inherited }
     }
 
+    // parse visibility, but emits an obsolete error if it's private
+    fn parse_non_priv_visibility(&self) -> visibility {
+        match self.parse_visibility() {
+            public => public,
+            inherited => inherited,
+            private => {
+                self.obsolete(*self.last_span, ObsoletePrivVisibility);
+                inherited
+            }
+        }
+    }
+
     fn parse_staticness(&self) -> bool {
         if self.eat_keyword(keywords::Static) {
             self.obsolete(*self.last_span, ObsoleteStaticMethod);
@@ -4063,7 +4075,7 @@ fn eval_src_mod_from_path(&self,
     // parse a function declaration from a foreign module
     fn parse_item_foreign_fn(&self,  attrs: ~[Attribute]) -> @foreign_item {
         let lo = self.span.lo;
-        let vis = self.parse_visibility();
+        let vis = self.parse_non_priv_visibility();
 
         // Parse obsolete purity.
         let purity = self.parse_fn_purity();
@@ -4443,7 +4455,7 @@ fn parse_item_or_view_item(&self,
         maybe_whole!(iovi self, nt_item);
         let lo = self.span.lo;
 
-        let visibility = self.parse_visibility();
+        let visibility = self.parse_non_priv_visibility();
 
         // must be a view item:
         if self.eat_keyword(keywords::Use) {
@@ -4575,7 +4587,7 @@ fn parse_foreign_item(&self,
         maybe_whole!(iovi self, nt_item);
         let lo = self.span.lo;
 
-        let visibility = self.parse_visibility();
+        let visibility = self.parse_non_priv_visibility();
 
         if (self.is_keyword(keywords::Const) || self.is_keyword(keywords::Static)) {
             // FOREIGN CONST ITEM
index a5d7ba2c1aaa1bd1fee0783770f9d71d09bbc1e1..a134ffe49fd02f4f1ee2e75808ae0a8c2fbff2c5 100644 (file)
@@ -21,7 +21,7 @@ struct dog {
 }
 
 impl dog {
-    priv fn bark(&self) -> int {
+    fn bark(&self) -> int {
       info!("Woof %u %d", *self.barks, *self.volume);
       *self.barks += 1u;
       if *self.barks % 3u == 0u {