Skip to content

Fix spans for macros #30075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 29, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3253,7 +3253,8 @@ impl<'a> Parser<'a> {
let tts = try!(self.parse_seq_to_end(&token::CloseDelim(delim),
seq_sep_none(), |p| p.parse_token_tree()));
let mac = Mac_ { path: path, tts: tts, ctxt: EMPTY_CTXT };
pat = PatMac(codemap::Spanned {node: mac, span: self.span});
pat = PatMac(codemap::Spanned {node: mac,
span: mk_sp(lo, self.last_span.hi)});
} else {
// Parse ident @ pat
// This can give false positives and parse nullary enums,
Expand Down Expand Up @@ -4475,6 +4476,7 @@ impl<'a> Parser<'a> {
let last_span = self.last_span;
self.complain_if_pub_macro(vis, last_span);

let lo = self.span.lo;
let pth = try!(self.parse_path(NoTypesAllowed));
try!(self.expect(&token::Not));

Expand All @@ -4485,8 +4487,8 @@ impl<'a> Parser<'a> {
|p| p.parse_token_tree()));
let m_ = Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT };
let m: ast::Mac = codemap::Spanned { node: m_,
span: mk_sp(self.span.lo,
self.span.hi) };
span: mk_sp(lo,
self.last_span.hi) };
if delim != token::Brace {
try!(self.expect(&token::Semi))
}
Expand Down Expand Up @@ -5513,6 +5515,8 @@ impl<'a> Parser<'a> {
let last_span = self.last_span;
self.complain_if_pub_macro(visibility, last_span);

let mac_lo = self.span.lo;

// item macro.
let pth = try!(self.parse_path(NoTypesAllowed));
try!(self.expect(&token::Not));
Expand All @@ -5533,8 +5537,8 @@ impl<'a> Parser<'a> {
// single-variant-enum... :
let m = Mac_ { path: pth, tts: tts, ctxt: EMPTY_CTXT };
let m: ast::Mac = codemap::Spanned { node: m,
span: mk_sp(self.span.lo,
self.span.hi) };
span: mk_sp(mac_lo,
self.last_span.hi) };

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