Skip to content

Commit

Permalink
Rollup merge of rust-lang#24981 - carols10cents:remove-more-priv, r=a…
Browse files Browse the repository at this point in the history
…lexcrichton

Hi! While researching stuff for the reference and the grammar, I came across a few mentions of using the `priv` keyword that was removed in 0.11.0 (rust-lang#13547, rust-lang#8122, rust-lang/rfcs#26, [RFC 0026](https://github.com/rust-lang/rfcs/blob/master/text/0026-remove-priv.md)).

One occurrence is a mention in the reference, a few are in comments, and a few are marking test functions. I left the test that makes sure you can't name an ident `priv` since it's still a reserved keyword. I did a little grepping around for `priv `, priv in backticks, `Private` etc and I think the remaining instances are fine, but if anyone knows anywhere in particular I should check for any other lingering mentions of `priv`, please let me know and I would be happy to! 🍂 🌊
  • Loading branch information
Manishearth committed May 1, 2015
2 parents 2f5802a + 2fdd1b0 commit ece65d6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1557,8 +1557,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 @@ -4775,7 +4775,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 {
let mut res = "*".to_string();
res.push_str(cmd.len().to_string());
res.push_str("\r\n");
Expand Down

0 comments on commit ece65d6

Please sign in to comment.