Remove priv sections from classes. Obsolete the syntax

This commit is contained in:
Brian Anderson 2012-09-10 18:56:07 -07:00
parent 3aa5b0cb44
commit 1203da3b9d
29 changed files with 64 additions and 102 deletions

View File

@ -20,7 +20,8 @@ pub enum ObsoleteSyntax {
ObsoleteStructCtor,
ObsoleteWith,
ObsoleteClassMethod,
ObsoleteClassTraits
ObsoleteClassTraits,
ObsoletePrivSection
}
impl ObsoleteSyntax : cmp::Eq {
@ -82,6 +83,11 @@ impl parser : ObsoleteReporter {
"implemented traits are specified on the impl, as in \
`impl foo : bar {`"
),
ObsoletePrivSection => (
"private section",
"the `priv` keyword is applied to individual items, methods, \
and fields"
),
};
self.report(sp, kind, kind_str, desc);
@ -152,5 +158,19 @@ impl parser : ObsoleteReporter {
}
}
fn try_parse_obsolete_priv_section() -> bool {
if self.is_keyword(~"priv") && self.look_ahead(1) == token::LBRACE {
self.obsolete(copy self.span, ObsoletePrivSection);
self.eat_keyword(~"priv");
self.bump();
while self.token != token::RBRACE {
self.parse_single_class_item(ast::private);
}
self.bump();
true
} else {
false
}
}
}

View File

@ -2818,22 +2818,13 @@ impl parser {
}
fn parse_class_item() -> class_contents {
if self.try_parse_obsolete_priv_section() {
return members(~[]);
}
if self.eat_keyword(~"priv") {
// XXX: Remove after snapshot.
match self.token {
token::LBRACE => {
self.bump();
let mut results = ~[];
while self.token != token::RBRACE {
vec::push(results,
self.parse_single_class_item(private));
}
self.bump();
return members(results);
}
_ =>
return members(~[self.parse_single_class_item(private)])
}
return members(~[self.parse_single_class_item(private)])
}
if self.eat_keyword(~"pub") {

View File

@ -1,9 +1,7 @@
mod kitties {
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
how_hungry : int,

View File

@ -1,9 +1,7 @@
mod kitties {
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
how_hungry : int,

View File

@ -1,9 +1,7 @@
mod kitties {
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
how_hungry : int,
}

View File

@ -1,9 +1,7 @@
mod kitties {
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
mut how_hungry : int,
name : ~str,

View File

@ -1,10 +1,8 @@
mod kitties {
struct cat<U> {
priv {
mut info : ~[U],
mut meows : uint,
}
priv mut info : ~[U],
priv mut meows : uint,
how_hungry : int,
}

View File

@ -4,10 +4,7 @@ use to_str::ToStr;
mod kitty {
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
mut how_hungry : int,
name : ~str,
}

View File

@ -1,7 +1,5 @@
struct cat {
priv {
mut meows : uint
}
priv mut meows : uint,
how_hungry : int,
}

View File

@ -4,9 +4,7 @@ trait noisy {
}
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
mut how_hungry : int,
name : str,

View File

@ -1,7 +1,5 @@
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
}
priv impl cat {

View File

@ -1,8 +1,6 @@
// error-pattern:assigning to immutable field
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
how_hungry : int,
}

View File

@ -1,8 +1,6 @@
// error-pattern:assigning to immutable field
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
how_hungry : int,

View File

@ -31,6 +31,13 @@ struct q : r {
//~^ ERROR obsolete syntax: class traits
}
struct sss {
priv {
//~^ ERROR obsolete syntax: private section
foo: ()
}
}
fn obsolete_with() {
struct S {
foo: (),

View File

@ -2,9 +2,7 @@
mod kitties {
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
how_hungry : int,

View File

@ -3,9 +3,7 @@ trait noisy {
}
struct dog {
priv {
barks : @mut uint,
}
priv barks : @mut uint,
volume : @mut int,
}
@ -37,9 +35,7 @@ fn dog() -> dog {
}
struct cat {
priv {
meows : @mut uint,
}
priv meows : @mut uint,
how_hungry : @mut int,
name : ~str,

View File

@ -3,10 +3,7 @@ trait noisy {
}
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
mut how_hungry : int,
name : ~str,
}

View File

@ -15,10 +15,8 @@ impl cat_type : cmp::Eq {
// ok: T should be in scope when resolving the trait ref for map
struct cat<T: Copy> {
priv {
// Yes, you can have negative meows
mut meows : int,
}
// Yes, you can have negative meows
priv mut meows : int,
mut how_hungry : int,
name : T,

View File

@ -4,9 +4,7 @@ use cci_class_trait;
use cci_class_trait::animals::*;
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
mut how_hungry : int,
name : ~str,

View File

@ -3,9 +3,7 @@ trait noisy {
}
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
mut how_hungry : int,
name : ~str,

View File

@ -1,7 +1,5 @@
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
how_hungry : int,
}

View File

@ -1,8 +1,6 @@
struct cat<U> {
priv {
mut info : ~[U],
mut meows : uint,
}
priv mut info : ~[U],
priv mut meows : uint,
how_hungry : int,
}

View File

@ -3,9 +3,7 @@ use to_str::*;
use to_str::ToStr;
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
mut how_hungry : int,
name : ~str,

View File

@ -1,7 +1,5 @@
struct cat<U> {
priv {
mut meows : uint,
}
priv mut meows : uint,
how_hungry : int,
}

View File

@ -1,7 +1,5 @@
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
how_hungry : int,
}

View File

@ -1,7 +1,5 @@
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
how_hungry : int,

View File

@ -1,7 +1,5 @@
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
mut how_hungry : int,
name : ~str,

View File

@ -1,7 +1,5 @@
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
how_hungry : int,
}

View File

@ -1,7 +1,5 @@
struct cat {
priv {
mut meows : uint,
}
priv mut meows : uint,
how_hungry : int,
}