Skip to content

Commit b9fa6c6

Browse files
committed
Fix spans for macros
1 parent c87ec1e commit b9fa6c6

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/libsyntax/parse/parser.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -2162,13 +2162,13 @@ impl<'a> Parser<'a> {
21622162
&token::CloseDelim(delim),
21632163
seq_sep_none(),
21642164
|p| p.parse_token_tree()));
2165-
let hi = self.span.hi;
2165+
let hi = self.last_span.hi;
21662166

21672167
return Ok(self.mk_mac_expr(lo,
2168-
hi,
2169-
MacInvocTT(pth,
2170-
tts,
2171-
EMPTY_CTXT)));
2168+
hi,
2169+
MacInvocTT(pth,
2170+
tts,
2171+
EMPTY_CTXT)));
21722172
}
21732173
if self.check(&token::OpenDelim(token::Brace)) {
21742174
// This is a struct literal, unless we're prohibited
@@ -3449,7 +3449,7 @@ impl<'a> Parser<'a> {
34493449
seq_sep_none(),
34503450
|p| p.parse_token_tree()
34513451
));
3452-
let hi = self.span.hi;
3452+
let hi = self.last_span.hi;
34533453

34543454
let style = if delim == token::Brace {
34553455
MacStmtWithBraces
@@ -3567,7 +3567,7 @@ impl<'a> Parser<'a> {
35673567
token::Semi => {
35683568
stmts.push(P(Spanned {
35693569
node: StmtMac(mac, MacStmtWithSemicolon),
3570-
span: span,
3570+
span: mk_sp(span.lo, self.span.hi),
35713571
}));
35723572
try!(self.bump());
35733573
}
@@ -3591,7 +3591,7 @@ impl<'a> Parser<'a> {
35913591
token::Semi => {
35923592
stmts.push(P(Spanned {
35933593
node: StmtMac(m, MacStmtWithSemicolon),
3594-
span: span,
3594+
span: mk_sp(span.lo, self.span.hi),
35953595
}));
35963596
try!(self.bump());
35973597
}
@@ -3610,13 +3610,15 @@ impl<'a> Parser<'a> {
36103610
}
36113611
}
36123612
_ => { // all other kinds of statements:
3613+
let mut hi = span.hi;
36133614
if classify::stmt_ends_with_semi(&node) {
36143615
try!(self.commit_stmt_expecting(token::Semi));
3616+
hi = self.last_span.hi;
36153617
}
36163618

36173619
stmts.push(P(Spanned {
36183620
node: node,
3619-
span: span
3621+
span: mk_sp(span.lo, hi)
36203622
}));
36213623
}
36223624
}

0 commit comments

Comments
 (0)