ast: Mac/Macro -> MacCall

This commit is contained in:
Vadim Petrochenkov 2020-02-29 19:32:20 +03:00
parent 23de8275c9
commit e809e0214e
43 changed files with 200 additions and 197 deletions

View File

@ -14,7 +14,7 @@
//! - [`Generics`], [`GenericParam`], [`WhereClause`]: Metadata associated with generic parameters. //! - [`Generics`], [`GenericParam`], [`WhereClause`]: Metadata associated with generic parameters.
//! - [`EnumDef`] and [`Variant`]: Enum declaration. //! - [`EnumDef`] and [`Variant`]: Enum declaration.
//! - [`Lit`] and [`LitKind`]: Literal expressions. //! - [`Lit`] and [`LitKind`]: Literal expressions.
//! - [`MacroDef`], [`MacStmtStyle`], [`Mac`], [`MacDelimeter`]: Macro definition and invocation. //! - [`MacroDef`], [`MacStmtStyle`], [`MacCall`], [`MacDelimeter`]: Macro definition and invocation.
//! - [`Attribute`]: Metadata associated with item. //! - [`Attribute`]: Metadata associated with item.
//! - [`UnOp`], [`UnOpKind`], [`BinOp`], [`BinOpKind`]: Unary and binary operators. //! - [`UnOp`], [`UnOpKind`], [`BinOp`], [`BinOpKind`]: Unary and binary operators.
@ -513,7 +513,7 @@ impl Pat {
TyKind::Path(None, Path::from_ident(*ident)) TyKind::Path(None, Path::from_ident(*ident))
} }
PatKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()), PatKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()),
PatKind::Mac(mac) => TyKind::Mac(mac.clone()), PatKind::MacCall(mac) => TyKind::MacCall(mac.clone()),
// `&mut? P` can be reinterpreted as `&mut? T` where `T` is `P` reparsed as a type. // `&mut? P` can be reinterpreted as `&mut? T` where `T` is `P` reparsed as a type.
PatKind::Ref(pat, mutbl) => { PatKind::Ref(pat, mutbl) => {
pat.to_ty().map(|ty| TyKind::Rptr(None, MutTy { ty, mutbl: *mutbl }))? pat.to_ty().map(|ty| TyKind::Rptr(None, MutTy { ty, mutbl: *mutbl }))?
@ -567,7 +567,7 @@ impl Pat {
| PatKind::Range(..) | PatKind::Range(..)
| PatKind::Ident(..) | PatKind::Ident(..)
| PatKind::Path(..) | PatKind::Path(..)
| PatKind::Mac(_) => {} | PatKind::MacCall(_) => {}
} }
} }
@ -682,7 +682,7 @@ pub enum PatKind {
Paren(P<Pat>), Paren(P<Pat>),
/// A macro pattern; pre-expansion. /// A macro pattern; pre-expansion.
Mac(Mac), MacCall(MacCall),
} }
#[derive( #[derive(
@ -881,9 +881,9 @@ impl Stmt {
pub fn add_trailing_semicolon(mut self) -> Self { pub fn add_trailing_semicolon(mut self) -> Self {
self.kind = match self.kind { self.kind = match self.kind {
StmtKind::Expr(expr) => StmtKind::Semi(expr), StmtKind::Expr(expr) => StmtKind::Semi(expr),
StmtKind::Mac(mac) => { StmtKind::MacCall(mac) => StmtKind::MacCall(
StmtKind::Mac(mac.map(|(mac, _style, attrs)| (mac, MacStmtStyle::Semicolon, attrs))) mac.map(|(mac, _style, attrs)| (mac, MacStmtStyle::Semicolon, attrs)),
} ),
kind => kind, kind => kind,
}; };
self self
@ -917,7 +917,7 @@ pub enum StmtKind {
/// Just a trailing semi-colon. /// Just a trailing semi-colon.
Empty, Empty,
/// Macro. /// Macro.
Mac(P<(Mac, MacStmtStyle, AttrVec)>), MacCall(P<(MacCall, MacStmtStyle, AttrVec)>),
} }
#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)] #[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)]
@ -1057,7 +1057,7 @@ impl Expr {
let kind = match &self.kind { let kind = match &self.kind {
// Trivial conversions. // Trivial conversions.
ExprKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()), ExprKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()),
ExprKind::Mac(mac) => TyKind::Mac(mac.clone()), ExprKind::MacCall(mac) => TyKind::MacCall(mac.clone()),
ExprKind::Paren(expr) => expr.to_ty().map(TyKind::Paren)?, ExprKind::Paren(expr) => expr.to_ty().map(TyKind::Paren)?,
@ -1127,7 +1127,7 @@ impl Expr {
ExprKind::Continue(..) => ExprPrecedence::Continue, ExprKind::Continue(..) => ExprPrecedence::Continue,
ExprKind::Ret(..) => ExprPrecedence::Ret, ExprKind::Ret(..) => ExprPrecedence::Ret,
ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm, ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm,
ExprKind::Mac(..) => ExprPrecedence::Mac, ExprKind::MacCall(..) => ExprPrecedence::Mac,
ExprKind::Struct(..) => ExprPrecedence::Struct, ExprKind::Struct(..) => ExprPrecedence::Struct,
ExprKind::Repeat(..) => ExprPrecedence::Repeat, ExprKind::Repeat(..) => ExprPrecedence::Repeat,
ExprKind::Paren(..) => ExprPrecedence::Paren, ExprKind::Paren(..) => ExprPrecedence::Paren,
@ -1259,7 +1259,7 @@ pub enum ExprKind {
InlineAsm(P<InlineAsm>), InlineAsm(P<InlineAsm>),
/// A macro invocation; pre-expansion. /// A macro invocation; pre-expansion.
Mac(Mac), MacCall(MacCall),
/// A struct literal expression. /// A struct literal expression.
/// ///
@ -1345,13 +1345,13 @@ pub enum Movability {
/// Represents a macro invocation. The `path` indicates which macro /// Represents a macro invocation. The `path` indicates which macro
/// is being invoked, and the `args` are arguments passed to it. /// is being invoked, and the `args` are arguments passed to it.
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct Mac { pub struct MacCall {
pub path: Path, pub path: Path,
pub args: P<MacArgs>, pub args: P<MacArgs>,
pub prior_type_ascription: Option<(Span, bool)>, pub prior_type_ascription: Option<(Span, bool)>,
} }
impl Mac { impl MacCall {
pub fn span(&self) -> Span { pub fn span(&self) -> Span {
self.path.span.to(self.args.span().unwrap_or(self.path.span)) self.path.span.to(self.args.span().unwrap_or(self.path.span))
} }
@ -1881,7 +1881,7 @@ pub enum TyKind {
/// Inferred type of a `self` or `&self` argument in a method. /// Inferred type of a `self` or `&self` argument in a method.
ImplicitSelf, ImplicitSelf,
/// A macro in the type position. /// A macro in the type position.
Mac(Mac), MacCall(MacCall),
/// Placeholder for a kind that has failed to be defined. /// Placeholder for a kind that has failed to be defined.
Err, Err,
/// Placeholder for a `va_list`. /// Placeholder for a `va_list`.
@ -2574,7 +2574,7 @@ pub enum ItemKind {
/// A macro invocation. /// A macro invocation.
/// ///
/// E.g., `foo!(..)`. /// E.g., `foo!(..)`.
Mac(Mac), MacCall(MacCall),
/// A macro definition. /// A macro definition.
MacroDef(MacroDef), MacroDef(MacroDef),
@ -2586,7 +2586,7 @@ impl ItemKind {
match self { match self {
Use(..) | Static(..) | Const(..) | Fn(..) | Mod(..) | GlobalAsm(..) | TyAlias(..) Use(..) | Static(..) | Const(..) | Fn(..) | Mod(..) | GlobalAsm(..) | TyAlias(..)
| Struct(..) | Union(..) | Trait(..) | TraitAlias(..) | MacroDef(..) => "a", | Struct(..) | Union(..) | Trait(..) | TraitAlias(..) | MacroDef(..) => "a",
ExternCrate(..) | ForeignMod(..) | Mac(..) | Enum(..) | Impl { .. } => "an", ExternCrate(..) | ForeignMod(..) | MacCall(..) | Enum(..) | Impl { .. } => "an",
} }
} }
@ -2606,7 +2606,7 @@ impl ItemKind {
ItemKind::Union(..) => "union", ItemKind::Union(..) => "union",
ItemKind::Trait(..) => "trait", ItemKind::Trait(..) => "trait",
ItemKind::TraitAlias(..) => "trait alias", ItemKind::TraitAlias(..) => "trait alias",
ItemKind::Mac(..) => "item macro invocation", ItemKind::MacCall(..) => "item macro invocation",
ItemKind::MacroDef(..) => "macro definition", ItemKind::MacroDef(..) => "macro definition",
ItemKind::Impl { .. } => "implementation", ItemKind::Impl { .. } => "implementation",
} }
@ -2648,14 +2648,14 @@ pub enum AssocItemKind {
/// An associated type. /// An associated type.
TyAlias(Defaultness, Generics, GenericBounds, Option<P<Ty>>), TyAlias(Defaultness, Generics, GenericBounds, Option<P<Ty>>),
/// A macro expanding to associated items. /// A macro expanding to associated items.
Macro(Mac), MacCall(MacCall),
} }
impl AssocItemKind { impl AssocItemKind {
pub fn defaultness(&self) -> Defaultness { pub fn defaultness(&self) -> Defaultness {
match *self { match *self {
Self::Const(def, ..) | Self::Fn(def, ..) | Self::TyAlias(def, ..) => def, Self::Const(def, ..) | Self::Fn(def, ..) | Self::TyAlias(def, ..) => def,
Self::Macro(..) => Defaultness::Final, Self::MacCall(..) => Defaultness::Final,
} }
} }
} }
@ -2666,7 +2666,7 @@ impl From<AssocItemKind> for ItemKind {
AssocItemKind::Const(a, b, c) => ItemKind::Const(a, b, c), AssocItemKind::Const(a, b, c) => ItemKind::Const(a, b, c),
AssocItemKind::Fn(a, b, c, d) => ItemKind::Fn(a, b, c, d), AssocItemKind::Fn(a, b, c, d) => ItemKind::Fn(a, b, c, d),
AssocItemKind::TyAlias(a, b, c, d) => ItemKind::TyAlias(a, b, c, d), AssocItemKind::TyAlias(a, b, c, d) => ItemKind::TyAlias(a, b, c, d),
AssocItemKind::Macro(a) => ItemKind::Mac(a), AssocItemKind::MacCall(a) => ItemKind::MacCall(a),
} }
} }
} }
@ -2679,7 +2679,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
ItemKind::Const(a, b, c) => AssocItemKind::Const(a, b, c), ItemKind::Const(a, b, c) => AssocItemKind::Const(a, b, c),
ItemKind::Fn(a, b, c, d) => AssocItemKind::Fn(a, b, c, d), ItemKind::Fn(a, b, c, d) => AssocItemKind::Fn(a, b, c, d),
ItemKind::TyAlias(a, b, c, d) => AssocItemKind::TyAlias(a, b, c, d), ItemKind::TyAlias(a, b, c, d) => AssocItemKind::TyAlias(a, b, c, d),
ItemKind::Mac(a) => AssocItemKind::Macro(a), ItemKind::MacCall(a) => AssocItemKind::MacCall(a),
_ => return Err(item_kind), _ => return Err(item_kind),
}) })
} }
@ -2695,7 +2695,7 @@ pub enum ForeignItemKind {
/// A foreign type. /// A foreign type.
TyAlias(Defaultness, Generics, GenericBounds, Option<P<Ty>>), TyAlias(Defaultness, Generics, GenericBounds, Option<P<Ty>>),
/// A macro expanding to foreign items. /// A macro expanding to foreign items.
Macro(Mac), MacCall(MacCall),
} }
impl From<ForeignItemKind> for ItemKind { impl From<ForeignItemKind> for ItemKind {
@ -2704,7 +2704,7 @@ impl From<ForeignItemKind> for ItemKind {
ForeignItemKind::Static(a, b, c) => ItemKind::Static(a, b, c), ForeignItemKind::Static(a, b, c) => ItemKind::Static(a, b, c),
ForeignItemKind::Fn(a, b, c, d) => ItemKind::Fn(a, b, c, d), ForeignItemKind::Fn(a, b, c, d) => ItemKind::Fn(a, b, c, d),
ForeignItemKind::TyAlias(a, b, c, d) => ItemKind::TyAlias(a, b, c, d), ForeignItemKind::TyAlias(a, b, c, d) => ItemKind::TyAlias(a, b, c, d),
ForeignItemKind::Macro(a) => ItemKind::Mac(a), ForeignItemKind::MacCall(a) => ItemKind::MacCall(a),
} }
} }
} }
@ -2717,7 +2717,7 @@ impl TryFrom<ItemKind> for ForeignItemKind {
ItemKind::Static(a, b, c) => ForeignItemKind::Static(a, b, c), ItemKind::Static(a, b, c) => ForeignItemKind::Static(a, b, c),
ItemKind::Fn(a, b, c, d) => ForeignItemKind::Fn(a, b, c, d), ItemKind::Fn(a, b, c, d) => ForeignItemKind::Fn(a, b, c, d),
ItemKind::TyAlias(a, b, c, d) => ForeignItemKind::TyAlias(a, b, c, d), ItemKind::TyAlias(a, b, c, d) => ForeignItemKind::TyAlias(a, b, c, d),
ItemKind::Mac(a) => ForeignItemKind::Macro(a), ItemKind::MacCall(a) => ForeignItemKind::MacCall(a),
_ => return Err(item_kind), _ => return Err(item_kind),
}) })
} }

View File

@ -679,7 +679,7 @@ impl HasAttrs for StmtKind {
StmtKind::Local(ref local) => local.attrs(), StmtKind::Local(ref local) => local.attrs(),
StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => expr.attrs(), StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => expr.attrs(),
StmtKind::Empty | StmtKind::Item(..) => &[], StmtKind::Empty | StmtKind::Item(..) => &[],
StmtKind::Mac(ref mac) => { StmtKind::MacCall(ref mac) => {
let (_, _, ref attrs) = **mac; let (_, _, ref attrs) = **mac;
attrs.attrs() attrs.attrs()
} }
@ -691,7 +691,7 @@ impl HasAttrs for StmtKind {
StmtKind::Local(local) => local.visit_attrs(f), StmtKind::Local(local) => local.visit_attrs(f),
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.visit_attrs(f), StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.visit_attrs(f),
StmtKind::Empty | StmtKind::Item(..) => {} StmtKind::Empty | StmtKind::Item(..) => {}
StmtKind::Mac(mac) => { StmtKind::MacCall(mac) => {
let (_mac, _style, attrs) = mac.deref_mut(); let (_mac, _style, attrs) = mac.deref_mut();
attrs.visit_attrs(f); attrs.visit_attrs(f);
} }

View File

@ -202,7 +202,7 @@ pub trait MutVisitor: Sized {
noop_visit_local(l, self); noop_visit_local(l, self);
} }
fn visit_mac(&mut self, _mac: &mut Mac) { fn visit_mac(&mut self, _mac: &mut MacCall) {
panic!("visit_mac disabled by default"); panic!("visit_mac disabled by default");
// N.B., see note about macros above. If you really want a visitor that // N.B., see note about macros above. If you really want a visitor that
// works on macros, use this definition in your trait impl: // works on macros, use this definition in your trait impl:
@ -482,7 +482,7 @@ pub fn noop_visit_ty<T: MutVisitor>(ty: &mut P<Ty>, vis: &mut T) {
vis.visit_id(id); vis.visit_id(id);
visit_vec(bounds, |bound| vis.visit_param_bound(bound)); visit_vec(bounds, |bound| vis.visit_param_bound(bound));
} }
TyKind::Mac(mac) => vis.visit_mac(mac), TyKind::MacCall(mac) => vis.visit_mac(mac),
} }
vis.visit_span(span); vis.visit_span(span);
} }
@ -584,8 +584,8 @@ pub fn noop_visit_attribute<T: MutVisitor>(attr: &mut Attribute, vis: &mut T) {
vis.visit_span(span); vis.visit_span(span);
} }
pub fn noop_visit_mac<T: MutVisitor>(mac: &mut Mac, vis: &mut T) { pub fn noop_visit_mac<T: MutVisitor>(mac: &mut MacCall, vis: &mut T) {
let Mac { path, args, prior_type_ascription: _ } = mac; let MacCall { path, args, prior_type_ascription: _ } = mac;
vis.visit_path(path); vis.visit_path(path);
visit_mac_args(args, vis); visit_mac_args(args, vis);
} }
@ -926,7 +926,7 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) {
vis.visit_generics(generics); vis.visit_generics(generics);
visit_bounds(bounds, vis); visit_bounds(bounds, vis);
} }
ItemKind::Mac(m) => vis.visit_mac(m), ItemKind::MacCall(m) => vis.visit_mac(m),
ItemKind::MacroDef(def) => vis.visit_macro_def(def), ItemKind::MacroDef(def) => vis.visit_macro_def(def),
} }
} }
@ -955,7 +955,7 @@ pub fn noop_flat_map_assoc_item<T: MutVisitor>(
visit_bounds(bounds, visitor); visit_bounds(bounds, visitor);
visit_opt(ty, |ty| visitor.visit_ty(ty)); visit_opt(ty, |ty| visitor.visit_ty(ty));
} }
AssocItemKind::Macro(mac) => visitor.visit_mac(mac), AssocItemKind::MacCall(mac) => visitor.visit_mac(mac),
} }
visitor.visit_span(span); visitor.visit_span(span);
smallvec![item] smallvec![item]
@ -1043,7 +1043,7 @@ pub fn noop_flat_map_foreign_item<T: MutVisitor>(
visit_bounds(bounds, visitor); visit_bounds(bounds, visitor);
visit_opt(ty, |ty| visitor.visit_ty(ty)); visit_opt(ty, |ty| visitor.visit_ty(ty));
} }
ForeignItemKind::Macro(mac) => visitor.visit_mac(mac), ForeignItemKind::MacCall(mac) => visitor.visit_mac(mac),
} }
visitor.visit_span(span); visitor.visit_span(span);
smallvec![item] smallvec![item]
@ -1082,7 +1082,7 @@ pub fn noop_visit_pat<T: MutVisitor>(pat: &mut P<Pat>, vis: &mut T) {
visit_vec(elems, |elem| vis.visit_pat(elem)) visit_vec(elems, |elem| vis.visit_pat(elem))
} }
PatKind::Paren(inner) => vis.visit_pat(inner), PatKind::Paren(inner) => vis.visit_pat(inner),
PatKind::Mac(mac) => vis.visit_mac(mac), PatKind::MacCall(mac) => vis.visit_mac(mac),
} }
vis.visit_span(span); vis.visit_span(span);
} }
@ -1219,7 +1219,7 @@ pub fn noop_visit_expr<T: MutVisitor>(Expr { kind, id, span, attrs }: &mut Expr,
} }
visit_vec(inputs, |(_c, expr)| vis.visit_expr(expr)); visit_vec(inputs, |(_c, expr)| vis.visit_expr(expr));
} }
ExprKind::Mac(mac) => vis.visit_mac(mac), ExprKind::MacCall(mac) => vis.visit_mac(mac),
ExprKind::Struct(path, fields, expr) => { ExprKind::Struct(path, fields, expr) => {
vis.visit_path(path); vis.visit_path(path);
fields.flat_map_in_place(|field| vis.flat_map_field(field)); fields.flat_map_in_place(|field| vis.flat_map_field(field));
@ -1275,11 +1275,11 @@ pub fn noop_flat_map_stmt_kind<T: MutVisitor>(
StmtKind::Expr(expr) => vis.filter_map_expr(expr).into_iter().map(StmtKind::Expr).collect(), StmtKind::Expr(expr) => vis.filter_map_expr(expr).into_iter().map(StmtKind::Expr).collect(),
StmtKind::Semi(expr) => vis.filter_map_expr(expr).into_iter().map(StmtKind::Semi).collect(), StmtKind::Semi(expr) => vis.filter_map_expr(expr).into_iter().map(StmtKind::Semi).collect(),
StmtKind::Empty => smallvec![StmtKind::Empty], StmtKind::Empty => smallvec![StmtKind::Empty],
StmtKind::Mac(mut mac) => { StmtKind::MacCall(mut mac) => {
let (mac_, _semi, attrs) = mac.deref_mut(); let (mac_, _semi, attrs) = mac.deref_mut();
vis.visit_mac(mac_); vis.visit_mac(mac_);
visit_thin_attrs(attrs, vis); visit_thin_attrs(attrs, vis);
smallvec![StmtKind::Mac(mac)] smallvec![StmtKind::MacCall(mac)]
} }
} }
} }

View File

@ -168,7 +168,7 @@ pub trait Visitor<'ast>: Sized {
fn visit_lifetime(&mut self, lifetime: &'ast Lifetime) { fn visit_lifetime(&mut self, lifetime: &'ast Lifetime) {
walk_lifetime(self, lifetime) walk_lifetime(self, lifetime)
} }
fn visit_mac(&mut self, _mac: &'ast Mac) { fn visit_mac(&mut self, _mac: &'ast MacCall) {
panic!("visit_mac disabled by default"); panic!("visit_mac disabled by default");
// N.B., see note about macros above. // N.B., see note about macros above.
// if you really want a visitor that // if you really want a visitor that
@ -350,7 +350,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
visitor.visit_generics(generics); visitor.visit_generics(generics);
walk_list!(visitor, visit_param_bound, bounds); walk_list!(visitor, visit_param_bound, bounds);
} }
ItemKind::Mac(ref mac) => visitor.visit_mac(mac), ItemKind::MacCall(ref mac) => visitor.visit_mac(mac),
ItemKind::MacroDef(ref ts) => visitor.visit_mac_def(ts, item.id), ItemKind::MacroDef(ref ts) => visitor.visit_mac_def(ts, item.id),
} }
walk_list!(visitor, visit_attribute, &item.attrs); walk_list!(visitor, visit_attribute, &item.attrs);
@ -418,7 +418,7 @@ pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) {
} }
TyKind::Typeof(ref expression) => visitor.visit_anon_const(expression), TyKind::Typeof(ref expression) => visitor.visit_anon_const(expression),
TyKind::Infer | TyKind::ImplicitSelf | TyKind::Err => {} TyKind::Infer | TyKind::ImplicitSelf | TyKind::Err => {}
TyKind::Mac(ref mac) => visitor.visit_mac(mac), TyKind::MacCall(ref mac) => visitor.visit_mac(mac),
TyKind::Never | TyKind::CVarArgs => {} TyKind::Never | TyKind::CVarArgs => {}
} }
} }
@ -521,7 +521,7 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) {
PatKind::Tuple(ref elems) | PatKind::Slice(ref elems) | PatKind::Or(ref elems) => { PatKind::Tuple(ref elems) | PatKind::Slice(ref elems) | PatKind::Or(ref elems) => {
walk_list!(visitor, visit_pat, elems); walk_list!(visitor, visit_pat, elems);
} }
PatKind::Mac(ref mac) => visitor.visit_mac(mac), PatKind::MacCall(ref mac) => visitor.visit_mac(mac),
} }
} }
@ -545,7 +545,7 @@ pub fn walk_foreign_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a ForeignI
walk_list!(visitor, visit_param_bound, bounds); walk_list!(visitor, visit_param_bound, bounds);
walk_list!(visitor, visit_ty, ty); walk_list!(visitor, visit_ty, ty);
} }
ForeignItemKind::Macro(mac) => { ForeignItemKind::MacCall(mac) => {
visitor.visit_mac(mac); visitor.visit_mac(mac);
} }
} }
@ -650,7 +650,7 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a AssocItem,
walk_list!(visitor, visit_param_bound, bounds); walk_list!(visitor, visit_param_bound, bounds);
walk_list!(visitor, visit_ty, ty); walk_list!(visitor, visit_ty, ty);
} }
AssocItemKind::Macro(mac) => { AssocItemKind::MacCall(mac) => {
visitor.visit_mac(mac); visitor.visit_mac(mac);
} }
} }
@ -679,7 +679,7 @@ pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) {
StmtKind::Item(ref item) => visitor.visit_item(item), StmtKind::Item(ref item) => visitor.visit_item(item),
StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => visitor.visit_expr(expr), StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => visitor.visit_expr(expr),
StmtKind::Empty => {} StmtKind::Empty => {}
StmtKind::Mac(ref mac) => { StmtKind::MacCall(ref mac) => {
let (ref mac, _, ref attrs) = **mac; let (ref mac, _, ref attrs) = **mac;
visitor.visit_mac(mac); visitor.visit_mac(mac);
for attr in attrs.iter() { for attr in attrs.iter() {
@ -689,7 +689,7 @@ pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) {
} }
} }
pub fn walk_mac<'a, V: Visitor<'a>>(visitor: &mut V, mac: &'a Mac) { pub fn walk_mac<'a, V: Visitor<'a>>(visitor: &mut V, mac: &'a MacCall) {
visitor.visit_path(&mac.path, DUMMY_NODE_ID); visitor.visit_path(&mac.path, DUMMY_NODE_ID);
} }
@ -811,7 +811,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
ExprKind::Ret(ref optional_expression) => { ExprKind::Ret(ref optional_expression) => {
walk_list!(visitor, visit_expr, optional_expression); walk_list!(visitor, visit_expr, optional_expression);
} }
ExprKind::Mac(ref mac) => visitor.visit_mac(mac), ExprKind::MacCall(ref mac) => visitor.visit_mac(mac),
ExprKind::Paren(ref subexpression) => visitor.visit_expr(subexpression), ExprKind::Paren(ref subexpression) => visitor.visit_expr(subexpression),
ExprKind::InlineAsm(ref ia) => { ExprKind::InlineAsm(ref ia) => {
for &(_, ref input) in &ia.inputs { for &(_, ref input) in &ia.inputs {

View File

@ -198,7 +198,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
return self.lower_expr_for(e, pat, head, body, opt_label); return self.lower_expr_for(e, pat, head, body, opt_label);
} }
ExprKind::Try(ref sub_expr) => self.lower_expr_try(e.span, sub_expr), ExprKind::Try(ref sub_expr) => self.lower_expr_try(e.span, sub_expr),
ExprKind::Mac(_) => panic!("Shouldn't exist here"), ExprKind::MacCall(_) => panic!("Shouldn't exist here"),
}; };
hir::Expr { hir::Expr {

View File

@ -426,7 +426,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
self.lower_generics(generics, ImplTraitContext::disallowed()), self.lower_generics(generics, ImplTraitContext::disallowed()),
self.lower_param_bounds(bounds, ImplTraitContext::disallowed()), self.lower_param_bounds(bounds, ImplTraitContext::disallowed()),
), ),
ItemKind::MacroDef(..) | ItemKind::Mac(..) => { ItemKind::MacroDef(..) | ItemKind::MacCall(..) => {
bug!("`TyMac` should have been expanded by now") bug!("`TyMac` should have been expanded by now")
} }
} }
@ -676,7 +676,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
hir::ForeignItemKind::Static(ty, m) hir::ForeignItemKind::Static(ty, m)
} }
ForeignItemKind::TyAlias(..) => hir::ForeignItemKind::Type, ForeignItemKind::TyAlias(..) => hir::ForeignItemKind::Type,
ForeignItemKind::Macro(_) => panic!("macro shouldn't exist here"), ForeignItemKind::MacCall(_) => panic!("macro shouldn't exist here"),
}, },
vis: self.lower_visibility(&i.vis, None), vis: self.lower_visibility(&i.vis, None),
span: i.span, span: i.span,
@ -779,7 +779,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
(generics, kind) (generics, kind)
} }
AssocItemKind::Macro(..) => bug!("macro item shouldn't exist at this point"), AssocItemKind::MacCall(..) => bug!("macro item shouldn't exist at this point"),
}; };
hir::TraitItem { hir::TraitItem {
@ -801,7 +801,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
AssocItemKind::Fn(_, sig, _, default) => { AssocItemKind::Fn(_, sig, _, default) => {
(hir::AssocItemKind::Method { has_self: sig.decl.has_self() }, default.is_some()) (hir::AssocItemKind::Method { has_self: sig.decl.has_self() }, default.is_some())
} }
AssocItemKind::Macro(..) => unimplemented!(), AssocItemKind::MacCall(..) => unimplemented!(),
}; };
let id = hir::TraitItemId { hir_id: self.lower_node_id(i.id) }; let id = hir::TraitItemId { hir_id: self.lower_node_id(i.id) };
let defaultness = hir::Defaultness::Default { has_value: has_default }; let defaultness = hir::Defaultness::Default { has_value: has_default };
@ -860,7 +860,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}; };
(generics, kind) (generics, kind)
} }
AssocItemKind::Macro(..) => bug!("`TyMac` should have been expanded by now"), AssocItemKind::MacCall(..) => bug!("`TyMac` should have been expanded by now"),
}; };
hir::ImplItem { hir::ImplItem {
@ -895,7 +895,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
AssocItemKind::Fn(_, sig, ..) => { AssocItemKind::Fn(_, sig, ..) => {
hir::AssocItemKind::Method { has_self: sig.decl.has_self() } hir::AssocItemKind::Method { has_self: sig.decl.has_self() }
} }
AssocItemKind::Macro(..) => unimplemented!(), AssocItemKind::MacCall(..) => unimplemented!(),
}, },
} }

View File

@ -1334,7 +1334,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
} }
} }
} }
TyKind::Mac(_) => bug!("`TyKind::Mac` should have been expanded by now"), TyKind::MacCall(_) => bug!("`TyKind::MacCall` should have been expanded by now"),
TyKind::CVarArgs => { TyKind::CVarArgs => {
self.sess.delay_span_bug( self.sess.delay_span_bug(
t.span, t.span,
@ -2282,7 +2282,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
StmtKind::Expr(ref e) => hir::StmtKind::Expr(self.lower_expr(e)), StmtKind::Expr(ref e) => hir::StmtKind::Expr(self.lower_expr(e)),
StmtKind::Semi(ref e) => hir::StmtKind::Semi(self.lower_expr(e)), StmtKind::Semi(ref e) => hir::StmtKind::Semi(self.lower_expr(e)),
StmtKind::Empty => return smallvec![], StmtKind::Empty => return smallvec![],
StmtKind::Mac(..) => panic!("shouldn't exist here"), StmtKind::MacCall(..) => panic!("shouldn't exist here"),
}; };
smallvec![hir::Stmt { hir_id: self.lower_node_id(s.id), kind, span: s.span }] smallvec![hir::Stmt { hir_id: self.lower_node_id(s.id), kind, span: s.span }]
} }

View File

@ -75,7 +75,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
self.ban_illegal_rest_pat(p.span) self.ban_illegal_rest_pat(p.span)
} }
PatKind::Paren(ref inner) => return self.lower_pat(inner), PatKind::Paren(ref inner) => return self.lower_pat(inner),
PatKind::Mac(_) => panic!("Shouldn't exist here"), PatKind::MacCall(_) => panic!("Shouldn't exist here"),
}; };
self.pat_with_node_id_of(p, node) self.pat_with_node_id_of(p, node)

View File

@ -976,7 +976,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
ForeignItemKind::Static(_, _, body) => { ForeignItemKind::Static(_, _, body) => {
self.check_foreign_kind_bodyless(fi.ident, "static", body.as_ref().map(|b| b.span)); self.check_foreign_kind_bodyless(fi.ident, "static", body.as_ref().map(|b| b.span));
} }
ForeignItemKind::Macro(..) => {} ForeignItemKind::MacCall(..) => {}
} }
visit::walk_foreign_item(self, fi) visit::walk_foreign_item(self, fi)

View File

@ -399,7 +399,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
ast::ForeignItemKind::TyAlias(..) => { ast::ForeignItemKind::TyAlias(..) => {
gate_feature_post!(&self, extern_types, i.span, "extern types are experimental"); gate_feature_post!(&self, extern_types, i.span, "extern types are experimental");
} }
ast::ForeignItemKind::Macro(..) => {} ast::ForeignItemKind::MacCall(..) => {}
} }
visit::walk_foreign_item(self, i) visit::walk_foreign_item(self, i)

View File

@ -113,7 +113,7 @@ impl<'ast> Visitor<'ast> for NodeCounter {
self.count += 1; self.count += 1;
walk_lifetime(self, lifetime) walk_lifetime(self, lifetime)
} }
fn visit_mac(&mut self, _mac: &Mac) { fn visit_mac(&mut self, _mac: &MacCall) {
self.count += 1; self.count += 1;
walk_mac(self, _mac) walk_mac(self, _mac)
} }

View File

@ -55,7 +55,7 @@ impl<'a> Visitor<'a> for ShowSpanVisitor<'a> {
visit::walk_ty(self, t); visit::walk_ty(self, t);
} }
fn visit_mac(&mut self, mac: &'a ast::Mac) { fn visit_mac(&mut self, mac: &'a ast::MacCall) {
visit::walk_mac(self, mac); visit::walk_mac(self, mac);
} }
} }

View File

@ -960,7 +960,7 @@ impl<'a> State<'a> {
ast::TyKind::ImplicitSelf => { ast::TyKind::ImplicitSelf => {
self.s.word("Self"); self.s.word("Self");
} }
ast::TyKind::Mac(ref m) => { ast::TyKind::MacCall(ref m) => {
self.print_mac(m); self.print_mac(m);
} }
ast::TyKind::CVarArgs => { ast::TyKind::CVarArgs => {
@ -987,7 +987,7 @@ impl<'a> State<'a> {
ast::ForeignItemKind::TyAlias(def, generics, bounds, ty) => { ast::ForeignItemKind::TyAlias(def, generics, bounds, ty) => {
self.print_associated_type(ident, generics, bounds, ty.as_deref(), vis, *def); self.print_associated_type(ident, generics, bounds, ty.as_deref(), vis, *def);
} }
ast::ForeignItemKind::Macro(m) => { ast::ForeignItemKind::MacCall(m) => {
self.print_mac(m); self.print_mac(m);
if m.args.need_semicolon() { if m.args.need_semicolon() {
self.s.word(";"); self.s.word(";");
@ -1231,7 +1231,7 @@ impl<'a> State<'a> {
self.print_where_clause(&generics.where_clause); self.print_where_clause(&generics.where_clause);
self.s.word(";"); self.s.word(";");
} }
ast::ItemKind::Mac(ref mac) => { ast::ItemKind::MacCall(ref mac) => {
self.print_mac(mac); self.print_mac(mac);
if mac.args.need_semicolon() { if mac.args.need_semicolon() {
self.s.word(";"); self.s.word(";");
@ -1413,7 +1413,7 @@ impl<'a> State<'a> {
ast::AssocItemKind::TyAlias(def, generics, bounds, ty) => { ast::AssocItemKind::TyAlias(def, generics, bounds, ty) => {
self.print_associated_type(ident, generics, bounds, ty.as_deref(), vis, *def); self.print_associated_type(ident, generics, bounds, ty.as_deref(), vis, *def);
} }
ast::AssocItemKind::Macro(m) => { ast::AssocItemKind::MacCall(m) => {
self.print_mac(m); self.print_mac(m);
if m.args.need_semicolon() { if m.args.need_semicolon() {
self.s.word(";"); self.s.word(";");
@ -1460,7 +1460,7 @@ impl<'a> State<'a> {
self.space_if_not_bol(); self.space_if_not_bol();
self.s.word(";"); self.s.word(";");
} }
ast::StmtKind::Mac(ref mac) => { ast::StmtKind::MacCall(ref mac) => {
let (ref mac, style, ref attrs) = **mac; let (ref mac, style, ref attrs) = **mac;
self.space_if_not_bol(); self.space_if_not_bol();
self.print_outer_attributes(attrs); self.print_outer_attributes(attrs);
@ -1570,7 +1570,7 @@ impl<'a> State<'a> {
self.print_else(elseopt) self.print_else(elseopt)
} }
crate fn print_mac(&mut self, m: &ast::Mac) { crate fn print_mac(&mut self, m: &ast::MacCall) {
self.print_mac_common( self.print_mac_common(
Some(MacHeader::Path(&m.path)), Some(MacHeader::Path(&m.path)),
true, true,
@ -2070,7 +2070,7 @@ impl<'a> State<'a> {
self.pclose(); self.pclose();
} }
ast::ExprKind::Mac(ref m) => self.print_mac(m), ast::ExprKind::MacCall(ref m) => self.print_mac(m),
ast::ExprKind::Paren(ref e) => { ast::ExprKind::Paren(ref e) => {
self.popen(); self.popen();
self.print_inner_attributes_inline(attrs); self.print_inner_attributes_inline(attrs);
@ -2254,7 +2254,7 @@ impl<'a> State<'a> {
self.print_pat(inner); self.print_pat(inner);
self.pclose(); self.pclose();
} }
PatKind::Mac(ref m) => self.print_mac(m), PatKind::MacCall(ref m) => self.print_mac(m),
} }
self.ann.post(self, AnnNode::Pat(pat)) self.ann.post(self, AnnNode::Pat(pat))
} }

View File

@ -40,7 +40,7 @@ pub fn expand_assert<'cx>(
)) ))
}); });
let args = P(MacArgs::Delimited(DelimSpan::from_single(sp), MacDelimiter::Parenthesis, tokens)); let args = P(MacArgs::Delimited(DelimSpan::from_single(sp), MacDelimiter::Parenthesis, tokens));
let panic_call = Mac { let panic_call = MacCall {
path: Path::from_ident(Ident::new(sym::panic, sp)), path: Path::from_ident(Ident::new(sym::panic, sp)),
args, args,
prior_type_ascription: None, prior_type_ascription: None,
@ -48,7 +48,7 @@ pub fn expand_assert<'cx>(
let if_expr = cx.expr_if( let if_expr = cx.expr_if(
sp, sp,
cx.expr(sp, ExprKind::Unary(UnOp::Not, cond_expr)), cx.expr(sp, ExprKind::Unary(UnOp::Not, cond_expr)),
cx.expr(sp, ExprKind::Mac(panic_call)), cx.expr(sp, ExprKind::MacCall(panic_call)),
None, None,
); );
MacEager::expr(if_expr) MacEager::expr(if_expr)

View File

@ -360,7 +360,7 @@ fn find_type_parameters(
visit::walk_ty(self, ty) visit::walk_ty(self, ty)
} }
fn visit_mac(&mut self, mac: &ast::Mac) { fn visit_mac(&mut self, mac: &ast::MacCall) {
self.cx.span_err(mac.span(), "`derive` cannot be used on items with type macros"); self.cx.span_err(mac.span(), "`derive` cannot be used on items with type macros");
} }
} }

View File

@ -341,7 +341,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
self.in_root = prev_in_root; self.in_root = prev_in_root;
} }
fn visit_mac(&mut self, mac: &'a ast::Mac) { fn visit_mac(&mut self, mac: &'a ast::MacCall) {
visit::walk_mac(self, mac) visit::walk_mac(self, mac)
} }
} }

View File

@ -86,7 +86,7 @@ pub fn expand_test_or_bench(
.raise(); .raise();
}; };
if let ast::ItemKind::Mac(_) = item.kind { if let ast::ItemKind::MacCall(_) = item.kind {
cx.parse_sess.span_diagnostic.span_warn( cx.parse_sess.span_diagnostic.span_warn(
item.span, item.span,
"`#[test]` attribute should not be used on macros. Use `#[cfg(test)]` instead.", "`#[test]` attribute should not be used on macros. Use `#[cfg(test)]` instead.",

View File

@ -138,7 +138,7 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> {
smallvec![P(item)] smallvec![P(item)]
} }
fn visit_mac(&mut self, _mac: &mut ast::Mac) { fn visit_mac(&mut self, _mac: &mut ast::MacCall) {
// Do nothing. // Do nothing.
} }
} }
@ -184,7 +184,7 @@ impl MutVisitor for EntryPointCleaner {
smallvec![item] smallvec![item]
} }
fn visit_mac(&mut self, _mac: &mut ast::Mac) { fn visit_mac(&mut self, _mac: &mut ast::MacCall) {
// Do nothing. // Do nothing.
} }
} }

View File

@ -372,7 +372,7 @@ where
mut_visit::noop_visit_tt(tt, self) mut_visit::noop_visit_tt(tt, self)
} }
fn visit_mac(&mut self, mac: &mut ast::Mac) { fn visit_mac(&mut self, mac: &mut ast::MacCall) {
mut_visit::noop_visit_mac(mac, self) mut_visit::noop_visit_mac(mac, self)
} }
} }

View File

@ -271,7 +271,7 @@ pub struct Invocation {
pub enum InvocationKind { pub enum InvocationKind {
Bang { Bang {
mac: ast::Mac, mac: ast::MacCall,
span: Span, span: Span,
}, },
Attr { Attr {
@ -625,7 +625,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
/// A macro's expansion does not fit in this fragment kind. /// A macro's expansion does not fit in this fragment kind.
/// For example, a non-type macro in a type position. /// For example, a non-type macro in a type position.
fn error_wrong_fragment_kind(&mut self, kind: AstFragmentKind, mac: &ast::Mac, span: Span) { fn error_wrong_fragment_kind(&mut self, kind: AstFragmentKind, mac: &ast::MacCall, span: Span) {
let msg = format!( let msg = format!(
"non-{kind} macro in {kind} position: {path}", "non-{kind} macro in {kind} position: {path}",
kind = kind.name(), kind = kind.name(),
@ -768,7 +768,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
visit::walk_item(self, item); visit::walk_item(self, item);
} }
fn visit_mac(&mut self, _: &'ast ast::Mac) {} fn visit_mac(&mut self, _: &'ast ast::MacCall) {}
} }
if !self.cx.ecfg.proc_macro_hygiene() { if !self.cx.ecfg.proc_macro_hygiene() {
@ -967,7 +967,12 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
placeholder(fragment_kind, NodeId::placeholder_from_expn_id(expn_id), vis) placeholder(fragment_kind, NodeId::placeholder_from_expn_id(expn_id), vis)
} }
fn collect_bang(&mut self, mac: ast::Mac, span: Span, kind: AstFragmentKind) -> AstFragment { fn collect_bang(
&mut self,
mac: ast::MacCall,
span: Span,
kind: AstFragmentKind,
) -> AstFragment {
self.collect(kind, InvocationKind::Bang { mac, span }) self.collect(kind, InvocationKind::Bang { mac, span })
} }
@ -1110,7 +1115,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
.into_inner(); .into_inner();
} }
if let ast::ExprKind::Mac(mac) = expr.kind { if let ast::ExprKind::MacCall(mac) = expr.kind {
self.check_attributes(&expr.attrs); self.check_attributes(&expr.attrs);
self.collect_bang(mac, expr.span, AstFragmentKind::Expr).make_expr().into_inner() self.collect_bang(mac, expr.span, AstFragmentKind::Expr).make_expr().into_inner()
} else { } else {
@ -1257,7 +1262,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
.map(|expr| expr.into_inner()); .map(|expr| expr.into_inner());
} }
if let ast::ExprKind::Mac(mac) = expr.kind { if let ast::ExprKind::MacCall(mac) = expr.kind {
self.check_attributes(&expr.attrs); self.check_attributes(&expr.attrs);
self.collect_bang(mac, expr.span, AstFragmentKind::OptExpr) self.collect_bang(mac, expr.span, AstFragmentKind::OptExpr)
.make_opt_expr() .make_opt_expr()
@ -1274,12 +1279,14 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
fn visit_pat(&mut self, pat: &mut P<ast::Pat>) { fn visit_pat(&mut self, pat: &mut P<ast::Pat>) {
self.cfg.configure_pat(pat); self.cfg.configure_pat(pat);
match pat.kind { match pat.kind {
PatKind::Mac(_) => {} PatKind::MacCall(_) => {}
_ => return noop_visit_pat(pat, self), _ => return noop_visit_pat(pat, self),
} }
visit_clobber(pat, |mut pat| match mem::replace(&mut pat.kind, PatKind::Wild) { visit_clobber(pat, |mut pat| match mem::replace(&mut pat.kind, PatKind::Wild) {
PatKind::Mac(mac) => self.collect_bang(mac, pat.span, AstFragmentKind::Pat).make_pat(), PatKind::MacCall(mac) => {
self.collect_bang(mac, pat.span, AstFragmentKind::Pat).make_pat()
}
_ => unreachable!(), _ => unreachable!(),
}); });
} }
@ -1311,7 +1318,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
} }
} }
if let StmtKind::Mac(mac) = stmt.kind { if let StmtKind::MacCall(mac) = stmt.kind {
let (mac, style, attrs) = mac.into_inner(); let (mac, style, attrs) = mac.into_inner();
self.check_attributes(&attrs); self.check_attributes(&attrs);
let mut placeholder = let mut placeholder =
@ -1360,10 +1367,10 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
} }
match item.kind { match item.kind {
ast::ItemKind::Mac(..) => { ast::ItemKind::MacCall(..) => {
self.check_attributes(&item.attrs); self.check_attributes(&item.attrs);
item.and_then(|item| match item.kind { item.and_then(|item| match item.kind {
ItemKind::Mac(mac) => self ItemKind::MacCall(mac) => self
.collect( .collect(
AstFragmentKind::Items, AstFragmentKind::Items,
InvocationKind::Bang { mac, span: item.span }, InvocationKind::Bang { mac, span: item.span },
@ -1432,10 +1439,10 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
} }
match item.kind { match item.kind {
ast::AssocItemKind::Macro(..) => { ast::AssocItemKind::MacCall(..) => {
self.check_attributes(&item.attrs); self.check_attributes(&item.attrs);
item.and_then(|item| match item.kind { item.and_then(|item| match item.kind {
ast::AssocItemKind::Macro(mac) => self ast::AssocItemKind::MacCall(mac) => self
.collect_bang(mac, item.span, AstFragmentKind::TraitItems) .collect_bang(mac, item.span, AstFragmentKind::TraitItems)
.make_trait_items(), .make_trait_items(),
_ => unreachable!(), _ => unreachable!(),
@ -1462,10 +1469,10 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
} }
match item.kind { match item.kind {
ast::AssocItemKind::Macro(..) => { ast::AssocItemKind::MacCall(..) => {
self.check_attributes(&item.attrs); self.check_attributes(&item.attrs);
item.and_then(|item| match item.kind { item.and_then(|item| match item.kind {
ast::AssocItemKind::Macro(mac) => self ast::AssocItemKind::MacCall(mac) => self
.collect_bang(mac, item.span, AstFragmentKind::ImplItems) .collect_bang(mac, item.span, AstFragmentKind::ImplItems)
.make_impl_items(), .make_impl_items(),
_ => unreachable!(), _ => unreachable!(),
@ -1477,12 +1484,14 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
fn visit_ty(&mut self, ty: &mut P<ast::Ty>) { fn visit_ty(&mut self, ty: &mut P<ast::Ty>) {
match ty.kind { match ty.kind {
ast::TyKind::Mac(_) => {} ast::TyKind::MacCall(_) => {}
_ => return noop_visit_ty(ty, self), _ => return noop_visit_ty(ty, self),
}; };
visit_clobber(ty, |mut ty| match mem::replace(&mut ty.kind, ast::TyKind::Err) { visit_clobber(ty, |mut ty| match mem::replace(&mut ty.kind, ast::TyKind::Err) {
ast::TyKind::Mac(mac) => self.collect_bang(mac, ty.span, AstFragmentKind::Ty).make_ty(), ast::TyKind::MacCall(mac) => {
self.collect_bang(mac, ty.span, AstFragmentKind::Ty).make_ty()
}
_ => unreachable!(), _ => unreachable!(),
}); });
} }
@ -1511,10 +1520,10 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
} }
match foreign_item.kind { match foreign_item.kind {
ast::ForeignItemKind::Macro(..) => { ast::ForeignItemKind::MacCall(..) => {
self.check_attributes(&foreign_item.attrs); self.check_attributes(&foreign_item.attrs);
foreign_item.and_then(|item| match item.kind { foreign_item.and_then(|item| match item.kind {
ast::ForeignItemKind::Macro(mac) => self ast::ForeignItemKind::MacCall(mac) => self
.collect_bang(mac, item.span, AstFragmentKind::ForeignItems) .collect_bang(mac, item.span, AstFragmentKind::ForeignItems)
.make_foreign_items(), .make_foreign_items(),
_ => unreachable!(), _ => unreachable!(),

View File

@ -2,7 +2,7 @@ use crate::base::ExtCtxt;
use crate::mbe; use crate::mbe;
use crate::mbe::macro_parser::{MatchedNonterminal, MatchedSeq, NamedMatch}; use crate::mbe::macro_parser::{MatchedNonterminal, MatchedSeq, NamedMatch};
use rustc_ast::ast::{Ident, Mac}; use rustc_ast::ast::{Ident, MacCall};
use rustc_ast::mut_visit::{self, MutVisitor}; use rustc_ast::mut_visit::{self, MutVisitor};
use rustc_ast::token::{self, NtTT, Token}; use rustc_ast::token::{self, NtTT, Token};
use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree, TreeAndJoint}; use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree, TreeAndJoint};
@ -23,7 +23,7 @@ impl MutVisitor for Marker {
*span = span.apply_mark(self.0, self.1) *span = span.apply_mark(self.0, self.1)
} }
fn visit_mac(&mut self, mac: &mut Mac) { fn visit_mac(&mut self, mac: &mut MacCall) {
mut_visit::noop_visit_mac(mac, self) mut_visit::noop_visit_mac(mac, self)
} }
} }

View File

@ -17,7 +17,7 @@ impl MutVisitor for ToZzIdentMutVisitor {
fn visit_ident(&mut self, ident: &mut ast::Ident) { fn visit_ident(&mut self, ident: &mut ast::Ident) {
*ident = Ident::from_str("zz"); *ident = Ident::from_str("zz");
} }
fn visit_mac(&mut self, mac: &mut ast::Mac) { fn visit_mac(&mut self, mac: &mut ast::MacCall) {
mut_visit::noop_visit_mac(mac, self) mut_visit::noop_visit_mac(mac, self)
} }
} }

View File

@ -281,7 +281,7 @@ fn ttdelim_span() {
.unwrap(); .unwrap();
let tts: Vec<_> = match expr.kind { let tts: Vec<_> = match expr.kind {
ast::ExprKind::Mac(ref mac) => mac.args.inner_tokens().trees().collect(), ast::ExprKind::MacCall(ref mac) => mac.args.inner_tokens().trees().collect(),
_ => panic!("not a macro"), _ => panic!("not a macro"),
}; };

View File

@ -15,8 +15,8 @@ pub fn placeholder(
id: ast::NodeId, id: ast::NodeId,
vis: Option<ast::Visibility>, vis: Option<ast::Visibility>,
) -> AstFragment { ) -> AstFragment {
fn mac_placeholder() -> ast::Mac { fn mac_placeholder() -> ast::MacCall {
ast::Mac { ast::MacCall {
path: ast::Path { span: DUMMY_SP, segments: Vec::new() }, path: ast::Path { span: DUMMY_SP, segments: Vec::new() },
args: P(ast::MacArgs::Empty), args: P(ast::MacArgs::Empty),
prior_type_ascription: None, prior_type_ascription: None,
@ -32,11 +32,11 @@ pub fn placeholder(
id, id,
span, span,
attrs: ast::AttrVec::new(), attrs: ast::AttrVec::new(),
kind: ast::ExprKind::Mac(mac_placeholder()), kind: ast::ExprKind::MacCall(mac_placeholder()),
}) })
}; };
let ty = || P(ast::Ty { id, kind: ast::TyKind::Mac(mac_placeholder()), span }); let ty = || P(ast::Ty { id, kind: ast::TyKind::MacCall(mac_placeholder()), span });
let pat = || P(ast::Pat { id, kind: ast::PatKind::Mac(mac_placeholder()), span }); let pat = || P(ast::Pat { id, kind: ast::PatKind::MacCall(mac_placeholder()), span });
match kind { match kind {
AstFragmentKind::Expr => AstFragment::Expr(expr_placeholder()), AstFragmentKind::Expr => AstFragment::Expr(expr_placeholder()),
@ -47,7 +47,7 @@ pub fn placeholder(
ident, ident,
vis, vis,
attrs, attrs,
kind: ast::ItemKind::Mac(mac_placeholder()), kind: ast::ItemKind::MacCall(mac_placeholder()),
tokens: None, tokens: None,
})]), })]),
AstFragmentKind::TraitItems => AstFragment::TraitItems(smallvec![P(ast::AssocItem { AstFragmentKind::TraitItems => AstFragment::TraitItems(smallvec![P(ast::AssocItem {
@ -56,7 +56,7 @@ pub fn placeholder(
ident, ident,
vis, vis,
attrs, attrs,
kind: ast::AssocItemKind::Macro(mac_placeholder()), kind: ast::AssocItemKind::MacCall(mac_placeholder()),
tokens: None, tokens: None,
})]), })]),
AstFragmentKind::ImplItems => AstFragment::ImplItems(smallvec![P(ast::AssocItem { AstFragmentKind::ImplItems => AstFragment::ImplItems(smallvec![P(ast::AssocItem {
@ -65,7 +65,7 @@ pub fn placeholder(
ident, ident,
vis, vis,
attrs, attrs,
kind: ast::AssocItemKind::Macro(mac_placeholder()), kind: ast::AssocItemKind::MacCall(mac_placeholder()),
tokens: None, tokens: None,
})]), })]),
AstFragmentKind::ForeignItems => { AstFragmentKind::ForeignItems => {
@ -75,19 +75,21 @@ pub fn placeholder(
ident, ident,
vis, vis,
attrs, attrs,
kind: ast::ForeignItemKind::Macro(mac_placeholder()), kind: ast::ForeignItemKind::MacCall(mac_placeholder()),
tokens: None, tokens: None,
})]) })])
} }
AstFragmentKind::Pat => { AstFragmentKind::Pat => AstFragment::Pat(P(ast::Pat {
AstFragment::Pat(P(ast::Pat { id, span, kind: ast::PatKind::Mac(mac_placeholder()) })) id,
} span,
kind: ast::PatKind::MacCall(mac_placeholder()),
})),
AstFragmentKind::Ty => { AstFragmentKind::Ty => {
AstFragment::Ty(P(ast::Ty { id, span, kind: ast::TyKind::Mac(mac_placeholder()) })) AstFragment::Ty(P(ast::Ty { id, span, kind: ast::TyKind::MacCall(mac_placeholder()) }))
} }
AstFragmentKind::Stmts => AstFragment::Stmts(smallvec![{ AstFragmentKind::Stmts => AstFragment::Stmts(smallvec![{
let mac = P((mac_placeholder(), ast::MacStmtStyle::Braces, ast::AttrVec::new())); let mac = P((mac_placeholder(), ast::MacStmtStyle::Braces, ast::AttrVec::new()));
ast::Stmt { id, span, kind: ast::StmtKind::Mac(mac) } ast::Stmt { id, span, kind: ast::StmtKind::MacCall(mac) }
}]), }]),
AstFragmentKind::Arms => AstFragment::Arms(smallvec![ast::Arm { AstFragmentKind::Arms => AstFragment::Arms(smallvec![ast::Arm {
attrs: Default::default(), attrs: Default::default(),
@ -239,7 +241,7 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
fn flat_map_item(&mut self, item: P<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> { fn flat_map_item(&mut self, item: P<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> {
match item.kind { match item.kind {
ast::ItemKind::Mac(_) => return self.remove(item.id).make_items(), ast::ItemKind::MacCall(_) => return self.remove(item.id).make_items(),
ast::ItemKind::MacroDef(_) => return smallvec![item], ast::ItemKind::MacroDef(_) => return smallvec![item],
_ => {} _ => {}
} }
@ -249,14 +251,14 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
fn flat_map_trait_item(&mut self, item: P<ast::AssocItem>) -> SmallVec<[P<ast::AssocItem>; 1]> { fn flat_map_trait_item(&mut self, item: P<ast::AssocItem>) -> SmallVec<[P<ast::AssocItem>; 1]> {
match item.kind { match item.kind {
ast::AssocItemKind::Macro(_) => self.remove(item.id).make_trait_items(), ast::AssocItemKind::MacCall(_) => self.remove(item.id).make_trait_items(),
_ => noop_flat_map_assoc_item(item, self), _ => noop_flat_map_assoc_item(item, self),
} }
} }
fn flat_map_impl_item(&mut self, item: P<ast::AssocItem>) -> SmallVec<[P<ast::AssocItem>; 1]> { fn flat_map_impl_item(&mut self, item: P<ast::AssocItem>) -> SmallVec<[P<ast::AssocItem>; 1]> {
match item.kind { match item.kind {
ast::AssocItemKind::Macro(_) => self.remove(item.id).make_impl_items(), ast::AssocItemKind::MacCall(_) => self.remove(item.id).make_impl_items(),
_ => noop_flat_map_assoc_item(item, self), _ => noop_flat_map_assoc_item(item, self),
} }
} }
@ -266,28 +268,28 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
item: P<ast::ForeignItem>, item: P<ast::ForeignItem>,
) -> SmallVec<[P<ast::ForeignItem>; 1]> { ) -> SmallVec<[P<ast::ForeignItem>; 1]> {
match item.kind { match item.kind {
ast::ForeignItemKind::Macro(_) => self.remove(item.id).make_foreign_items(), ast::ForeignItemKind::MacCall(_) => self.remove(item.id).make_foreign_items(),
_ => noop_flat_map_foreign_item(item, self), _ => noop_flat_map_foreign_item(item, self),
} }
} }
fn visit_expr(&mut self, expr: &mut P<ast::Expr>) { fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
match expr.kind { match expr.kind {
ast::ExprKind::Mac(_) => *expr = self.remove(expr.id).make_expr(), ast::ExprKind::MacCall(_) => *expr = self.remove(expr.id).make_expr(),
_ => noop_visit_expr(expr, self), _ => noop_visit_expr(expr, self),
} }
} }
fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> { fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
match expr.kind { match expr.kind {
ast::ExprKind::Mac(_) => self.remove(expr.id).make_opt_expr(), ast::ExprKind::MacCall(_) => self.remove(expr.id).make_opt_expr(),
_ => noop_filter_map_expr(expr, self), _ => noop_filter_map_expr(expr, self),
} }
} }
fn flat_map_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> { fn flat_map_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> {
let (style, mut stmts) = match stmt.kind { let (style, mut stmts) = match stmt.kind {
ast::StmtKind::Mac(mac) => (mac.1, self.remove(stmt.id).make_stmts()), ast::StmtKind::MacCall(mac) => (mac.1, self.remove(stmt.id).make_stmts()),
_ => return noop_flat_map_stmt(stmt, self), _ => return noop_flat_map_stmt(stmt, self),
}; };
@ -302,14 +304,14 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
fn visit_pat(&mut self, pat: &mut P<ast::Pat>) { fn visit_pat(&mut self, pat: &mut P<ast::Pat>) {
match pat.kind { match pat.kind {
ast::PatKind::Mac(_) => *pat = self.remove(pat.id).make_pat(), ast::PatKind::MacCall(_) => *pat = self.remove(pat.id).make_pat(),
_ => noop_visit_pat(pat, self), _ => noop_visit_pat(pat, self),
} }
} }
fn visit_ty(&mut self, ty: &mut P<ast::Ty>) { fn visit_ty(&mut self, ty: &mut P<ast::Ty>) {
match ty.kind { match ty.kind {
ast::TyKind::Mac(_) => *ty = self.remove(ty.id).make_ty(), ast::TyKind::MacCall(_) => *ty = self.remove(ty.id).make_ty(),
_ => noop_visit_ty(ty, self), _ => noop_visit_ty(ty, self),
} }
} }
@ -328,12 +330,12 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
fn visit_mod(&mut self, module: &mut ast::Mod) { fn visit_mod(&mut self, module: &mut ast::Mod) {
noop_visit_mod(module, self); noop_visit_mod(module, self);
module.items.retain(|item| match item.kind { module.items.retain(|item| match item.kind {
ast::ItemKind::Mac(_) if !self.cx.ecfg.keep_macs => false, // remove macro definitions ast::ItemKind::MacCall(_) if !self.cx.ecfg.keep_macs => false, // remove macro definitions
_ => true, _ => true,
}); });
} }
fn visit_mac(&mut self, _mac: &mut ast::Mac) { fn visit_mac(&mut self, _mac: &mut ast::MacCall) {
// Do nothing. // Do nothing.
} }
} }

View File

@ -780,7 +780,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> {
// in general the pretty printer processes unexpanded code, so // in general the pretty printer processes unexpanded code, so
// we override the default `visit_mac` method which panics. // we override the default `visit_mac` method which panics.
fn visit_mac(&mut self, mac: &mut ast::Mac) { fn visit_mac(&mut self, mac: &mut ast::MacCall) {
noop_visit_mac(mac, self) noop_visit_mac(mac, self)
} }
} }

View File

@ -778,7 +778,7 @@ impl EarlyLintPass for UnusedDocComment {
ast::StmtKind::Empty ast::StmtKind::Empty
| ast::StmtKind::Semi(_) | ast::StmtKind::Semi(_)
| ast::StmtKind::Expr(_) | ast::StmtKind::Expr(_)
| ast::StmtKind::Mac(_) => return, | ast::StmtKind::MacCall(_) => return,
}; };
warn_if_doc(cx, stmt.span, kind, stmt.kind.attrs()); warn_if_doc(cx, stmt.span, kind, stmt.kind.attrs());
@ -1478,7 +1478,7 @@ impl EarlyLintPass for KeywordIdents {
fn check_mac_def(&mut self, cx: &EarlyContext<'_>, mac_def: &ast::MacroDef, _id: ast::NodeId) { fn check_mac_def(&mut self, cx: &EarlyContext<'_>, mac_def: &ast::MacroDef, _id: ast::NodeId) {
self.check_tokens(cx, mac_def.body.inner_tokens()); self.check_tokens(cx, mac_def.body.inner_tokens());
} }
fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::Mac) { fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::MacCall) {
self.check_tokens(cx, mac.args.inner_tokens()); self.check_tokens(cx, mac.args.inner_tokens());
} }
fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: ast::Ident) { fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: ast::Ident) {

View File

@ -249,7 +249,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
self.check_id(id); self.check_id(id);
} }
fn visit_mac(&mut self, mac: &'a ast::Mac) { fn visit_mac(&mut self, mac: &'a ast::MacCall) {
// FIXME(#54110): So, this setup isn't really right. I think // FIXME(#54110): So, this setup isn't really right. I think
// that (a) the librustc_ast visitor ought to be doing this as // that (a) the librustc_ast visitor ought to be doing this as
// part of `walk_mac`, and (b) we should be calling // part of `walk_mac`, and (b) we should be calling

View File

@ -198,7 +198,7 @@ macro_rules! early_lint_methods {
fn check_path(a: &ast::Path, b: ast::NodeId); fn check_path(a: &ast::Path, b: ast::NodeId);
fn check_attribute(a: &ast::Attribute); fn check_attribute(a: &ast::Attribute);
fn check_mac_def(a: &ast::MacroDef, b: ast::NodeId); fn check_mac_def(a: &ast::MacroDef, b: ast::NodeId);
fn check_mac(a: &ast::Mac); fn check_mac(a: &ast::MacCall);
/// Called when entering a syntax node that can have lint attributes such /// Called when entering a syntax node that can have lint attributes such
/// as `#[allow(...)]`. Called with *all* the attributes of that node. /// as `#[allow(...)]`. Called with *all* the attributes of that node.

View File

@ -538,7 +538,7 @@ impl EarlyLintPass for UnusedParens {
// Do not lint on `(..)` as that will result in the other arms being useless. // Do not lint on `(..)` as that will result in the other arms being useless.
Paren(_) Paren(_)
// The other cases do not contain sub-patterns. // The other cases do not contain sub-patterns.
| Wild | Rest | Lit(..) | Mac(..) | Range(..) | Ident(.., None) | Path(..) => return, | Wild | Rest | Lit(..) | MacCall(..) | Range(..) | Ident(.., None) | Path(..) => return,
// These are list-like patterns; parens can always be removed. // These are list-like patterns; parens can always be removed.
TupleStruct(_, ps) | Tuple(ps) | Slice(ps) | Or(ps) => for p in ps { TupleStruct(_, ps) | Tuple(ps) | Slice(ps) | Or(ps) => for p in ps {
self.check_unused_parens_pat(cx, p, false, false); self.check_unused_parens_pat(cx, p, false, false);

View File

@ -519,7 +519,7 @@ impl<'a> MutVisitor for StripUnconfigured<'a> {
noop_flat_map_assoc_item(configure!(self, item), self) noop_flat_map_assoc_item(configure!(self, item), self)
} }
fn visit_mac(&mut self, _mac: &mut ast::Mac) { fn visit_mac(&mut self, _mac: &mut ast::MacCall) {
// Don't configure interpolated AST (cf. issue #34171). // Don't configure interpolated AST (cf. issue #34171).
// Interpolated AST will get configured once the surrounding tokens are parsed. // Interpolated AST will get configured once the surrounding tokens are parsed.
} }

View File

@ -4,8 +4,8 @@ use super::{BlockMode, Parser, PathStyle, Restrictions, TokenType};
use super::{SemiColonMode, SeqSep, TokenExpectType}; use super::{SemiColonMode, SeqSep, TokenExpectType};
use crate::maybe_recover_from_interpolated_ty_qpath; use crate::maybe_recover_from_interpolated_ty_qpath;
use rustc_ast::ast::{self, AttrStyle, AttrVec, CaptureBy, Field, Ident, Lit, DUMMY_NODE_ID}; use rustc_ast::ast::{self, AttrStyle, AttrVec, CaptureBy, Field, Ident, Lit, UnOp, DUMMY_NODE_ID};
use rustc_ast::ast::{AnonConst, BinOp, BinOpKind, FnDecl, FnRetTy, Mac, Param, Ty, TyKind, UnOp}; use rustc_ast::ast::{AnonConst, BinOp, BinOpKind, FnDecl, FnRetTy, MacCall, Param, Ty, TyKind};
use rustc_ast::ast::{Arm, Async, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLimits}; use rustc_ast::ast::{Arm, Async, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLimits};
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::token::{self, Token, TokenKind}; use rustc_ast::token::{self, Token, TokenKind};
@ -1065,12 +1065,12 @@ impl<'a> Parser<'a> {
// `!`, as an operator, is prefix, so we know this isn't that. // `!`, as an operator, is prefix, so we know this isn't that.
let (hi, kind) = if self.eat(&token::Not) { let (hi, kind) = if self.eat(&token::Not) {
// MACRO INVOCATION expression // MACRO INVOCATION expression
let mac = Mac { let mac = MacCall {
path, path,
args: self.parse_mac_args()?, args: self.parse_mac_args()?,
prior_type_ascription: self.last_type_ascription, prior_type_ascription: self.last_type_ascription,
}; };
(self.prev_token.span, ExprKind::Mac(mac)) (self.prev_token.span, ExprKind::MacCall(mac))
} else if self.check(&token::OpenDelim(token::Brace)) { } else if self.check(&token::OpenDelim(token::Brace)) {
if let Some(expr) = self.maybe_parse_struct_expr(lo, &path, &attrs) { if let Some(expr) = self.maybe_parse_struct_expr(lo, &path, &attrs) {
return expr; return expr;

View File

@ -4,16 +4,12 @@ use super::{FollowedByType, Parser, PathStyle};
use crate::maybe_whole; use crate::maybe_whole;
use rustc_ast::ast::{self, AttrStyle, AttrVec, Attribute, Ident, DUMMY_NODE_ID}; use rustc_ast::ast::{self, Async, AttrStyle, AttrVec, Attribute, Ident, DUMMY_NODE_ID};
use rustc_ast::ast::{AssocItem, AssocItemKind, ForeignItemKind, Item, ItemKind}; use rustc_ast::ast::{AssocItem, AssocItemKind, ForeignItemKind, Item, ItemKind};
use rustc_ast::ast::{ use rustc_ast::ast::{BindingMode, Block, FnDecl, FnSig, MacArgs, MacCall, MacDelimiter, Param};
Async, Const, Defaultness, IsAuto, PathSegment, Unsafe, UseTree, UseTreeKind, use rustc_ast::ast::{Const, Defaultness, IsAuto, PathSegment, Unsafe, UseTree, UseTreeKind};
};
use rustc_ast::ast::{
BindingMode, Block, FnDecl, FnSig, Mac, MacArgs, MacDelimiter, Param, SelfKind,
};
use rustc_ast::ast::{EnumDef, Generics, StructField, TraitRef, Ty, TyKind, Variant, VariantData}; use rustc_ast::ast::{EnumDef, Generics, StructField, TraitRef, Ty, TyKind, Variant, VariantData};
use rustc_ast::ast::{FnHeader, ForeignItem, Mutability, Visibility, VisibilityKind}; use rustc_ast::ast::{FnHeader, ForeignItem, Mutability, SelfKind, Visibility, VisibilityKind};
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::token; use rustc_ast::token;
use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree}; use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree};
@ -220,7 +216,7 @@ impl<'a> Parser<'a> {
return Ok(None); return Ok(None);
} else if macros_allowed && self.check_path() { } else if macros_allowed && self.check_path() {
// MACRO INVOCATION ITEM // MACRO INVOCATION ITEM
(Ident::invalid(), ItemKind::Mac(self.parse_item_macro(vis)?)) (Ident::invalid(), ItemKind::MacCall(self.parse_item_macro(vis)?))
} else { } else {
return Ok(None); return Ok(None);
}; };
@ -339,13 +335,13 @@ impl<'a> Parser<'a> {
} }
/// Parses an item macro, e.g., `item!();`. /// Parses an item macro, e.g., `item!();`.
fn parse_item_macro(&mut self, vis: &Visibility) -> PResult<'a, Mac> { fn parse_item_macro(&mut self, vis: &Visibility) -> PResult<'a, MacCall> {
let path = self.parse_path(PathStyle::Mod)?; // `foo::bar` let path = self.parse_path(PathStyle::Mod)?; // `foo::bar`
self.expect(&token::Not)?; // `!` self.expect(&token::Not)?; // `!`
let args = self.parse_mac_args()?; // `( .. )` or `[ .. ]` (followed by `;`), or `{ .. }`. let args = self.parse_mac_args()?; // `( .. )` or `[ .. ]` (followed by `;`), or `{ .. }`.
self.eat_semi_for_macro_if_needed(&args); self.eat_semi_for_macro_if_needed(&args);
self.complain_if_pub_macro(vis, false); self.complain_if_pub_macro(vis, false);
Ok(Mac { path, args, prior_type_ascription: self.last_type_ascription }) Ok(MacCall { path, args, prior_type_ascription: self.last_type_ascription })
} }
/// Recover if we parsed attributes and expected an item but there was none. /// Recover if we parsed attributes and expected an item but there was none.

View File

@ -1,9 +1,7 @@
use super::{Parser, PathStyle}; use super::{Parser, PathStyle};
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole}; use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
use rustc_ast::ast::{ use rustc_ast::ast::{self, AttrVec, Attribute, FieldPat, MacCall, Pat, PatKind, RangeEnd};
self, AttrVec, Attribute, FieldPat, Mac, Pat, PatKind, RangeEnd, RangeSyntax, use rustc_ast::ast::{BindingMode, Expr, ExprKind, Ident, Mutability, Path, QSelf, RangeSyntax};
};
use rustc_ast::ast::{BindingMode, Expr, ExprKind, Ident, Mutability, Path, QSelf};
use rustc_ast::mut_visit::{noop_visit_mac, noop_visit_pat, MutVisitor}; use rustc_ast::mut_visit::{noop_visit_mac, noop_visit_pat, MutVisitor};
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::token; use rustc_ast::token;
@ -540,7 +538,7 @@ impl<'a> Parser<'a> {
fn make_all_value_bindings_mutable(pat: &mut P<Pat>) -> bool { fn make_all_value_bindings_mutable(pat: &mut P<Pat>) -> bool {
struct AddMut(bool); struct AddMut(bool);
impl MutVisitor for AddMut { impl MutVisitor for AddMut {
fn visit_mac(&mut self, mac: &mut Mac) { fn visit_mac(&mut self, mac: &mut MacCall) {
noop_visit_mac(mac, self); noop_visit_mac(mac, self);
} }
@ -597,8 +595,8 @@ impl<'a> Parser<'a> {
fn parse_pat_mac_invoc(&mut self, path: Path) -> PResult<'a, PatKind> { fn parse_pat_mac_invoc(&mut self, path: Path) -> PResult<'a, PatKind> {
self.bump(); self.bump();
let args = self.parse_mac_args()?; let args = self.parse_mac_args()?;
let mac = Mac { path, args, prior_type_ascription: self.last_type_ascription }; let mac = MacCall { path, args, prior_type_ascription: self.last_type_ascription };
Ok(PatKind::Mac(mac)) Ok(PatKind::MacCall(mac))
} }
fn fatal_unexpected_non_pat( fn fatal_unexpected_non_pat(

View File

@ -8,7 +8,7 @@ use crate::maybe_whole;
use crate::DirectoryOwnership; use crate::DirectoryOwnership;
use rustc_ast::ast; use rustc_ast::ast;
use rustc_ast::ast::{AttrStyle, AttrVec, Attribute, Mac, MacStmtStyle}; use rustc_ast::ast::{AttrStyle, AttrVec, Attribute, MacCall, MacStmtStyle};
use rustc_ast::ast::{Block, BlockCheckMode, Expr, ExprKind, Local, Stmt, StmtKind, DUMMY_NODE_ID}; use rustc_ast::ast::{Block, BlockCheckMode, Expr, ExprKind, Local, Stmt, StmtKind, DUMMY_NODE_ID};
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::token::{self, TokenKind}; use rustc_ast::token::{self, TokenKind};
@ -110,14 +110,14 @@ impl<'a> Parser<'a> {
let style = let style =
if delim == token::Brace { MacStmtStyle::Braces } else { MacStmtStyle::NoBraces }; if delim == token::Brace { MacStmtStyle::Braces } else { MacStmtStyle::NoBraces };
let mac = Mac { path, args, prior_type_ascription: self.last_type_ascription }; let mac = MacCall { path, args, prior_type_ascription: self.last_type_ascription };
let kind = if delim == token::Brace || self.token == token::Semi || self.token == token::Eof let kind = if delim == token::Brace || self.token == token::Semi || self.token == token::Eof
{ {
StmtKind::Mac(P((mac, style, attrs))) StmtKind::MacCall(P((mac, style, attrs)))
} else { } else {
// Since none of the above applied, this is an expression statement macro. // Since none of the above applied, this is an expression statement macro.
let e = self.mk_expr(lo.to(hi), ExprKind::Mac(mac), AttrVec::new()); let e = self.mk_expr(lo.to(hi), ExprKind::MacCall(mac), AttrVec::new());
let e = self.maybe_recover_from_bad_qpath(e, true)?; let e = self.maybe_recover_from_bad_qpath(e, true)?;
let e = self.parse_dot_or_call_expr_with(e, lo, attrs)?; let e = self.parse_dot_or_call_expr_with(e, lo, attrs)?;
let e = self.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(e))?; let e = self.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(e))?;

View File

@ -3,10 +3,8 @@ use super::{Parser, PathStyle, TokenType};
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole}; use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
use rustc_ast::ast::{self, BareFnTy, FnRetTy, GenericParam, Lifetime, MutTy, Ty, TyKind}; use rustc_ast::ast::{self, BareFnTy, FnRetTy, GenericParam, Lifetime, MutTy, Ty, TyKind};
use rustc_ast::ast::{ use rustc_ast::ast::{GenericBound, GenericBounds, MacCall, Mutability};
GenericBound, GenericBounds, PolyTraitRef, TraitBoundModifier, TraitObjectSyntax, use rustc_ast::ast::{PolyTraitRef, TraitBoundModifier, TraitObjectSyntax};
};
use rustc_ast::ast::{Mac, Mutability};
use rustc_ast::ptr::P; use rustc_ast::ptr::P;
use rustc_ast::token::{self, Token, TokenKind}; use rustc_ast::token::{self, Token, TokenKind};
use rustc_errors::{pluralize, struct_span_err, Applicability, PResult}; use rustc_errors::{pluralize, struct_span_err, Applicability, PResult};
@ -355,7 +353,7 @@ impl<'a> Parser<'a> {
let path = self.parse_path(PathStyle::Type)?; let path = self.parse_path(PathStyle::Type)?;
if self.eat(&token::Not) { if self.eat(&token::Not) {
// Macro invocation in type position // Macro invocation in type position
Ok(TyKind::Mac(Mac { Ok(TyKind::MacCall(MacCall {
path, path,
args: self.parse_mac_args()?, args: self.parse_mac_args()?,
prior_type_ascription: self.last_type_ascription, prior_type_ascription: self.last_type_ascription,

View File

@ -336,8 +336,8 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
ast_visit::walk_lifetime(self, lifetime) ast_visit::walk_lifetime(self, lifetime)
} }
fn visit_mac(&mut self, mac: &'v ast::Mac) { fn visit_mac(&mut self, mac: &'v ast::MacCall) {
self.record("Mac", Id::None, mac); self.record("MacCall", Id::None, mac);
} }
fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v ast::PathSegment) { fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v ast::PathSegment) {

View File

@ -302,7 +302,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
fn block_needs_anonymous_module(&mut self, block: &Block) -> bool { fn block_needs_anonymous_module(&mut self, block: &Block) -> bool {
// If any statements are items, we need to create an anonymous module // If any statements are items, we need to create an anonymous module
block.stmts.iter().any(|statement| match statement.kind { block.stmts.iter().any(|statement| match statement.kind {
StmtKind::Item(_) | StmtKind::Mac(_) => true, StmtKind::Item(_) | StmtKind::MacCall(_) => true,
_ => false, _ => false,
}) })
} }
@ -803,7 +803,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
// These items do not add names to modules. // These items do not add names to modules.
ItemKind::Impl { .. } | ItemKind::ForeignMod(..) | ItemKind::GlobalAsm(..) => {} ItemKind::Impl { .. } | ItemKind::ForeignMod(..) | ItemKind::GlobalAsm(..) => {}
ItemKind::MacroDef(..) | ItemKind::Mac(_) => unreachable!(), ItemKind::MacroDef(..) | ItemKind::MacCall(_) => unreachable!(),
} }
} }
@ -819,7 +819,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
ForeignItemKind::TyAlias(..) => { ForeignItemKind::TyAlias(..) => {
(Res::Def(DefKind::ForeignTy, self.r.definitions.local_def_id(item.id)), TypeNS) (Res::Def(DefKind::ForeignTy, self.r.definitions.local_def_id(item.id)), TypeNS)
} }
ForeignItemKind::Macro(_) => unreachable!(), ForeignItemKind::MacCall(_) => unreachable!(),
}; };
let parent = self.parent_scope.module; let parent = self.parent_scope.module;
let expansion = self.parent_scope.expansion; let expansion = self.parent_scope.expansion;
@ -1167,9 +1167,9 @@ macro_rules! method {
} }
impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
method!(visit_expr: ast::Expr, ast::ExprKind::Mac, walk_expr); method!(visit_expr: ast::Expr, ast::ExprKind::MacCall, walk_expr);
method!(visit_pat: ast::Pat, ast::PatKind::Mac, walk_pat); method!(visit_pat: ast::Pat, ast::PatKind::MacCall, walk_pat);
method!(visit_ty: ast::Ty, ast::TyKind::Mac, walk_ty); method!(visit_ty: ast::Ty, ast::TyKind::MacCall, walk_ty);
fn visit_item(&mut self, item: &'b Item) { fn visit_item(&mut self, item: &'b Item) {
let macro_use = match item.kind { let macro_use = match item.kind {
@ -1177,7 +1177,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
self.parent_scope.legacy = self.define_macro(item); self.parent_scope.legacy = self.define_macro(item);
return; return;
} }
ItemKind::Mac(..) => { ItemKind::MacCall(..) => {
self.parent_scope.legacy = self.visit_invoc(item.id); self.parent_scope.legacy = self.visit_invoc(item.id);
return; return;
} }
@ -1195,7 +1195,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
} }
fn visit_stmt(&mut self, stmt: &'b ast::Stmt) { fn visit_stmt(&mut self, stmt: &'b ast::Stmt) {
if let ast::StmtKind::Mac(..) = stmt.kind { if let ast::StmtKind::MacCall(..) = stmt.kind {
self.parent_scope.legacy = self.visit_invoc(stmt.id); self.parent_scope.legacy = self.visit_invoc(stmt.id);
} else { } else {
visit::walk_stmt(self, stmt); visit::walk_stmt(self, stmt);
@ -1203,7 +1203,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
} }
fn visit_foreign_item(&mut self, foreign_item: &'b ForeignItem) { fn visit_foreign_item(&mut self, foreign_item: &'b ForeignItem) {
if let ForeignItemKind::Macro(_) = foreign_item.kind { if let ForeignItemKind::MacCall(_) = foreign_item.kind {
self.visit_invoc(foreign_item.id); self.visit_invoc(foreign_item.id);
return; return;
} }
@ -1224,7 +1224,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
fn visit_assoc_item(&mut self, item: &'b AssocItem, ctxt: AssocCtxt) { fn visit_assoc_item(&mut self, item: &'b AssocItem, ctxt: AssocCtxt) {
let parent = self.parent_scope.module; let parent = self.parent_scope.module;
if let AssocItemKind::Macro(_) = item.kind { if let AssocItemKind::MacCall(_) = item.kind {
self.visit_invoc(item.id); self.visit_invoc(item.id);
return; return;
} }
@ -1246,7 +1246,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
(Res::Def(DefKind::Method, item_def_id), ValueNS) (Res::Def(DefKind::Method, item_def_id), ValueNS)
} }
AssocItemKind::TyAlias(..) => (Res::Def(DefKind::AssocTy, item_def_id), TypeNS), AssocItemKind::TyAlias(..) => (Res::Def(DefKind::AssocTy, item_def_id), TypeNS),
AssocItemKind::Macro(_) => bug!(), // handled above AssocItemKind::MacCall(_) => bug!(), // handled above
}; };
let vis = ty::Visibility::Public; let vis = ty::Visibility::Public;
@ -1259,7 +1259,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> {
fn visit_token(&mut self, t: Token) { fn visit_token(&mut self, t: Token) {
if let token::Interpolated(nt) = t.kind { if let token::Interpolated(nt) = t.kind {
if let token::NtExpr(ref expr) = *nt { if let token::NtExpr(ref expr) = *nt {
if let ast::ExprKind::Mac(..) = expr.kind { if let ast::ExprKind::MacCall(..) = expr.kind {
self.visit_invoc(expr.id); self.visit_invoc(expr.id);
} }
} }

View File

@ -132,7 +132,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
DefPathData::ValueNs(i.ident.name) DefPathData::ValueNs(i.ident.name)
} }
ItemKind::MacroDef(..) => DefPathData::MacroNs(i.ident.name), ItemKind::MacroDef(..) => DefPathData::MacroNs(i.ident.name),
ItemKind::Mac(..) => return self.visit_macro_invoc(i.id), ItemKind::MacCall(..) => return self.visit_macro_invoc(i.id),
ItemKind::GlobalAsm(..) => DefPathData::Misc, ItemKind::GlobalAsm(..) => DefPathData::Misc,
ItemKind::Use(..) => { ItemKind::Use(..) => {
return visit::walk_item(self, i); return visit::walk_item(self, i);
@ -160,7 +160,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
} }
fn visit_foreign_item(&mut self, foreign_item: &'a ForeignItem) { fn visit_foreign_item(&mut self, foreign_item: &'a ForeignItem) {
if let ForeignItemKind::Macro(_) = foreign_item.kind { if let ForeignItemKind::MacCall(_) = foreign_item.kind {
return self.visit_macro_invoc(foreign_item.id); return self.visit_macro_invoc(foreign_item.id);
} }
@ -230,7 +230,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
} }
AssocItemKind::Fn(..) | AssocItemKind::Const(..) => DefPathData::ValueNs(i.ident.name), AssocItemKind::Fn(..) | AssocItemKind::Const(..) => DefPathData::ValueNs(i.ident.name),
AssocItemKind::TyAlias(..) => DefPathData::TypeNs(i.ident.name), AssocItemKind::TyAlias(..) => DefPathData::TypeNs(i.ident.name),
AssocItemKind::Macro(..) => return self.visit_macro_invoc(i.id), AssocItemKind::MacCall(..) => return self.visit_macro_invoc(i.id),
}; };
let def = self.create_def(i.id, def_data, i.span); let def = self.create_def(i.id, def_data, i.span);
@ -239,7 +239,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
fn visit_pat(&mut self, pat: &'a Pat) { fn visit_pat(&mut self, pat: &'a Pat) {
match pat.kind { match pat.kind {
PatKind::Mac(..) => return self.visit_macro_invoc(pat.id), PatKind::MacCall(..) => return self.visit_macro_invoc(pat.id),
_ => visit::walk_pat(self, pat), _ => visit::walk_pat(self, pat),
} }
} }
@ -251,7 +251,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
fn visit_expr(&mut self, expr: &'a Expr) { fn visit_expr(&mut self, expr: &'a Expr) {
let parent_def = match expr.kind { let parent_def = match expr.kind {
ExprKind::Mac(..) => return self.visit_macro_invoc(expr.id), ExprKind::MacCall(..) => return self.visit_macro_invoc(expr.id),
ExprKind::Closure(_, asyncness, ..) => { ExprKind::Closure(_, asyncness, ..) => {
// Async closures desugar to closures inside of closures, so // Async closures desugar to closures inside of closures, so
// we must create two defs. // we must create two defs.
@ -274,7 +274,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
fn visit_ty(&mut self, ty: &'a Ty) { fn visit_ty(&mut self, ty: &'a Ty) {
match ty.kind { match ty.kind {
TyKind::Mac(..) => return self.visit_macro_invoc(ty.id), TyKind::MacCall(..) => return self.visit_macro_invoc(ty.id),
TyKind::ImplTrait(node_id, _) => { TyKind::ImplTrait(node_id, _) => {
self.create_def(node_id, DefPathData::ImplTrait, ty.span); self.create_def(node_id, DefPathData::ImplTrait, ty.span);
} }
@ -285,7 +285,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
fn visit_stmt(&mut self, stmt: &'a Stmt) { fn visit_stmt(&mut self, stmt: &'a Stmt) {
match stmt.kind { match stmt.kind {
StmtKind::Mac(..) => self.visit_macro_invoc(stmt.id), StmtKind::MacCall(..) => self.visit_macro_invoc(stmt.id),
_ => visit::walk_stmt(self, stmt), _ => visit::walk_stmt(self, stmt),
} }
} }
@ -293,7 +293,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
fn visit_token(&mut self, t: Token) { fn visit_token(&mut self, t: Token) {
if let token::Interpolated(nt) = t.kind { if let token::Interpolated(nt) = t.kind {
if let token::NtExpr(ref expr) = *nt { if let token::NtExpr(ref expr) = *nt {
if let ExprKind::Mac(..) = expr.kind { if let ExprKind::MacCall(..) = expr.kind {
self.visit_macro_invoc(expr.id); self.visit_macro_invoc(expr.id);
} }
} }

View File

@ -449,7 +449,7 @@ impl<'a, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
visit::walk_foreign_item(this, foreign_item); visit::walk_foreign_item(this, foreign_item);
}); });
} }
ForeignItemKind::Macro(..) => { ForeignItemKind::MacCall(..) => {
visit::walk_foreign_item(self, foreign_item); visit::walk_foreign_item(self, foreign_item);
} }
} }
@ -852,7 +852,7 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
AssocItemKind::TyAlias(_, generics, _, _) => { AssocItemKind::TyAlias(_, generics, _, _) => {
walk_assoc_item(this, generics, item); walk_assoc_item(this, generics, item);
} }
AssocItemKind::Macro(_) => { AssocItemKind::MacCall(_) => {
panic!("unexpanded macro in resolve!") panic!("unexpanded macro in resolve!")
} }
}; };
@ -897,7 +897,7 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
// do nothing, these are just around to be encoded // do nothing, these are just around to be encoded
} }
ItemKind::Mac(_) => panic!("unexpanded macro in resolve!"), ItemKind::MacCall(_) => panic!("unexpanded macro in resolve!"),
} }
} }
@ -1174,7 +1174,7 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
}, },
); );
} }
AssocItemKind::Macro(_) => { AssocItemKind::MacCall(_) => {
panic!("unexpanded macro in resolve!") panic!("unexpanded macro in resolve!")
} }
} }

View File

@ -1067,7 +1067,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
self.visit_ty(default_ty) self.visit_ty(default_ty)
} }
} }
ast::AssocItemKind::Macro(_) => {} ast::AssocItemKind::MacCall(_) => {}
} }
} }
@ -1103,7 +1103,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
// trait. // trait.
self.visit_ty(ty) self.visit_ty(ty)
} }
ast::AssocItemKind::Macro(_) => {} ast::AssocItemKind::MacCall(_) => {}
} }
} }
@ -1345,7 +1345,7 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
walk_list!(self, visit_ty, ty); walk_list!(self, visit_ty, ty);
self.process_generic_params(ty_params, &qualname, item.id); self.process_generic_params(ty_params, &qualname, item.id);
} }
Mac(_) => (), MacCall(_) => (),
_ => visit::walk_item(self, item), _ => visit::walk_item(self, item),
} }
} }
@ -1549,7 +1549,7 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
self.dumper.dump_def(&access, var_data); self.dumper.dump_def(&access, var_data);
} }
} }
ast::ForeignItemKind::Macro(..) => {} ast::ForeignItemKind::MacCall(..) => {}
} }
} }
} }

View File

@ -174,7 +174,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
} }
// FIXME(plietar): needs a new DefKind in rls-data // FIXME(plietar): needs a new DefKind in rls-data
ast::ForeignItemKind::TyAlias(..) => None, ast::ForeignItemKind::TyAlias(..) => None,
ast::ForeignItemKind::Macro(..) => None, ast::ForeignItemKind::MacCall(..) => None,
} }
} }

View File

@ -308,7 +308,7 @@ impl Sig for ast::Ty {
| ast::TyKind::Infer | ast::TyKind::Infer
| ast::TyKind::Err | ast::TyKind::Err
| ast::TyKind::ImplicitSelf | ast::TyKind::ImplicitSelf
| ast::TyKind::Mac(_) => Err("Ty"), | ast::TyKind::MacCall(_) => Err("Ty"),
} }
} }
} }
@ -544,7 +544,7 @@ impl Sig for ast::Item {
ast::ItemKind::ExternCrate(_) => Err("extern crate"), ast::ItemKind::ExternCrate(_) => Err("extern crate"),
// FIXME should implement this (e.g., pub use). // FIXME should implement this (e.g., pub use).
ast::ItemKind::Use(_) => Err("import"), ast::ItemKind::Use(_) => Err("import"),
ast::ItemKind::Mac(..) | ast::ItemKind::MacroDef(_) => Err("Macro"), ast::ItemKind::MacCall(..) | ast::ItemKind::MacroDef(_) => Err("Macro"),
} }
} }
} }
@ -795,7 +795,7 @@ impl Sig for ast::ForeignItem {
Ok(Signature { text, defs, refs: vec![] }) Ok(Signature { text, defs, refs: vec![] })
} }
ast::ForeignItemKind::Macro(..) => Err("macro"), ast::ForeignItemKind::MacCall(..) => Err("macro"),
} }
} }
} }

View File

@ -449,7 +449,7 @@ pub fn make_test(
} }
if !found_macro { if !found_macro {
if let ast::ItemKind::Mac(..) = item.kind { if let ast::ItemKind::MacCall(..) = item.kind {
found_macro = true; found_macro = true;
} }
} }