about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorEduard Burtescu <edy.burt@gmail.com>2014-01-12 02:25:51 +0200
committerEduard Burtescu <edy.burt@gmail.com>2014-01-12 02:26:04 +0200
commit509fc92a9bb6f9a251308476ebf4e76795df60bf (patch)
tree06b6f708400f1c7ce8ece748232263d4af3d3a56 /src/libsyntax/parse
parent68ebe8141a9d469ed7a7081e7a4a9ff4c82fbff7 (diff)
downloadrust-509fc92a9bb6f9a251308476ebf4e76795df60bf.tar.gz
rust-509fc92a9bb6f9a251308476ebf4e76795df60bf.zip
Removed remnants of `@mut` and `~mut` from comments and the type system.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs98
1 files changed, 41 insertions, 57 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index b783ea6da3c..c83ea52c362 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -142,8 +142,6 @@ at INTERPOLATED tokens */
 macro_rules! maybe_whole_expr (
     ($p:expr) => (
         {
-            // This horrible convolution is brought to you by
-            // @mut, have a terrible day
             let mut maybe_path = match ($p).token {
                 INTERPOLATED(token::NtPath(ref pt)) => Some((**pt).clone()),
                 _ => None,
@@ -3636,20 +3634,14 @@ impl Parser {
     // that may have a self type.
     fn parse_fn_decl_with_self(&mut self, parse_arg_fn: |&mut Parser| -> Arg)
                                -> (ExplicitSelf, P<FnDecl>) {
-        fn maybe_parse_explicit_self(cnstr: |v: Mutability| ->
-                                        ast::ExplicitSelf_,
+        fn maybe_parse_explicit_self(explicit_self: ast::ExplicitSelf_,
                                      p: &mut Parser)
                                      -> ast::ExplicitSelf_ {
             // We need to make sure it isn't a type
-            if p.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) ||
-                ((p.look_ahead(1, |t| token::is_keyword(keywords::Const, t)) ||
-                  p.look_ahead(1, |t| token::is_keyword(keywords::Mut, t))) &&
-                 p.look_ahead(2, |t| token::is_keyword(keywords::Self, t))) {
-
+            if p.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) {
                 p.bump();
-                let mutability = p.parse_mutability();
                 p.expect_self_ident();
-                cnstr(mutability)
+                explicit_self
             } else {
                 SelfStatic
             }
@@ -3708,55 +3700,47 @@ impl Parser {
         // backwards compatible.
         let lo = self.span.lo;
         let explicit_self = match self.token {
-          token::BINOP(token::AND) => {
-            maybe_parse_borrowed_explicit_self(self)
-          }
-          token::AT => {
-            maybe_parse_explicit_self(SelfBox, self)
-          }
-          token::TILDE => {
-            maybe_parse_explicit_self(|mutability| {
-                if mutability != MutImmutable {
-                    self.span_err(self.last_span,
-                                  "mutability declaration not allowed here");
+            token::BINOP(token::AND) => {
+                maybe_parse_borrowed_explicit_self(self)
+            }
+            token::AT => {
+                maybe_parse_explicit_self(SelfBox, self)
+            }
+            token::TILDE => {
+                maybe_parse_explicit_self(SelfUniq(MutImmutable), self)
+            }
+            token::IDENT(..) if self.is_self_ident() => {
+                self.bump();
+                SelfValue(MutImmutable)
+            }
+            token::BINOP(token::STAR) => {
+                // Possibly "*self" or "*mut self" -- not supported. Try to avoid
+                // emitting cryptic "unexpected token" errors.
+                self.bump();
+                let mutability = if Parser::token_is_mutability(&self.token) {
+                    self.parse_mutability()
+                } else { MutImmutable };
+                if self.is_self_ident() {
+                    self.span_err(self.span, "cannot pass self by unsafe pointer");
+                    self.bump();
                 }
-                SelfUniq(MutImmutable)
-            }, self)
-          }
-          token::IDENT(..) if self.is_self_ident() => {
-            self.bump();
-            SelfValue(MutImmutable)
-          }
-          token::BINOP(token::STAR) => {
-            // Possibly "*self" or "*mut self" -- not supported. Try to avoid
-            // emitting cryptic "unexpected token" errors.
-            self.bump();
-            let mutability = if Parser::token_is_mutability(&self.token) {
-                self.parse_mutability()
-            } else { MutImmutable };
-            if self.is_self_ident() {
-                self.span_err(self.span, "cannot pass self by unsafe pointer");
+                SelfValue(mutability)
+            }
+            _ if Parser::token_is_mutability(&self.token) &&
+                    self.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) => {
+                let mutability = self.parse_mutability();
+                self.expect_self_ident();
+                SelfValue(mutability)
+            }
+            _ if Parser::token_is_mutability(&self.token) &&
+                    self.look_ahead(1, |t| *t == token::TILDE) &&
+                    self.look_ahead(2, |t| token::is_keyword(keywords::Self, t)) => {
+                let mutability = self.parse_mutability();
                 self.bump();
+                self.expect_self_ident();
+                SelfUniq(mutability)
             }
-            SelfValue(mutability)
-          }
-          _ if Parser::token_is_mutability(&self.token) &&
-               self.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) => {
-            let mutability = self.parse_mutability();
-            self.expect_self_ident();
-            SelfValue(mutability)
-          }
-          _ if Parser::token_is_mutability(&self.token) &&
-               self.look_ahead(1, |t| *t == token::TILDE) &&
-               self.look_ahead(2, |t| token::is_keyword(keywords::Self, t)) => {
-            let mutability = self.parse_mutability();
-            self.bump();
-            self.expect_self_ident();
-            SelfUniq(mutability)
-          }
-          _ => {
-            SelfStatic
-          }
+            _ => SelfStatic
         };
 
         // If we parsed a self type, expect a comma before the argument list.