Skip to content

Commit 323781c

Browse files
committed
Auto merge of #30075 - kyeah:mac-span, r=sanxiyn
Fixes #28424 (item macros), #30067 (impl item macros), and pattern macros.
2 parents 7499558 + 920120e commit 323781c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3253,7 +3253,8 @@ impl<'a> Parser<'a> {
32533253
let tts = try!(self.parse_seq_to_end(&token::CloseDelim(delim),
32543254
seq_sep_none(), |p| p.parse_token_tree()));
32553255
let mac = Mac_ { path: path, tts: tts, ctxt: EMPTY_CTXT };
3256-
pat = PatMac(codemap::Spanned {node: mac, span: self.span});
3256+
pat = PatMac(codemap::Spanned {node: mac,
3257+
span: mk_sp(lo, self.last_span.hi)});
32573258
} else {
32583259
// Parse ident @ pat
32593260
// This can give false positives and parse nullary enums,
@@ -4475,6 +4476,7 @@ impl<'a> Parser<'a> {
44754476
let last_span = self.last_span;
44764477
self.complain_if_pub_macro(vis, last_span);
44774478

4479+
let lo = self.span.lo;
44784480
let pth = try!(self.parse_path(NoTypesAllowed));
44794481
try!(self.expect(&token::Not));
44804482

@@ -4485,8 +4487,8 @@ impl<'a> Parser<'a> {
44854487
|p| p.parse_token_tree()));
44864488
let m_ = Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT };
44874489
let m: ast::Mac = codemap::Spanned { node: m_,
4488-
span: mk_sp(self.span.lo,
4489-
self.span.hi) };
4490+
span: mk_sp(lo,
4491+
self.last_span.hi) };
44904492
if delim != token::Brace {
44914493
try!(self.expect(&token::Semi))
44924494
}
@@ -5513,6 +5515,8 @@ impl<'a> Parser<'a> {
55135515
let last_span = self.last_span;
55145516
self.complain_if_pub_macro(visibility, last_span);
55155517

5518+
let mac_lo = self.span.lo;
5519+
55165520
// item macro.
55175521
let pth = try!(self.parse_path(NoTypesAllowed));
55185522
try!(self.expect(&token::Not));
@@ -5533,8 +5537,8 @@ impl<'a> Parser<'a> {
55335537
// single-variant-enum... :
55345538
let m = Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT };
55355539
let m: ast::Mac = codemap::Spanned { node: m,
5536-
span: mk_sp(self.span.lo,
5537-
self.span.hi) };
5540+
span: mk_sp(mac_lo,
5541+
self.last_span.hi) };
55385542

55395543
if delim != token::Brace {
55405544
if !try!(self.eat(&token::Semi) ){

0 commit comments

Comments
 (0)