Attach TokenStream
to ast::Visibility
A `Visibility` does not have outer attributes, so we only capture tokens when parsing a `macro_rules!` matcher
This commit is contained in:
parent
55082ce413
commit
c1011165e6
22 changed files with 120 additions and 50 deletions
|
@ -3,7 +3,7 @@ use crate::base::ExtCtxt;
|
|||
use rustc_ast::attr;
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::{self as ast, AttrVec, BlockCheckMode, Expr, PatKind, UnOp};
|
||||
use rustc_span::source_map::{respan, Spanned};
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
|
||||
use rustc_span::Span;
|
||||
|
@ -584,7 +584,11 @@ impl<'a> ExtCtxt<'a> {
|
|||
attrs,
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
kind,
|
||||
vis: respan(span.shrink_to_lo(), ast::VisibilityKind::Inherited),
|
||||
vis: ast::Visibility {
|
||||
span: span.shrink_to_lo(),
|
||||
kind: ast::VisibilityKind::Inherited,
|
||||
tokens: None,
|
||||
},
|
||||
span,
|
||||
tokens: None,
|
||||
})
|
||||
|
@ -598,7 +602,11 @@ impl<'a> ExtCtxt<'a> {
|
|||
span: ty.span,
|
||||
ty,
|
||||
ident: None,
|
||||
vis: respan(vis_span, ast::VisibilityKind::Inherited),
|
||||
vis: ast::Visibility {
|
||||
span: vis_span,
|
||||
kind: ast::VisibilityKind::Inherited,
|
||||
tokens: None,
|
||||
},
|
||||
attrs: Vec::new(),
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
is_placeholder: false,
|
||||
|
@ -617,7 +625,11 @@ impl<'a> ExtCtxt<'a> {
|
|||
disr_expr: None,
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
ident,
|
||||
vis: respan(vis_span, ast::VisibilityKind::Inherited),
|
||||
vis: ast::Visibility {
|
||||
span: vis_span,
|
||||
kind: ast::VisibilityKind::Inherited,
|
||||
tokens: None,
|
||||
},
|
||||
span,
|
||||
is_placeholder: false,
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ use rustc_session::lint::builtin::UNUSED_DOC_COMMENTS;
|
|||
use rustc_session::lint::BuiltinLintDiagnostics;
|
||||
use rustc_session::parse::{feature_err, ParseSess};
|
||||
use rustc_session::Limit;
|
||||
use rustc_span::source_map::respan;
|
||||
use rustc_span::symbol::{sym, Ident, Symbol};
|
||||
use rustc_span::{ExpnId, FileName, Span, DUMMY_SP};
|
||||
|
||||
|
@ -358,7 +357,11 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||
kind: ast::ItemKind::Mod(krate.module),
|
||||
ident: Ident::invalid(),
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
vis: respan(krate.span.shrink_to_lo(), ast::VisibilityKind::Public),
|
||||
vis: ast::Visibility {
|
||||
span: krate.span.shrink_to_lo(),
|
||||
kind: ast::VisibilityKind::Public,
|
||||
tokens: None,
|
||||
},
|
||||
tokens: None,
|
||||
})]);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::expand::{AstFragment, AstFragmentKind};
|
|||
use rustc_ast as ast;
|
||||
use rustc_ast::mut_visit::*;
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_span::source_map::{dummy_spanned, DUMMY_SP};
|
||||
use rustc_span::source_map::DUMMY_SP;
|
||||
use rustc_span::symbol::Ident;
|
||||
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
|
@ -26,7 +26,11 @@ pub fn placeholder(
|
|||
|
||||
let ident = Ident::invalid();
|
||||
let attrs = Vec::new();
|
||||
let vis = vis.unwrap_or_else(|| dummy_spanned(ast::VisibilityKind::Inherited));
|
||||
let vis = vis.unwrap_or(ast::Visibility {
|
||||
span: DUMMY_SP,
|
||||
kind: ast::VisibilityKind::Inherited,
|
||||
tokens: None,
|
||||
});
|
||||
let span = DUMMY_SP;
|
||||
let expr_placeholder = || {
|
||||
P(ast::Expr {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue