diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 01c1af7464d..989a796cbc9 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -32,7 +32,6 @@ use std::to_bytes; pub enum ObsoleteSyntax { ObsoleteLet, ObsoleteFieldTerminator, - ObsoleteStructCtor, ObsoleteWith, ObsoleteClassTraits, ObsoletePrivSection, @@ -89,7 +88,6 @@ pub trait ParserObsoleteMethods { fn token_is_obsolete_ident(&self, ident: &str, token: &Token) -> bool; fn is_obsolete_ident(&self, ident: &str) -> bool; fn eat_obsolete_ident(&self, ident: &str) -> bool; - fn try_parse_obsolete_struct_ctor(&self) -> bool; fn try_parse_obsolete_with(&self) -> bool; fn try_parse_obsolete_priv_section(&self, attrs: &[Attribute]) -> bool; } @@ -106,12 +104,6 @@ impl ParserObsoleteMethods for Parser { "field declaration terminated with semicolon", "fields are now separated by commas" ), - ObsoleteStructCtor => ( - "struct constructor", - "structs are now constructed with `MyStruct { foo: val }` \ - syntax. Structs with private fields cannot be created \ - outside of their defining module" - ), ObsoleteWith => ( "with", "record update is done with `..`, e.g. \ @@ -311,17 +303,6 @@ impl ParserObsoleteMethods for Parser { } } - fn try_parse_obsolete_struct_ctor(&self) -> bool { - if self.eat_obsolete_ident("new") { - self.obsolete(*self.last_span, ObsoleteStructCtor); - self.parse_fn_decl(); - self.parse_block(); - true - } else { - false - } - } - fn try_parse_obsolete_with(&self) -> bool { if *self.token == token::COMMA && self.look_ahead(1, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a2664dcf890..af54dea3c33 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3929,10 +3929,6 @@ impl Parser { return ~[self.parse_single_struct_field(public, attrs)]; } - if self.try_parse_obsolete_struct_ctor() { - return ~[]; - } - return ~[self.parse_single_struct_field(inherited, attrs)]; } diff --git a/src/test/compile-fail/obsolete-syntax.rs b/src/test/compile-fail/obsolete-syntax.rs index 8ba5e2815a5..49af0972341 100644 --- a/src/test/compile-fail/obsolete-syntax.rs +++ b/src/test/compile-fail/obsolete-syntax.rs @@ -13,8 +13,6 @@ struct s { //~^ ERROR obsolete syntax: `let` in field declaration bar: (); //~^ ERROR obsolete syntax: field declaration terminated with semicolon - new() { } - //~^ ERROR obsolete syntax: struct constructor } struct q : r { diff --git a/src/test/run-pass/struct-new-as-field-name.rs b/src/test/run-pass/struct-new-as-field-name.rs new file mode 100644 index 00000000000..fb93c560e0d --- /dev/null +++ b/src/test/run-pass/struct-new-as-field-name.rs @@ -0,0 +1,8 @@ +struct Foo { + new: int, +} + +pub fn main() { + let foo = Foo{ new: 3 }; + assert_eq!(foo.new, 3); +}