about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-01-29 08:21:38 -0800
committerbors <bors@rust-lang.org>2014-01-29 08:21:38 -0800
commite1580f6d09f0cd990c3eed55b1d6181af3258791 (patch)
tree034b8287f1f017f7956d004be95184f53140bd5d /src/libsyntax
parent87004db1137c9126ecc8834b1c881c2ef09ee8ef (diff)
parenta6867e259b98904d0144904b4ffbba61f7c8f6f9 (diff)
downloadrust-e1580f6d09f0cd990c3eed55b1d6181af3258791.tar.gz
rust-e1580f6d09f0cd990c3eed55b1d6181af3258791.zip
auto merge of #11868 : bytbox/rust/remove-do, r=alexcrichton
Fixes #10815.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs2
-rw-r--r--src/libsyntax/fold.rs1
-rw-r--r--src/libsyntax/parse/classify.rs2
-rw-r--r--src/libsyntax/parse/parser.rs76
-rw-r--r--src/libsyntax/parse/token.rs79
-rw-r--r--src/libsyntax/print/pprust.rs22
-rw-r--r--src/libsyntax/visit.rs3
7 files changed, 44 insertions, 141 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 10b1aad8138..3070ecde71e 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -539,7 +539,6 @@ impl Expr {
 #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
 pub enum CallSugar {
     NoSugar,
-    DoSugar,
     ForSugar
 }
 
@@ -566,7 +565,6 @@ pub enum Expr_ {
     ExprMatch(@Expr, ~[Arm]),
     ExprFnBlock(P<FnDecl>, P<Block>),
     ExprProc(P<FnDecl>, P<Block>),
-    ExprDoBody(@Expr),
     ExprBlock(P<Block>),
 
     ExprAssign(@Expr, @Expr),
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index c739fb911ba..d02f6384990 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -752,7 +752,6 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr {
         ExprUnary(callee_id, binop, ohs) => {
             ExprUnary(folder.new_id(callee_id), binop, folder.fold_expr(ohs))
         }
-        ExprDoBody(f) => ExprDoBody(folder.fold_expr(f)),
         ExprLit(_) => e.node.clone(),
         ExprCast(expr, ty) => {
             ExprCast(folder.fold_expr(expr), folder.fold_ty(ty))
diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs
index 61c80919b6e..accf5e73540 100644
--- a/src/libsyntax/parse/classify.rs
+++ b/src/libsyntax/parse/classify.rs
@@ -29,9 +29,7 @@ pub fn expr_requires_semi_to_be_stmt(e: @ast::Expr) -> bool {
       | ast::ExprWhile(..)
       | ast::ExprLoop(..)
       | ast::ExprForLoop(..)
-      | ast::ExprCall(_, _, ast::DoSugar)
       | ast::ExprCall(_, _, ast::ForSugar)
-      | ast::ExprMethodCall(_, _, _, _, ast::DoSugar)
       | ast::ExprMethodCall(_, _, _, _, ast::ForSugar) => false,
       _ => true
     }
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 17590ccf523..b4de4dabfc6 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -13,7 +13,7 @@
 use abi;
 use abi::AbiSet;
 use ast::{Sigil, BorrowedSigil, ManagedSigil, OwnedSigil};
-use ast::{CallSugar, NoSugar, DoSugar};
+use ast::{CallSugar, NoSugar};
 use ast::{BareFnTy, ClosureTy};
 use ast::{RegionTyParamBound, TraitTyParamBound};
 use ast::{Provided, Public, Purity};
@@ -24,7 +24,7 @@ use ast::{Crate, CrateConfig, Decl, DeclItem};
 use ast::{DeclLocal, DefaultBlock, UnDeref, BiDiv, EMPTY_CTXT, EnumDef, ExplicitSelf};
 use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain};
 use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox};
-use ast::{ExprBreak, ExprCall, ExprCast, ExprDoBody};
+use ast::{ExprBreak, ExprCall, ExprCast};
 use ast::{ExprField, ExprFnBlock, ExprIf, ExprIndex};
 use ast::{ExprLit, ExprLogLevel, ExprLoop, ExprMac};
 use ast::{ExprMethodCall, ExprParen, ExprPath, ExprProc};
@@ -1796,9 +1796,6 @@ impl Parser {
             return self.parse_if_expr();
         } else if self.eat_keyword(keywords::For) {
             return self.parse_for_expr(None);
-        } else if self.eat_keyword(keywords::Do) {
-            return self.parse_sugary_call_expr(lo, ~"do", DoSugar,
-                                               ExprDoBody);
         } else if self.eat_keyword(keywords::While) {
             return self.parse_while_expr();
         } else if Parser::token_is_lifetime(&self.token) {
@@ -2541,75 +2538,6 @@ impl Parser {
         self.mk_expr(lo, hi, ExprForLoop(pat, expr, loop_block, opt_ident))
     }
 
-
-    // parse a 'do'.
-    // the 'do' expression parses as a call, but looks like
-    // a function call followed by a closure expression.
-    pub fn parse_sugary_call_expr(&mut self,
-                                  lo: BytePos,
-                                  keyword: ~str,
-                                  sugar: CallSugar,
-                                  ctor: |v: @Expr| -> Expr_)
-                                  -> @Expr {
-        // Parse the callee `foo` in
-        //    do foo || {
-        //    do foo.bar || {
-        // etc, or the portion of the call expression before the lambda in
-        //    do foo() || {
-        // or
-        //    do foo.bar(a) || {
-        // Turn on the restriction to stop at | or || so we can parse
-        // them as the lambda arguments
-        let e = self.parse_expr_res(RESTRICT_NO_BAR_OR_DOUBLEBAR_OP);
-        match e.node {
-            ExprCall(f, ref args, NoSugar) => {
-                let block = self.parse_lambda_block_expr();
-                let last_arg = self.mk_expr(block.span.lo, block.span.hi,
-                                            ctor(block));
-                let args = vec::append_one((*args).clone(), last_arg);
-                self.mk_expr(lo, block.span.hi, ExprCall(f, args, sugar))
-            }
-            ExprMethodCall(_, i, ref tps, ref args, NoSugar) => {
-                let block = self.parse_lambda_block_expr();
-                let last_arg = self.mk_expr(block.span.lo, block.span.hi,
-                                            ctor(block));
-                let args = vec::append_one((*args).clone(), last_arg);
-                let method_call = self.mk_method_call(i,
-                                                      (*tps).clone(),
-                                                      args,
-                                                      sugar);
-                self.mk_expr(lo, block.span.hi, method_call)
-            }
-            ExprField(f, i, ref tps) => {
-                let block = self.parse_lambda_block_expr();
-                let last_arg = self.mk_expr(block.span.lo, block.span.hi,
-                                            ctor(block));
-                let method_call = self.mk_method_call(i,
-                                                      (*tps).clone(),
-                                                      ~[f, last_arg],
-                                                      sugar);
-                self.mk_expr(lo, block.span.hi, method_call)
-            }
-            ExprPath(..) | ExprCall(..) | ExprMethodCall(..) |
-                ExprParen(..) => {
-                let block = self.parse_lambda_block_expr();
-                let last_arg = self.mk_expr(block.span.lo, block.span.hi,
-                                            ctor(block));
-                let call = self.mk_call(e, ~[last_arg], sugar);
-                self.mk_expr(lo, last_arg.span.hi, call)
-            }
-            _ => {
-                // There may be other types of expressions that can
-                // represent the callee in `do` expressions
-                // but they aren't represented by tests
-                debug!("sugary call on {:?}", e.node);
-                self.span_fatal(
-                    e.span,
-                    format!("`{}` must be followed by a block call", keyword));
-            }
-        }
-    }
-
     pub fn parse_while_expr(&mut self) -> @Expr {
         let lo = self.last_span.lo;
         let cond = self.parse_expr();
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 56681ef2def..68e2f44ebb1 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -433,51 +433,50 @@ declare_special_idents_and_keywords! {
         (14,                         As,         "as");
         (15,                         Break,      "break");
         (16,                         Const,      "const");
-        (17,                         Do,         "do");
-        (18,                         Else,       "else");
-        (19,                         Enum,       "enum");
-        (20,                         Extern,     "extern");
-        (21,                         False,      "false");
-        (22,                         Fn,         "fn");
-        (23,                         For,        "for");
-        (24,                         If,         "if");
-        (25,                         Impl,       "impl");
-        (26,                         In,         "in");
-        (27,                         Let,        "let");
-        (28,                         __LogLevel, "__log_level");
-        (29,                         Loop,       "loop");
-        (30,                         Match,      "match");
-        (31,                         Mod,        "mod");
-        (32,                         Mut,        "mut");
-        (33,                         Once,       "once");
-        (34,                         Priv,       "priv");
-        (35,                         Pub,        "pub");
-        (36,                         Ref,        "ref");
-        (37,                         Return,     "return");
+        (17,                         Else,       "else");
+        (18,                         Enum,       "enum");
+        (19,                         Extern,     "extern");
+        (20,                         False,      "false");
+        (21,                         Fn,         "fn");
+        (22,                         For,        "for");
+        (23,                         If,         "if");
+        (24,                         Impl,       "impl");
+        (25,                         In,         "in");
+        (26,                         Let,        "let");
+        (27,                         __LogLevel, "__log_level");
+        (28,                         Loop,       "loop");
+        (29,                         Match,      "match");
+        (30,                         Mod,        "mod");
+        (31,                         Mut,        "mut");
+        (32,                         Once,       "once");
+        (33,                         Priv,       "priv");
+        (34,                         Pub,        "pub");
+        (35,                         Ref,        "ref");
+        (36,                         Return,     "return");
         // Static and Self are also special idents (prefill de-dupes)
         (super::STATIC_KEYWORD_NAME, Static,     "static");
         (super::SELF_KEYWORD_NAME,   Self,       "self");
-        (38,                         Struct,     "struct");
-        (39,                         Super,      "super");
-        (40,                         True,       "true");
-        (41,                         Trait,      "trait");
-        (42,                         Type,       "type");
-        (43,                         Unsafe,     "unsafe");
-        (44,                         Use,        "use");
-        (45,                         While,      "while");
-        (46,                         Continue,   "continue");
-        (47,                         Proc,       "proc");
-        (48,                         Box,        "box");
+        (37,                         Struct,     "struct");
+        (38,                         Super,      "super");
+        (39,                         True,       "true");
+        (40,                         Trait,      "trait");
+        (41,                         Type,       "type");
+        (42,                         Unsafe,     "unsafe");
+        (43,                         Use,        "use");
+        (44,                         While,      "while");
+        (45,                         Continue,   "continue");
+        (46,                         Proc,       "proc");
+        (47,                         Box,        "box");
 
         'reserved:
-        (49,                         Alignof,    "alignof");
-        (50,                         Be,         "be");
-        (51,                         Offsetof,   "offsetof");
-        (52,                         Pure,       "pure");
-        (53,                         Sizeof,     "sizeof");
-        (54,                         Typeof,     "typeof");
-        (55,                         Unsized,    "unsized");
-        (56,                         Yield,      "yield");
+        (48,                         Alignof,    "alignof");
+        (49,                         Be,         "be");
+        (50,                         Offsetof,   "offsetof");
+        (51,                         Pure,       "pure");
+        (52,                         Sizeof,     "sizeof");
+        (53,                         Typeof,     "typeof");
+        (54,                         Unsized,    "unsized");
+        (55,                         Yield,      "yield");
     }
 }
 
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index d3c194b6af6..68efdf31e03 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -1088,10 +1088,6 @@ pub fn print_call_pre(s: &mut State,
                       base_args: &mut ~[@ast::Expr])
                    -> Option<@ast::Expr> {
     match sugar {
-        ast::DoSugar => {
-            head(s, "do");
-            Some(base_args.pop().unwrap())
-        }
         ast::ForSugar => {
             head(s, "for");
             Some(base_args.pop().unwrap())
@@ -1111,19 +1107,8 @@ pub fn print_call_post(s: &mut State,
     }
     if sugar != ast::NoSugar {
         nbsp(s);
-        match blk.unwrap().node {
-          // need to handle closures specifically
-          ast::ExprDoBody(e) => {
-            end(s); // we close our head box; closure
-                    // will create it's own.
-            print_expr(s, e);
-            end(s); // close outer box, as closures don't
-          }
-          _ => {
-            // not sure if this can happen.
-            print_expr(s, blk.unwrap());
-          }
-        }
+        // not sure if this can happen
+        print_expr(s, blk.unwrap());
     }
 }
 
@@ -1405,9 +1390,6 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) {
         // empty box to satisfy the close.
         ibox(s, 0);
       }
-      ast::ExprDoBody(body) => {
-        print_expr(s, body);
-      }
       ast::ExprBlock(blk) => {
         // containing cbox, will be closed by print-block at }
         cbox(s, indent_unit);
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index 5e7ad3af526..7201fc3a380 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -665,8 +665,7 @@ pub fn walk_expr<E: Clone, V: Visitor<E>>(visitor: &mut V, expression: &Expr, en
             visitor.visit_expr(right_expression, env.clone())
         }
         ExprAddrOf(_, subexpression) |
-        ExprUnary(_, _, subexpression) |
-        ExprDoBody(subexpression) => {
+        ExprUnary(_, _, subexpression) => {
             visitor.visit_expr(subexpression, env.clone())
         }
         ExprLit(_) => {}