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,
|
||||
ObsoleteWith,
|
||||
ObsoleteClassMethod,
|
||||
ObsoleteClassTraits
|
||||
}
|
||||
|
||||
impl ObsoleteSyntax : cmp::Eq {
|
||||
|
@ -76,6 +77,11 @@ impl parser : ObsoleteReporter {
|
|||
"class method",
|
||||
"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);
|
||||
|
|
|
@ -19,7 +19,7 @@ use obsolete::{
|
|||
ObsoleteReporter, ObsoleteSyntax,
|
||||
ObsoleteLowerCaseKindBounds, ObsoleteLet,
|
||||
ObsoleteFieldTerminator, ObsoleteStructCtor,
|
||||
ObsoleteWith, ObsoleteClassMethod
|
||||
ObsoleteWith, ObsoleteClassMethod, ObsoleteClassTraits
|
||||
};
|
||||
use ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute,
|
||||
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();
|
||||
self.parse_region_param();
|
||||
let ty_params = self.parse_ty_params();
|
||||
let traits : ~[@trait_ref] = if self.eat(token::COLON)
|
||||
{ self.parse_trait_ref_list(token::LBRACE) }
|
||||
let traits : ~[@trait_ref] = if self.eat(token::COLON) {
|
||||
self.obsolete(copy self.span, ObsoleteClassTraits);
|
||||
self.parse_trait_ref_list(token::LBRACE)
|
||||
}
|
||||
else { ~[] };
|
||||
|
||||
let mut fields: ~[@struct_field];
|
||||
|
|
|
@ -3,10 +3,13 @@ trait animal {
|
|||
fn eat();
|
||||
}
|
||||
|
||||
struct cat : animal {
|
||||
struct cat {
|
||||
meows: uint,
|
||||
}
|
||||
|
||||
impl cat : animal {
|
||||
}
|
||||
|
||||
fn cat(in_x : uint) -> cat {
|
||||
cat {
|
||||
meows: in_x
|
||||
|
|
|
@ -27,6 +27,10 @@ struct ss {
|
|||
//~^ ERROR obsolete syntax: class method
|
||||
}
|
||||
|
||||
struct q : r {
|
||||
//~^ ERROR obsolete syntax: class traits
|
||||
}
|
||||
|
||||
fn obsolete_with() {
|
||||
struct S {
|
||||
foo: (),
|
||||
|
|
Loading…
Add table
Reference in a new issue