]> git.lizzy.rs Git - rust.git/commitdiff
Change spans for sugary call expressions
authorSeo Sanghyeon <sanxiyn@gmail.com>
Thu, 4 Jul 2013 11:48:45 +0000 (20:48 +0900)
committerSeo Sanghyeon <sanxiyn@gmail.com>
Fri, 5 Jul 2013 04:03:25 +0000 (13:03 +0900)
src/libsyntax/parse/parser.rs

index cc0baa28e20d75a076ffafcc53c7d2102ca7f2e9..ae87fd8774a9ace0c2ebb0e37bf1657ad25abc2b 100644 (file)
@@ -1549,10 +1549,10 @@ pub fn parse_bottom_expr(&self) -> @expr {
         } else if self.eat_keyword(keywords::If) {
             return self.parse_if_expr();
         } else if self.eat_keyword(keywords::For) {
-            return self.parse_sugary_call_expr(~"for", ForSugar,
+            return self.parse_sugary_call_expr(lo, ~"for", ForSugar,
                                                expr_loop_body);
         } else if self.eat_keyword(keywords::Do) {
-            return self.parse_sugary_call_expr(~"do", DoSugar,
+            return self.parse_sugary_call_expr(lo, ~"do", DoSugar,
                                                expr_do_body);
         } else if self.eat_keyword(keywords::While) {
             return self.parse_while_expr();
@@ -2264,12 +2264,11 @@ pub fn parse_else_expr(&self) -> @expr {
     // parse a 'for' or 'do'.
     // the 'for' and 'do' expressions parse as calls, but look like
     // function calls followed by a closure expression.
-    pub fn parse_sugary_call_expr(&self,
+    pub fn parse_sugary_call_expr(&self, lo: BytePos,
                                   keyword: ~str,
                                   sugar: CallSugar,
                                   ctor: &fn(v: @expr) -> expr_)
                                   -> @expr {
-        let lo = self.last_span;
         // Parse the callee `foo` in
         //    for foo || {
         //    for foo.bar || {
@@ -2286,21 +2285,21 @@ pub fn parse_sugary_call_expr(&self,
                 let last_arg = self.mk_expr(block.span.lo, block.span.hi,
                                             ctor(block));
                 let args = vec::append(copy *args, [last_arg]);
-                self.mk_expr(lo.lo, block.span.hi, expr_call(f, args, sugar))
+                self.mk_expr(lo, block.span.hi, expr_call(f, args, sugar))
             }
             expr_method_call(_, f, 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(copy *args, [last_arg]);
-                self.mk_expr(lo.lo, block.span.hi,
+                self.mk_expr(lo, block.span.hi,
                              self.mk_method_call(f, i, copy *tps, args, sugar))
             }
             expr_field(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));
-                self.mk_expr(lo.lo, block.span.hi,
+                self.mk_expr(lo, block.span.hi,
                              self.mk_method_call(f, i, copy *tps, ~[last_arg], sugar))
             }
             expr_path(*) | expr_call(*) | expr_method_call(*) |
@@ -2309,7 +2308,7 @@ pub fn parse_sugary_call_expr(&self,
                 let last_arg = self.mk_expr(block.span.lo, block.span.hi,
                                             ctor(block));
                 self.mk_expr(
-                    lo.lo,
+                    lo,
                     last_arg.span.hi,
                     self.mk_call(e, ~[last_arg], sugar))
             }
@@ -2319,7 +2318,7 @@ pub fn parse_sugary_call_expr(&self,
                 // but they aren't represented by tests
                 debug!("sugary call on %?", e.node);
                 self.span_fatal(
-                    *lo,
+                    e.span,
                     fmt!("`%s` must be followed by a block call", keyword));
             }
         }