Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1562,8 +1562,7 @@ warnings are generated, or otherwise "you used a private item of another module
and weren't allowed to."

By default, everything in Rust is *private*, with one exception. Enum variants
in a `pub` enum are also public by default. You are allowed to alter this
default visibility with the `priv` keyword. When an item is declared as `pub`,
in a `pub` enum are also public by default. When an item is declared as `pub`,
it can be thought of as being accessible to the outside world. For example:

```
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
if let ast::MethodImplItem(ref sig, _) = ii.node {
// if the method specifies a visibility, use that, otherwise
// inherit the visibility from the impl (so `foo` in `pub impl
// { fn foo(); }` is public, but private in `priv impl { fn
// { fn foo(); }` is public, but private in `impl { fn
// foo(); }`).
let method_vis = ii.vis.inherit_from(parent_visibility);
Some((sig, ii.id, ii.ident, method_vis, ii.span))
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4772,7 +4772,7 @@ impl<'a> Parser<'a> {
return self.parse_single_struct_field(Inherited, attrs);
}

/// Parse visibility: PUB, PRIV, or nothing
/// Parse visibility: PUB or nothing
fn parse_visibility(&mut self) -> PResult<Visibility> {
if try!(self.eat_keyword(keywords::Pub)) { Ok(Public) }
else { Ok(Inherited) }
Expand Down
16 changes: 8 additions & 8 deletions src/test/run-pass/issue-4241.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ enum Result {
Status(String)
}

priv fn parse_data(len: usize, io: @io::Reader) -> Result {
fn parse_data(len: usize, io: @io::Reader) -> Result {
let res =
if (len > 0) {
let bytes = io.read_bytes(len as usize);
Expand All @@ -42,7 +42,7 @@ priv fn parse_data(len: usize, io: @io::Reader) -> Result {
return res;
}

priv fn parse_list(len: usize, io: @io::Reader) -> Result {
fn parse_list(len: usize, io: @io::Reader) -> Result {
let mut list: ~[Result] = ~[];
for _ in 0..len {
let v = match io.read_char() {
Expand All @@ -55,11 +55,11 @@ priv fn parse_list(len: usize, io: @io::Reader) -> Result {
return List(list);
}

priv fn chop(s: String) -> String {
fn chop(s: String) -> String {
s.slice(0, s.len() - 1).to_string()
}

priv fn parse_bulk(io: @io::Reader) -> Result {
fn parse_bulk(io: @io::Reader) -> Result {
match from_str::<isize>(chop(io.read_line())) {
None => panic!(),
Some(-1) => Nil,
Expand All @@ -68,7 +68,7 @@ priv fn parse_bulk(io: @io::Reader) -> Result {
}
}

priv fn parse_multi(io: @io::Reader) -> Result {
fn parse_multi(io: @io::Reader) -> Result {
match from_str::<isize>(chop(io.read_line())) {
None => panic!(),
Some(-1) => Nil,
Expand All @@ -78,14 +78,14 @@ priv fn parse_multi(io: @io::Reader) -> Result {
}
}

priv fn parse_int(io: @io::Reader) -> Result {
fn parse_int(io: @io::Reader) -> Result {
match from_str::<isize>(chop(io.read_line())) {
None => panic!(),
Some(i) => Int(i)
}
}

priv fn parse_response(io: @io::Reader) -> Result {
fn parse_response(io: @io::Reader) -> Result {
match io.read_char() {
'$' => parse_bulk(io),
'*' => parse_multi(io),
Expand All @@ -96,7 +96,7 @@ priv fn parse_response(io: @io::Reader) -> Result {
}
}

priv fn cmd_to_string(cmd: ~[String]) -> String {
fn cmd_to_string(cmd: ~[String]) -> String {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is actually ancient. ~[String] though, that's an anachronism?!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL I didn't even notice that! Maybe I'll take a look around for ~s next :)

let mut res = "*".to_string();
res.push_str(cmd.len().to_string());
res.push_str("\r\n");
Expand Down