diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index a987ae948a4..0f4de9257c9 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -60,6 +60,7 @@ pub enum ObsoleteSyntax { ObsoleteConstManagedPointer, ObsoletePurity, ObsoleteStaticMethod, + ObsoleteConstItem, } impl to_bytes::IterBytes for ObsoleteSyntax { @@ -203,6 +204,11 @@ fn obsolete(&self, sp: span, kind: ObsoleteSyntax) { "`static` notation", "`static` is superfluous; remove it" ), + ObsoleteConstItem => ( + "`const` item", + "`const` items are now `static` items; replace `const` with \ + `static`" + ), }; self.report(sp, kind, kind_str, desc); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6f2c0f7ddf5..b7cc0b35023 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -81,6 +81,7 @@ use parse::obsolete::{ObsoleteMode, ObsoleteImplicitSelf}; use parse::obsolete::{ObsoleteLifetimeNotation, ObsoleteConstManagedPointer}; use parse::obsolete::{ObsoletePurity, ObsoleteStaticMethod}; +use parse::obsolete::{ObsoleteConstItem}; 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}; @@ -3563,7 +3564,9 @@ fn parse_item_foreign_const(&self, vis: ast::visibility, let lo = self.span.lo; // XXX: Obsolete; remove after snap. - if !self.eat_keyword(&~"const") { + if self.eat_keyword(&~"const") { + self.obsolete(*self.last_span, ObsoleteConstItem); + } else { self.expect_keyword(&~"static"); } @@ -3959,6 +3962,9 @@ fn parse_item_or_view_item( (self.is_keyword(&~"static") && !self.token_is_keyword(&~"fn", &self.look_ahead(1)))) { // CONST ITEM + if self.is_keyword(&~"const") { + self.obsolete(*self.span, ObsoleteConstItem); + } self.bump(); let (ident, item_, extra_attrs) = self.parse_item_const(); return iovi_item(self.mk_item(lo, self.last_span.hi, ident, item_,