Report obsolete trait lists on structs
This commit is contained in:
parent
9869d071d1
commit
6957af770b
4 changed files with 19 additions and 4 deletions
|
@ -20,6 +20,7 @@ pub enum ObsoleteSyntax {
|
||||||
ObsoleteStructCtor,
|
ObsoleteStructCtor,
|
||||||
ObsoleteWith,
|
ObsoleteWith,
|
||||||
ObsoleteClassMethod,
|
ObsoleteClassMethod,
|
||||||
|
ObsoleteClassTraits
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ObsoleteSyntax : cmp::Eq {
|
impl ObsoleteSyntax : cmp::Eq {
|
||||||
|
@ -76,6 +77,11 @@ impl parser : ObsoleteReporter {
|
||||||
"class method",
|
"class method",
|
||||||
"methods should be defined inside impls"
|
"methods should be defined inside impls"
|
||||||
),
|
),
|
||||||
|
ObsoleteClassTraits => (
|
||||||
|
"class traits",
|
||||||
|
"implemented traits are specified on the impl, as in \
|
||||||
|
`impl foo : bar {`"
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report(sp, kind, kind_str, desc);
|
self.report(sp, kind, kind_str, desc);
|
||||||
|
|
|
@ -19,7 +19,7 @@ use obsolete::{
|
||||||
ObsoleteReporter, ObsoleteSyntax,
|
ObsoleteReporter, ObsoleteSyntax,
|
||||||
ObsoleteLowerCaseKindBounds, ObsoleteLet,
|
ObsoleteLowerCaseKindBounds, ObsoleteLet,
|
||||||
ObsoleteFieldTerminator, ObsoleteStructCtor,
|
ObsoleteFieldTerminator, ObsoleteStructCtor,
|
||||||
ObsoleteWith, ObsoleteClassMethod
|
ObsoleteWith, ObsoleteClassMethod, ObsoleteClassTraits
|
||||||
};
|
};
|
||||||
use ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute,
|
use ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute,
|
||||||
bind_by_ref, bind_by_implicit_ref, bind_by_value, bind_by_move,
|
bind_by_ref, bind_by_implicit_ref, bind_by_value, bind_by_move,
|
||||||
|
@ -2648,8 +2648,10 @@ impl parser {
|
||||||
let class_name = self.parse_value_ident();
|
let class_name = self.parse_value_ident();
|
||||||
self.parse_region_param();
|
self.parse_region_param();
|
||||||
let ty_params = self.parse_ty_params();
|
let ty_params = self.parse_ty_params();
|
||||||
let traits : ~[@trait_ref] = if self.eat(token::COLON)
|
let traits : ~[@trait_ref] = if self.eat(token::COLON) {
|
||||||
{ self.parse_trait_ref_list(token::LBRACE) }
|
self.obsolete(copy self.span, ObsoleteClassTraits);
|
||||||
|
self.parse_trait_ref_list(token::LBRACE)
|
||||||
|
}
|
||||||
else { ~[] };
|
else { ~[] };
|
||||||
|
|
||||||
let mut fields: ~[@struct_field];
|
let mut fields: ~[@struct_field];
|
||||||
|
|
|
@ -3,10 +3,13 @@ trait animal {
|
||||||
fn eat();
|
fn eat();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cat : animal {
|
struct cat {
|
||||||
meows: uint,
|
meows: uint,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl cat : animal {
|
||||||
|
}
|
||||||
|
|
||||||
fn cat(in_x : uint) -> cat {
|
fn cat(in_x : uint) -> cat {
|
||||||
cat {
|
cat {
|
||||||
meows: in_x
|
meows: in_x
|
||||||
|
|
|
@ -27,6 +27,10 @@ struct ss {
|
||||||
//~^ ERROR obsolete syntax: class method
|
//~^ ERROR obsolete syntax: class method
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct q : r {
|
||||||
|
//~^ ERROR obsolete syntax: class traits
|
||||||
|
}
|
||||||
|
|
||||||
fn obsolete_with() {
|
fn obsolete_with() {
|
||||||
struct S {
|
struct S {
|
||||||
foo: (),
|
foo: (),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue