diff options
| author | bors <bors@rust-lang.org> | 2013-02-27 09:42:56 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-02-27 09:42:56 -0800 |
| commit | a6d9689399d091c3265f00434a69c551a61c28dc (patch) | |
| tree | 2c40b3bb0659ac6ea6dabed650d8e01de199e3f5 /src/libsyntax/parse/parser.rs | |
| parent | 061a2237230d3abcdb30ecb8987e5de17e67a58e (diff) | |
| parent | 07c3f5c0de752166ae34f0fe50e50e65a2403b66 (diff) | |
| download | rust-a6d9689399d091c3265f00434a69c551a61c28dc.tar.gz rust-a6d9689399d091c3265f00434a69c551a61c28dc.zip | |
auto merge of #5136 : pcwalton/rust/impl-publicizing, r=pcwalton
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index af25a4f6e58..59ad35b38e4 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -76,6 +76,7 @@ use parse::obsolete::{ObsoleteStructCtor, ObsoleteWith}; use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds}; use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax}; use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer}; +use parse::obsolete::{ObsoleteMutVector, ObsoleteTraitImplVisibility}; use parse::prec::{as_prec, token_to_binop}; use parse::token::{can_begin_expr, is_ident, is_ident_or_path}; use parse::token::{is_plain_ident, INTERPOLATED, special_idents}; @@ -624,6 +625,9 @@ pub impl Parser { } else if *self.token == token::LBRACKET { self.expect(token::LBRACKET); let mt = self.parse_mt(); + if mt.mutbl == m_mutbl { // `m_const` too after snapshot + self.obsolete(*self.last_span, ObsoleteMutVector); + } // Parse the `* 3` in `[ int * 3 ]` let t = match self.maybe_parse_fixed_vstore_with_star() { @@ -678,7 +682,7 @@ pub impl Parser { // reflected in the AST type. let mt = self.parse_mt(); - if mt.mutbl == m_mutbl && sigil == OwnedSigil { + if mt.mutbl != m_imm && sigil == OwnedSigil { self.obsolete(*self.last_span, ObsoleteMutOwnedPointer); } @@ -1134,6 +1138,10 @@ pub impl Parser { } else if *self.token == token::LBRACKET { self.bump(); let mutbl = self.parse_mutability(); + if mutbl == m_mutbl { // `m_const` too after snapshot + self.obsolete(*self.last_span, ObsoleteMutVector); + } + if *self.token == token::RBRACKET { // Empty vector. self.bump(); @@ -1574,6 +1582,10 @@ pub impl Parser { token::TILDE => { self.bump(); let m = self.parse_mutability(); + if m != m_imm { + self.obsolete(*self.last_span, ObsoleteMutOwnedPointer); + } + let e = self.parse_prefix_expr(); hi = e.span.hi; // HACK: turn ~[...] into a ~-evec @@ -2930,9 +2942,9 @@ pub impl Parser { } // Parses two variants (with the region/type params always optional): - // impl<T> ~[T] : to_str { ... } - // impl<T> to_str for ~[T] { ... } - fn parse_item_impl() -> item_info { + // impl<T> Foo { ... } + // impl<T> ToStr for ~[T] { ... } + fn parse_item_impl(visibility: ast::visibility) -> item_info { fn wrap_path(p: Parser, pt: @path) -> @Ty { @Ty { id: p.get_id(), @@ -2981,6 +2993,12 @@ pub impl Parser { None }; + // Do not allow visibility to be specified in `impl...for...`. It is + // meaningless. + if opt_trait.is_some() && visibility != ast::inherited { + self.obsolete(*self.span, ObsoleteTraitImplVisibility); + } + let mut meths = ~[]; if !self.eat(token::SEMI) { self.expect(token::LBRACE); @@ -3848,7 +3866,8 @@ pub impl Parser { maybe_append(attrs, extra_attrs))); } else if items_allowed && self.eat_keyword(~"impl") { // IMPL ITEM - let (ident, item_, extra_attrs) = self.parse_item_impl(); + let (ident, item_, extra_attrs) = + self.parse_item_impl(visibility); return iovi_item(self.mk_item(lo, self.last_span.hi, ident, item_, visibility, maybe_append(attrs, extra_attrs))); |
