]> git.lizzy.rs Git - rust.git/commitdiff
Fix spans for macros
authorNick Cameron <ncameron@mozilla.com>
Thu, 9 Apr 2015 20:49:10 +0000 (08:49 +1200)
committerNick Cameron <ncameron@mozilla.com>
Sun, 12 Apr 2015 01:28:17 +0000 (13:28 +1200)
src/libsyntax/parse/parser.rs

index 3cc16006b1b9c08a0812ad7033a8d562755f6b3f..a3dd77b8197dc187b8a24d58189a9ba33550cbf5 100644 (file)
@@ -2162,13 +2162,13 @@ pub fn parse_bottom_expr(&mut self) -> PResult<P<Expr>> {
                             &token::CloseDelim(delim),
                             seq_sep_none(),
                             |p| p.parse_token_tree()));
-                        let hi = self.span.hi;
+                        let hi = self.last_span.hi;
 
                         return Ok(self.mk_mac_expr(lo,
-                                                hi,
-                                                MacInvocTT(pth,
-                                                           tts,
-                                                           EMPTY_CTXT)));
+                                                   hi,
+                                                   MacInvocTT(pth,
+                                                              tts,
+                                                              EMPTY_CTXT)));
                     }
                     if self.check(&token::OpenDelim(token::Brace)) {
                         // This is a struct literal, unless we're prohibited
@@ -3449,7 +3449,7 @@ fn check_expected_item(p: &mut Parser, attrs: &[Attribute]) {
                 seq_sep_none(),
                 |p| p.parse_token_tree()
             ));
-            let hi = self.span.hi;
+            let hi = self.last_span.hi;
 
             let style = if delim == token::Brace {
                 MacStmtWithBraces
@@ -3567,7 +3567,7 @@ fn parse_block_tail(&mut self, lo: BytePos, s: BlockCheckMode) -> PResult<P<Bloc
                         token::Semi => {
                             stmts.push(P(Spanned {
                                 node: StmtMac(mac, MacStmtWithSemicolon),
-                                span: span,
+                                span: mk_sp(span.lo, self.span.hi),
                             }));
                             try!(self.bump());
                         }
@@ -3591,7 +3591,7 @@ fn parse_block_tail(&mut self, lo: BytePos, s: BlockCheckMode) -> PResult<P<Bloc
                         token::Semi => {
                             stmts.push(P(Spanned {
                                 node: StmtMac(m, MacStmtWithSemicolon),
-                                span: span,
+                                span: mk_sp(span.lo, self.span.hi),
                             }));
                             try!(self.bump());
                         }
@@ -3610,13 +3610,15 @@ fn parse_block_tail(&mut self, lo: BytePos, s: BlockCheckMode) -> PResult<P<Bloc
                     }
                 }
                 _ => { // all other kinds of statements:
+                    let mut hi = span.hi;
                     if classify::stmt_ends_with_semi(&node) {
                         try!(self.commit_stmt_expecting(token::Semi));
+                        hi = self.last_span.hi;
                     }
 
                     stmts.push(P(Spanned {
                         node: node,
-                        span: span
+                        span: mk_sp(span.lo, hi)
                     }));
                 }
             }