diff --git a/src/libextra/fileinput.rs b/src/libextra/fileinput.rs index 7a36b25eac57a..14b02688cffcf 100644 --- a/src/libextra/fileinput.rs +++ b/src/libextra/fileinput.rs @@ -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], + files: ~[Option], /** 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 @@ impl 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 @@ impl FileInput { 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) => { diff --git a/src/libextra/future.rs b/src/libextra/future.rs index 7d2a0658969ab..cc65c49d73a9c 100644 --- a/src/libextra/future.rs +++ b/src/libextra/future.rs @@ -46,7 +46,7 @@ impl Drop for Future { fn drop(&self) {} } -priv enum FutureState { +enum FutureState { Pending(~fn() -> A), Evaluating, Forced(A) diff --git a/src/libextra/getopts.rs b/src/libextra/getopts.rs index 15aac8ef47c9e..8bd9d857d6957 100644 --- a/src/libextra/getopts.rs +++ b/src/libextra/getopts.rs @@ -708,9 +708,9 @@ pub mod groups { * 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 @@ pub mod groups { } #[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 }; diff --git a/src/libextra/num/bigint.rs b/src/libextra/num/bigint.rs index bced00902c95f..dd5d0b0eac9fe 100644 --- a/src/libextra/num/bigint.rs +++ b/src/libextra/num/bigint.rs @@ -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 @@ impl BigUint { } - 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 @@ impl BigUint { } - 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 @@ impl BigUint { } - 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 @@ impl BigUint { } - 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 @@ impl BigUint { #[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 @@ priv fn get_radix_base(radix: uint) -> (uint, 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), diff --git a/src/libextra/stats.rs b/src/libextra/stats.rs index 68d5af43688a2..0266c5f812445 100644 --- a/src/libextra/stats.rs +++ b/src/libextra/stats.rs @@ -222,7 +222,7 @@ impl<'self> Stats for &'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 { diff --git a/src/libextra/term.rs b/src/libextra/term.rs index 1cfb4f4afa627..b731f1a72827c 100644 --- a/src/libextra/term.rs +++ b/src/libextra/term.rs @@ -75,7 +75,7 @@ pub mod 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 @@ impl Terminal { } } - 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 } diff --git a/src/libextra/terminfo/parm.rs b/src/libextra/terminfo/parm.rs index b619e0f33b644..0929575ee9e70 100644 --- a/src/libextra/terminfo/parm.rs +++ b/src/libextra/terminfo/parm.rs @@ -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 @@ priv struct Flags { } 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 @@ priv enum FormatOp { } 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 { diff --git a/src/libextra/time.rs b/src/libextra/time.rs index efc3dc87adc00..f6a5fd98234b5 100644 --- a/src/libextra/time.rs +++ b/src/libextra/time.rs @@ -254,7 +254,7 @@ impl Tm { } } -priv fn do_strptime(s: &str, format: &str) -> Result { +fn do_strptime(s: &str, format: &str) -> Result { fn match_str(s: &str, pos: uint, needle: &str) -> bool { let mut i = pos; for ch in needle.byte_iter() { @@ -687,7 +687,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result { } } -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); diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs index bbcf42b1c5d32..c9e2b8dd37b9d 100644 --- a/src/librustc/middle/typeck/rscope.rs +++ b/src/librustc/middle/typeck/rscope.rs @@ -215,7 +215,7 @@ impl region_scope for MethodRscope { pub struct type_rscope(Option); 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 { diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index 4356f1143da46..a4de10f8c7760 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -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() -> (server::Oneshot, client::Oneshot) { @@ -341,7 +341,7 @@ mod pipesy { #[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(pipe: Oneshot, x_0: T) -> @@ -489,7 +489,7 @@ mod pipesy { #[allow(non_camel_case_types)] pub mod streamp { - priv use std::kinds::Send; + use std::kinds::Send; pub fn init() -> (server::Open, client::Open) { pub use std::pipes::HasBuffer; @@ -501,7 +501,7 @@ mod pipesy { #[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(pipe: Open, x_0: T) -> diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 7ab3c81b61f7a..1f22343ad9c36 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -422,9 +422,9 @@ pub fn float_to_str_common(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 } @@ -825,7 +825,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)] diff --git a/src/libstd/str.rs b/src/libstd/str.rs index b4057b85cbfef..d54bfb836c321 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -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 { diff --git a/src/libstd/str/ascii.rs b/src/libstd/str/ascii.rs index 1be4d07dfa477..6ededb02107d4 100644 --- a/src/libstd/str/ascii.rs +++ b/src/libstd/str/ascii.rs @@ -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 @@ priv static ASCII_LOWER_MAP: &'static [u8] = &[ 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, diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index ec956f6186376..dda5e990221ec 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -64,6 +64,7 @@ pub enum ObsoleteSyntax { ObsoleteMutWithMultipleBindings, ObsoleteExternVisibility, ObsoleteUnsafeExternFn, + ObsoletePrivVisibility, } impl to_bytes::IterBytes for ObsoleteSyntax { @@ -253,6 +254,10 @@ impl ParserObsoleteMethods for Parser { "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); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a0932729930e3..8afa273e06f24 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -85,7 +85,7 @@ use parse::obsolete::{ObsoleteConstItem, ObsoleteFixedLengthVectorType}; 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 @@ impl Parser { 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 @@ impl Parser { 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 @@ impl Parser { 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 @@ impl Parser { // 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 @@ impl Parser { 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 @@ impl Parser { 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 diff --git a/src/test/run-pass/class-cast-to-trait-multiple-types.rs b/src/test/run-pass/class-cast-to-trait-multiple-types.rs index a5d7ba2c1aaa1..a134ffe49fd02 100644 --- a/src/test/run-pass/class-cast-to-trait-multiple-types.rs +++ b/src/test/run-pass/class-cast-to-trait-multiple-types.rs @@ -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 {