1
Fork 0

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, ObsoleteStructCtor,
ObsoleteWith, ObsoleteWith,
ObsoleteClassMethod, ObsoleteClassMethod,
ObsoleteClassTraits ObsoleteClassTraits,
ObsoletePrivSection
} }
impl ObsoleteSyntax : cmp::Eq { impl ObsoleteSyntax : cmp::Eq {
@ -82,6 +83,11 @@ impl parser : ObsoleteReporter {
"implemented traits are specified on the impl, as in \ "implemented traits are specified on the impl, as in \
`impl foo : bar {`" `impl foo : bar {`"
), ),
ObsoletePrivSection => (
"private section",
"the `priv` keyword is applied to individual items, methods, \
and fields"
),
}; };
self.report(sp, kind, kind_str, desc); 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 { fn parse_class_item() -> class_contents {
if self.try_parse_obsolete_priv_section() {
return members(~[]);
}
if self.eat_keyword(~"priv") { if self.eat_keyword(~"priv") {
// XXX: Remove after snapshot. return members(~[self.parse_single_class_item(private)])
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)])
}
} }
if self.eat_keyword(~"pub") { if self.eat_keyword(~"pub") {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3,10 +3,7 @@ trait noisy {
} }
struct cat { struct cat {
priv { priv mut meows : uint,
mut meows : uint,
}
mut how_hungry : int, mut how_hungry : int,
name : ~str, 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 // ok: T should be in scope when resolving the trait ref for map
struct cat<T: Copy> { struct cat<T: Copy> {
priv { // Yes, you can have negative meows
// Yes, you can have negative meows priv mut meows : int,
mut meows : int,
}
mut how_hungry : int, mut how_hungry : int,
name : T, name : T,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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