Skip to content

Commit e6bce95

Browse files
committed
Auto merge of #44375 - topecongiro:macrodef-span, r=petrochenkov
Add visibility to span for macros 2.0 cc rust-lang/rustfmt#1949. r? @nrc
2 parents 3d29f0e + ed63e0b commit e6bce95

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/libsyntax/parse/parser.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -3789,9 +3789,9 @@ impl<'a> Parser<'a> {
37893789
is_defaultness
37903790
}
37913791

3792-
fn eat_macro_def(&mut self, attrs: &[Attribute], vis: &Visibility)
3792+
fn eat_macro_def(&mut self, attrs: &[Attribute], vis: &Visibility, lo: Span)
37933793
-> PResult<'a, Option<P<Item>>> {
3794-
let lo = self.span;
3794+
let token_lo = self.span;
37953795
let (ident, def) = match self.token {
37963796
token::Ident(ident) if ident.name == keywords::Macro.name() => {
37973797
self.bump();
@@ -3811,7 +3811,7 @@ impl<'a> Parser<'a> {
38113811
};
38123812
TokenStream::concat(vec![
38133813
args.into(),
3814-
TokenTree::Token(lo.to(self.prev_span), token::FatArrow).into(),
3814+
TokenTree::Token(token_lo.to(self.prev_span), token::FatArrow).into(),
38153815
body.into(),
38163816
])
38173817
} else {
@@ -3861,7 +3861,7 @@ impl<'a> Parser<'a> {
38613861
node: StmtKind::Local(self.parse_local(attrs.into())?),
38623862
span: lo.to(self.prev_span),
38633863
}
3864-
} else if let Some(macro_def) = self.eat_macro_def(&attrs, &Visibility::Inherited)? {
3864+
} else if let Some(macro_def) = self.eat_macro_def(&attrs, &Visibility::Inherited, lo)? {
38653865
Stmt {
38663866
id: ast::DUMMY_NODE_ID,
38673867
node: StmtKind::Item(macro_def),
@@ -6011,7 +6011,7 @@ impl<'a> Parser<'a> {
60116011
maybe_append(attrs, extra_attrs));
60126012
return Ok(Some(item));
60136013
}
6014-
if let Some(macro_def) = self.eat_macro_def(&attrs, &visibility)? {
6014+
if let Some(macro_def) = self.eat_macro_def(&attrs, &visibility, lo)? {
60156015
return Ok(Some(macro_def));
60166016
}
60176017

0 commit comments

Comments
 (0)