diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-07-11 15:00:40 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-07-17 15:46:43 -0700 |
| commit | db020ab63cd51dd4a25cba2d00117f016128762b (patch) | |
| tree | 2b6f1e99ba4356f3e3bf5338332c278d2a85109b /src/libsyntax/parse/parser.rs | |
| parent | b5729bd60095fb5ca884936775e031cf19900760 (diff) | |
| download | rust-db020ab63cd51dd4a25cba2d00117f016128762b.tar.gz rust-db020ab63cd51dd4a25cba2d00117f016128762b.zip | |
rustc: Implement and enforce instance coherence
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 74210f74d4d..c7687bf2b98 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2188,14 +2188,23 @@ class parser { } } + fn token_is_pound_or_doc_comment(++tok: token::token) -> bool { + alt tok { + token::POUND | token::DOC_COMMENT(_) { true } + _ { false } + } + } + fn parse_single_class_item(vis: visibility) -> @class_member { - if self.eat_keyword(~"let") { + if (self.eat_keyword(~"let") || + self.token_is_keyword(~"mut", copy self.token) || + !self.is_any_keyword(copy self.token)) && + !self.token_is_pound_or_doc_comment(self.token) { let a_var = self.parse_instance_var(vis); self.expect(token::SEMI); ret a_var; - } - else { + } else { let m = self.parse_method(vis); ret @{node: class_method(m), span: m.span}; } @@ -2510,7 +2519,7 @@ class parser { self.parse_item_trait() } else if self.eat_keyword(~"impl") { self.parse_item_impl() - } else if self.eat_keyword(~"class") { + } else if self.eat_keyword(~"class") || self.eat_keyword(~"struct") { self.parse_item_class() } else if !self.is_any_keyword(copy self.token) && self.look_ahead(1) == token::NOT |
