Remove priv sections from classes. Obsolete the syntax
This commit is contained in:
parent
3aa5b0cb44
commit
1203da3b9d
29 changed files with 64 additions and 102 deletions
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2818,23 +2818,14 @@ 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.
|
|
||||||
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") {
|
if self.eat_keyword(~"pub") {
|
||||||
return members(~[self.parse_single_class_item(public)]);
|
return members(~[self.parse_single_class_item(public)]);
|
||||||
|
|
|
@ -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,
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
struct cat {
|
struct cat {
|
||||||
priv {
|
priv mut meows : uint,
|
||||||
mut meows : uint
|
|
||||||
}
|
|
||||||
|
|
||||||
how_hungry : int,
|
how_hungry : int,
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
struct cat {
|
struct cat {
|
||||||
priv {
|
priv mut meows : uint,
|
||||||
mut meows : uint,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
priv impl cat {
|
priv impl cat {
|
||||||
|
|
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
|
|
||||||
|
|
|
@ -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: (),
|
||||||
|
|
|
@ -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,
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
mut meows : int,
|
priv mut meows : int,
|
||||||
}
|
|
||||||
|
|
||||||
mut how_hungry : int,
|
mut how_hungry : int,
|
||||||
name : T,
|
name : T,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
struct cat {
|
struct cat {
|
||||||
priv {
|
priv mut meows : uint,
|
||||||
mut meows : uint,
|
|
||||||
}
|
|
||||||
|
|
||||||
how_hungry : int,
|
how_hungry : int,
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
struct cat<U> {
|
struct cat<U> {
|
||||||
priv {
|
priv mut meows : uint,
|
||||||
mut meows : uint,
|
|
||||||
}
|
|
||||||
|
|
||||||
how_hungry : int,
|
how_hungry : int,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
struct cat {
|
struct cat {
|
||||||
priv {
|
priv mut meows : uint,
|
||||||
mut meows : uint,
|
|
||||||
}
|
|
||||||
|
|
||||||
how_hungry : int,
|
how_hungry : int,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
struct cat {
|
struct cat {
|
||||||
priv {
|
priv mut meows : uint,
|
||||||
mut meows : uint,
|
|
||||||
}
|
|
||||||
|
|
||||||
how_hungry : int,
|
how_hungry : int,
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
struct cat {
|
struct cat {
|
||||||
priv {
|
priv mut meows : uint,
|
||||||
mut meows : uint,
|
|
||||||
}
|
|
||||||
|
|
||||||
how_hungry : int,
|
how_hungry : int,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
struct cat {
|
struct cat {
|
||||||
priv {
|
priv mut meows : uint,
|
||||||
mut meows : uint,
|
|
||||||
}
|
|
||||||
|
|
||||||
how_hungry : int,
|
how_hungry : int,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue