about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-03-22 12:56:10 -0700
committerPatrick Walton <pcwalton@mimiga.net>2013-03-22 22:24:33 -0700
commitfa70709e07983fb62d1fddadac0987c79e836d23 (patch)
tree53e4f95639a3696f9cc1fac44ea3cc42eddfe842
parentd60a7259f9f7855aefac17596f66bc4c863dfe7a (diff)
downloadrust-fa70709e07983fb62d1fddadac0987c79e836d23.tar.gz
rust-fa70709e07983fb62d1fddadac0987c79e836d23.zip
libsyntax: Stop parsing `pure` and `static`
-rw-r--r--src/libcore/rt/sched.rs2
-rw-r--r--src/librustpkg/rustpkg.rc2
-rw-r--r--src/libsyntax/parse/obsolete.rs10
-rw-r--r--src/libsyntax/parse/parser.rs16
-rw-r--r--src/test/auxiliary/static_fn_inline_xc_aux.rs4
5 files changed, 26 insertions, 8 deletions
diff --git a/src/libcore/rt/sched.rs b/src/libcore/rt/sched.rs
index 4a140458fd3..c2c4bedee81 100644
--- a/src/libcore/rt/sched.rs
+++ b/src/libcore/rt/sched.rs
@@ -311,7 +311,7 @@ impl Task {
         };
     }
 
-    static priv fn build_start_wrapper(start: ~fn()) -> ~fn() {
+    priv fn build_start_wrapper(start: ~fn()) -> ~fn() {
         // XXX: The old code didn't have this extra allocation
         let wrapper: ~fn() = || {
             start();
diff --git a/src/librustpkg/rustpkg.rc b/src/librustpkg/rustpkg.rc
index c2e3ce04f06..90d6fcbb8a5 100644
--- a/src/librustpkg/rustpkg.rc
+++ b/src/librustpkg/rustpkg.rc
@@ -57,7 +57,7 @@ struct PackageScript {
 }
 
 impl PackageScript {
-    static fn parse(parent: &Path) -> Result<PackageScript, ~str> {
+    fn parse(parent: &Path) -> Result<PackageScript, ~str> {
         let script = parent.push(~"pkg.rs");
 
         if !os::path_exists(&script) {
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index 65eb87fb83c..173ae31f948 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -59,6 +59,8 @@ pub enum ObsoleteSyntax {
     ObsoleteImplicitSelf,
     ObsoleteLifetimeNotation,
     ObsoleteConstManagedPointer,
+    ObsoletePurity,
+    ObsoleteStaticMethod,
 }
 
 impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -198,6 +200,14 @@ pub impl Parser {
                 "const `@` pointer",
                 "instead of `@const Foo`, write `@Foo`"
             ),
+            ObsoletePurity => (
+                "pure function",
+                "remove `pure`"
+            ),
+            ObsoleteStaticMethod => (
+                "`static` notation",
+                "`static` is superfluous; remove it"
+            ),
         };
 
         self.report(sp, kind, kind_str, desc);
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 7ee45eea0de..4b79e4f20f3 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -80,6 +80,7 @@ use parse::obsolete::{ObsoleteAssertion, ObsoletePostFnTySigil};
 use parse::obsolete::{ObsoleteBareFnType, ObsoleteNewtypeEnum};
 use parse::obsolete::{ObsoleteMode, ObsoleteImplicitSelf};
 use parse::obsolete::{ObsoleteLifetimeNotation, ObsoleteConstManagedPointer};
+use parse::obsolete::{ObsoletePurity, ObsoleteStaticMethod};
 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};
@@ -413,7 +414,7 @@ pub impl Parser {
 
     fn parse_purity(&self) -> purity {
         if self.eat_keyword(&~"pure") {
-            // NB: We parse this as impure for bootstrapping purposes.
+            self.obsolete(*self.last_span, ObsoletePurity);
             return impure_fn;
         } else if self.eat_keyword(&~"unsafe") {
             return unsafe_fn;
@@ -2684,7 +2685,7 @@ pub impl Parser {
 
     fn parse_optional_purity(&self) -> ast::purity {
         if self.eat_keyword(&~"pure") {
-            // NB: We parse this as impure for bootstrapping purposes.
+            self.obsolete(*self.last_span, ObsoletePurity);
             ast::impure_fn
         } else if self.eat_keyword(&~"unsafe") {
             ast::unsafe_fn
@@ -3341,8 +3342,14 @@ pub impl Parser {
         else if self.eat_keyword(&~"priv") { private }
         else { inherited }
     }
+
     fn parse_staticness(&self) -> bool {
-        self.eat_keyword(&~"static")
+        if self.eat_keyword(&~"static") {
+            self.obsolete(*self.last_span, ObsoleteStaticMethod);
+            true
+        } else {
+            false
+        }
     }
 
     // given a termination token and a vector of already-parsed
@@ -3580,6 +3587,7 @@ pub impl Parser {
     fn parse_fn_purity(&self) -> purity {
         if self.eat_keyword(&~"fn") { impure_fn }
         else if self.eat_keyword(&~"pure") {
+            self.obsolete(*self.last_span, ObsoletePurity);
             self.expect_keyword(&~"fn");
             // NB: We parse this as impure for bootstrapping purposes.
             impure_fn
@@ -3979,7 +3987,7 @@ pub impl Parser {
         }
         if items_allowed && self.eat_keyword(&~"pure") {
             // PURE FUNCTION ITEM
-            // NB: We parse this as impure for bootstrapping purposes.
+            self.obsolete(*self.last_span, ObsoletePurity);
             self.expect_keyword(&~"fn");
             let (ident, item_, extra_attrs) = self.parse_item_fn(impure_fn);
             return iovi_item(self.mk_item(lo, self.last_span.hi, ident, item_,
diff --git a/src/test/auxiliary/static_fn_inline_xc_aux.rs b/src/test/auxiliary/static_fn_inline_xc_aux.rs
index b1bdfcfcffc..5fc6621f186 100644
--- a/src/test/auxiliary/static_fn_inline_xc_aux.rs
+++ b/src/test/auxiliary/static_fn_inline_xc_aux.rs
@@ -11,14 +11,14 @@
 
 pub mod num {
     pub trait Num2 {
-        static fn from_int2(n: int) -> Self;
+        fn from_int2(n: int) -> Self;
     }
 }
 
 pub mod float {
     impl ::num::Num2 for float {
         #[inline]
-        static fn from_int2(n: int) -> float { return n as float;  }
+        fn from_int2(n: int) -> float { return n as float;  }
     }
 }