diff --git a/src/librustc_ast/ast.rs b/src/librustc_ast/ast.rs index 7cc045ef34461..ccf20ad154bfa 100644 --- a/src/librustc_ast/ast.rs +++ b/src/librustc_ast/ast.rs @@ -14,7 +14,7 @@ //! - [`Generics`], [`GenericParam`], [`WhereClause`]: Metadata associated with generic parameters. //! - [`EnumDef`] and [`Variant`]: Enum declaration. //! - [`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. //! - [`UnOp`], [`UnOpKind`], [`BinOp`], [`BinOpKind`]: Unary and binary operators. @@ -513,7 +513,7 @@ impl Pat { TyKind::Path(None, Path::from_ident(*ident)) } 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. PatKind::Ref(pat, mutbl) => { pat.to_ty().map(|ty| TyKind::Rptr(None, MutTy { ty, mutbl: *mutbl }))? @@ -567,7 +567,7 @@ impl Pat { | PatKind::Range(..) | PatKind::Ident(..) | PatKind::Path(..) - | PatKind::Mac(_) => {} + | PatKind::MacCall(_) => {} } } @@ -682,7 +682,7 @@ pub enum PatKind { Paren(P), /// A macro pattern; pre-expansion. - Mac(Mac), + MacCall(MacCall), } #[derive( @@ -881,9 +881,9 @@ impl Stmt { pub fn add_trailing_semicolon(mut self) -> Self { self.kind = match self.kind { StmtKind::Expr(expr) => StmtKind::Semi(expr), - StmtKind::Mac(mac) => { - StmtKind::Mac(mac.map(|(mac, _style, attrs)| (mac, MacStmtStyle::Semicolon, attrs))) - } + StmtKind::MacCall(mac) => StmtKind::MacCall( + mac.map(|(mac, _style, attrs)| (mac, MacStmtStyle::Semicolon, attrs)), + ), kind => kind, }; self @@ -917,7 +917,7 @@ pub enum StmtKind { /// Just a trailing semi-colon. Empty, /// Macro. - Mac(P<(Mac, MacStmtStyle, AttrVec)>), + MacCall(P<(MacCall, MacStmtStyle, AttrVec)>), } #[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)] @@ -1057,7 +1057,7 @@ impl Expr { let kind = match &self.kind { // Trivial conversions. 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)?, @@ -1127,7 +1127,7 @@ impl Expr { ExprKind::Continue(..) => ExprPrecedence::Continue, ExprKind::Ret(..) => ExprPrecedence::Ret, ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm, - ExprKind::Mac(..) => ExprPrecedence::Mac, + ExprKind::MacCall(..) => ExprPrecedence::Mac, ExprKind::Struct(..) => ExprPrecedence::Struct, ExprKind::Repeat(..) => ExprPrecedence::Repeat, ExprKind::Paren(..) => ExprPrecedence::Paren, @@ -1259,7 +1259,7 @@ pub enum ExprKind { InlineAsm(P), /// A macro invocation; pre-expansion. - Mac(Mac), + MacCall(MacCall), /// A struct literal expression. /// @@ -1345,13 +1345,13 @@ pub enum Movability { /// Represents a macro invocation. The `path` indicates which macro /// is being invoked, and the `args` are arguments passed to it. #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] -pub struct Mac { +pub struct MacCall { pub path: Path, pub args: P, pub prior_type_ascription: Option<(Span, bool)>, } -impl Mac { +impl MacCall { pub fn span(&self) -> 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. ImplicitSelf, /// A macro in the type position. - Mac(Mac), + MacCall(MacCall), /// Placeholder for a kind that has failed to be defined. Err, /// Placeholder for a `va_list`. @@ -2574,7 +2574,7 @@ pub enum ItemKind { /// A macro invocation. /// /// E.g., `foo!(..)`. - Mac(Mac), + MacCall(MacCall), /// A macro definition. MacroDef(MacroDef), @@ -2586,7 +2586,7 @@ impl ItemKind { match self { Use(..) | Static(..) | Const(..) | Fn(..) | Mod(..) | GlobalAsm(..) | TyAlias(..) | 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::Trait(..) => "trait", ItemKind::TraitAlias(..) => "trait alias", - ItemKind::Mac(..) => "item macro invocation", + ItemKind::MacCall(..) => "item macro invocation", ItemKind::MacroDef(..) => "macro definition", ItemKind::Impl { .. } => "implementation", } @@ -2648,14 +2648,14 @@ pub enum AssocItemKind { /// An associated type. TyAlias(Defaultness, Generics, GenericBounds, Option>), /// A macro expanding to associated items. - Macro(Mac), + MacCall(MacCall), } impl AssocItemKind { pub fn defaultness(&self) -> Defaultness { match *self { Self::Const(def, ..) | Self::Fn(def, ..) | Self::TyAlias(def, ..) => def, - Self::Macro(..) => Defaultness::Final, + Self::MacCall(..) => Defaultness::Final, } } } @@ -2666,7 +2666,7 @@ impl From for ItemKind { AssocItemKind::Const(a, b, c) => ItemKind::Const(a, b, c), 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::Macro(a) => ItemKind::Mac(a), + AssocItemKind::MacCall(a) => ItemKind::MacCall(a), } } } @@ -2679,7 +2679,7 @@ impl TryFrom for AssocItemKind { ItemKind::Const(a, b, c) => AssocItemKind::Const(a, b, c), 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::Mac(a) => AssocItemKind::Macro(a), + ItemKind::MacCall(a) => AssocItemKind::MacCall(a), _ => return Err(item_kind), }) } @@ -2695,7 +2695,7 @@ pub enum ForeignItemKind { /// A foreign type. TyAlias(Defaultness, Generics, GenericBounds, Option>), /// A macro expanding to foreign items. - Macro(Mac), + MacCall(MacCall), } impl From for ItemKind { @@ -2704,7 +2704,7 @@ impl From for ItemKind { ForeignItemKind::Static(a, b, c) => ItemKind::Static(a, b, c), 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::Macro(a) => ItemKind::Mac(a), + ForeignItemKind::MacCall(a) => ItemKind::MacCall(a), } } } @@ -2717,7 +2717,7 @@ impl TryFrom for ForeignItemKind { ItemKind::Static(a, b, c) => ForeignItemKind::Static(a, b, c), 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::Mac(a) => ForeignItemKind::Macro(a), + ItemKind::MacCall(a) => ForeignItemKind::MacCall(a), _ => return Err(item_kind), }) } diff --git a/src/librustc_ast/attr/mod.rs b/src/librustc_ast/attr/mod.rs index 0638e8e667617..a68b70eeeb4f8 100644 --- a/src/librustc_ast/attr/mod.rs +++ b/src/librustc_ast/attr/mod.rs @@ -676,7 +676,7 @@ impl HasAttrs for StmtKind { StmtKind::Local(ref local) => local.attrs(), StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => expr.attrs(), StmtKind::Empty | StmtKind::Item(..) => &[], - StmtKind::Mac(ref mac) => { + StmtKind::MacCall(ref mac) => { let (_, _, ref attrs) = **mac; attrs.attrs() } @@ -688,7 +688,7 @@ impl HasAttrs for StmtKind { StmtKind::Local(local) => local.visit_attrs(f), StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.visit_attrs(f), StmtKind::Empty | StmtKind::Item(..) => {} - StmtKind::Mac(mac) => { + StmtKind::MacCall(mac) => { let (_mac, _style, attrs) = mac.deref_mut(); attrs.visit_attrs(f); } diff --git a/src/librustc_ast/mut_visit.rs b/src/librustc_ast/mut_visit.rs index dedc74eea9279..a1a5b9debc50d 100644 --- a/src/librustc_ast/mut_visit.rs +++ b/src/librustc_ast/mut_visit.rs @@ -202,7 +202,7 @@ pub trait MutVisitor: Sized { 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"); // N.B., see note about macros above. If you really want a visitor that // works on macros, use this definition in your trait impl: @@ -482,7 +482,7 @@ pub fn noop_visit_ty(ty: &mut P, vis: &mut T) { vis.visit_id(id); 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); } @@ -584,8 +584,8 @@ pub fn noop_visit_attribute(attr: &mut Attribute, vis: &mut T) { vis.visit_span(span); } -pub fn noop_visit_mac(mac: &mut Mac, vis: &mut T) { - let Mac { path, args, prior_type_ascription: _ } = mac; +pub fn noop_visit_mac(mac: &mut MacCall, vis: &mut T) { + let MacCall { path, args, prior_type_ascription: _ } = mac; vis.visit_path(path); visit_mac_args(args, vis); } @@ -926,7 +926,7 @@ pub fn noop_visit_item_kind(kind: &mut ItemKind, vis: &mut T) { vis.visit_generics(generics); 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), } } @@ -955,7 +955,7 @@ pub fn noop_flat_map_assoc_item( visit_bounds(bounds, visitor); 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); smallvec![item] @@ -1043,7 +1043,7 @@ pub fn noop_flat_map_foreign_item( visit_bounds(bounds, visitor); 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); smallvec![item] @@ -1082,7 +1082,7 @@ pub fn noop_visit_pat(pat: &mut P, vis: &mut T) { visit_vec(elems, |elem| vis.visit_pat(elem)) } 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); } @@ -1219,7 +1219,7 @@ pub fn noop_visit_expr(Expr { kind, id, span, attrs }: &mut 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) => { vis.visit_path(path); fields.flat_map_in_place(|field| vis.flat_map_field(field)); @@ -1275,11 +1275,11 @@ pub fn noop_flat_map_stmt_kind( 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::Empty => smallvec![StmtKind::Empty], - StmtKind::Mac(mut mac) => { + StmtKind::MacCall(mut mac) => { let (mac_, _semi, attrs) = mac.deref_mut(); vis.visit_mac(mac_); visit_thin_attrs(attrs, vis); - smallvec![StmtKind::Mac(mac)] + smallvec![StmtKind::MacCall(mac)] } } } diff --git a/src/librustc_ast/visit.rs b/src/librustc_ast/visit.rs index 1436c84b9c1f3..39028b7583c63 100644 --- a/src/librustc_ast/visit.rs +++ b/src/librustc_ast/visit.rs @@ -168,7 +168,7 @@ pub trait Visitor<'ast>: Sized { fn visit_lifetime(&mut self, lifetime: &'ast 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"); // N.B., see note about macros above. // 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); 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), } 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::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 => {} } } @@ -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) => { 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_ty, ty); } - ForeignItemKind::Macro(mac) => { + ForeignItemKind::MacCall(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_ty, ty); } - AssocItemKind::Macro(mac) => { + AssocItemKind::MacCall(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::Expr(ref expr) | StmtKind::Semi(ref expr) => visitor.visit_expr(expr), StmtKind::Empty => {} - StmtKind::Mac(ref mac) => { + StmtKind::MacCall(ref mac) => { let (ref mac, _, ref attrs) = **mac; visitor.visit_mac(mac); 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); } @@ -811,7 +811,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) { ExprKind::Ret(ref 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::InlineAsm(ref ia) => { for &(_, ref input) in &ia.inputs { diff --git a/src/librustc_ast_lowering/expr.rs b/src/librustc_ast_lowering/expr.rs index 7038387caa9bf..a4cbae5196635 100644 --- a/src/librustc_ast_lowering/expr.rs +++ b/src/librustc_ast_lowering/expr.rs @@ -198,7 +198,7 @@ impl<'hir> LoweringContext<'_, 'hir> { 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::Mac(_) => panic!("Shouldn't exist here"), + ExprKind::MacCall(_) => panic!("Shouldn't exist here"), }; hir::Expr { diff --git a/src/librustc_ast_lowering/item.rs b/src/librustc_ast_lowering/item.rs index 46aad99f13130..d17267a153c33 100644 --- a/src/librustc_ast_lowering/item.rs +++ b/src/librustc_ast_lowering/item.rs @@ -426,7 +426,7 @@ impl<'hir> LoweringContext<'_, 'hir> { self.lower_generics(generics, 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") } } @@ -676,7 +676,7 @@ impl<'hir> LoweringContext<'_, 'hir> { hir::ForeignItemKind::Static(ty, m) } 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), span: i.span, @@ -779,7 +779,7 @@ impl<'hir> LoweringContext<'_, 'hir> { (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 { @@ -801,7 +801,7 @@ impl<'hir> LoweringContext<'_, 'hir> { AssocItemKind::Fn(_, sig, _, default) => { (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 defaultness = hir::Defaultness::Default { has_value: has_default }; @@ -860,7 +860,7 @@ impl<'hir> LoweringContext<'_, 'hir> { }; (generics, kind) } - AssocItemKind::Macro(..) => bug!("`TyMac` should have been expanded by now"), + AssocItemKind::MacCall(..) => bug!("`TyMac` should have been expanded by now"), }; hir::ImplItem { @@ -895,7 +895,7 @@ impl<'hir> LoweringContext<'_, 'hir> { AssocItemKind::Fn(_, sig, ..) => { hir::AssocItemKind::Method { has_self: sig.decl.has_self() } } - AssocItemKind::Macro(..) => unimplemented!(), + AssocItemKind::MacCall(..) => unimplemented!(), }, } diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs index df71b05ac2c98..4964b7174a734 100644 --- a/src/librustc_ast_lowering/lib.rs +++ b/src/librustc_ast_lowering/lib.rs @@ -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 => { self.sess.delay_span_bug( t.span, @@ -2282,7 +2282,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { StmtKind::Expr(ref e) => hir::StmtKind::Expr(self.lower_expr(e)), StmtKind::Semi(ref e) => hir::StmtKind::Semi(self.lower_expr(e)), 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 }] } diff --git a/src/librustc_ast_lowering/pat.rs b/src/librustc_ast_lowering/pat.rs index d6f4ba1529be6..8ba6576f69265 100644 --- a/src/librustc_ast_lowering/pat.rs +++ b/src/librustc_ast_lowering/pat.rs @@ -75,7 +75,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { self.ban_illegal_rest_pat(p.span) } 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) diff --git a/src/librustc_ast_passes/ast_validation.rs b/src/librustc_ast_passes/ast_validation.rs index 69d5610e01601..d7491800f0428 100644 --- a/src/librustc_ast_passes/ast_validation.rs +++ b/src/librustc_ast_passes/ast_validation.rs @@ -976,7 +976,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { ForeignItemKind::Static(_, _, body) => { 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) diff --git a/src/librustc_ast_passes/feature_gate.rs b/src/librustc_ast_passes/feature_gate.rs index 97c88d4f1d966..6a0f5235eca25 100644 --- a/src/librustc_ast_passes/feature_gate.rs +++ b/src/librustc_ast_passes/feature_gate.rs @@ -400,7 +400,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { ast::ForeignItemKind::TyAlias(..) => { gate_feature_post!(&self, extern_types, i.span, "extern types are experimental"); } - ast::ForeignItemKind::Macro(..) => {} + ast::ForeignItemKind::MacCall(..) => {} } visit::walk_foreign_item(self, i) diff --git a/src/librustc_ast_passes/node_count.rs b/src/librustc_ast_passes/node_count.rs index 16bcec8360e34..534d6c7b1ea70 100644 --- a/src/librustc_ast_passes/node_count.rs +++ b/src/librustc_ast_passes/node_count.rs @@ -113,7 +113,7 @@ impl<'ast> Visitor<'ast> for NodeCounter { self.count += 1; walk_lifetime(self, lifetime) } - fn visit_mac(&mut self, _mac: &Mac) { + fn visit_mac(&mut self, _mac: &MacCall) { self.count += 1; walk_mac(self, _mac) } diff --git a/src/librustc_ast_passes/show_span.rs b/src/librustc_ast_passes/show_span.rs index 73a66ba566bc6..2366426d4dcba 100644 --- a/src/librustc_ast_passes/show_span.rs +++ b/src/librustc_ast_passes/show_span.rs @@ -55,7 +55,7 @@ impl<'a> Visitor<'a> for ShowSpanVisitor<'a> { 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); } } diff --git a/src/librustc_ast_pretty/pprust.rs b/src/librustc_ast_pretty/pprust.rs index b11dda8af731e..e3f75769eef8b 100644 --- a/src/librustc_ast_pretty/pprust.rs +++ b/src/librustc_ast_pretty/pprust.rs @@ -960,7 +960,7 @@ impl<'a> State<'a> { ast::TyKind::ImplicitSelf => { self.s.word("Self"); } - ast::TyKind::Mac(ref m) => { + ast::TyKind::MacCall(ref m) => { self.print_mac(m); } ast::TyKind::CVarArgs => { @@ -987,7 +987,7 @@ impl<'a> State<'a> { ast::ForeignItemKind::TyAlias(def, generics, bounds, ty) => { self.print_associated_type(ident, generics, bounds, ty.as_deref(), vis, *def); } - ast::ForeignItemKind::Macro(m) => { + ast::ForeignItemKind::MacCall(m) => { self.print_mac(m); if m.args.need_semicolon() { self.s.word(";"); @@ -1231,7 +1231,7 @@ impl<'a> State<'a> { self.print_where_clause(&generics.where_clause); self.s.word(";"); } - ast::ItemKind::Mac(ref mac) => { + ast::ItemKind::MacCall(ref mac) => { self.print_mac(mac); if mac.args.need_semicolon() { self.s.word(";"); @@ -1413,7 +1413,7 @@ impl<'a> State<'a> { ast::AssocItemKind::TyAlias(def, generics, bounds, ty) => { self.print_associated_type(ident, generics, bounds, ty.as_deref(), vis, *def); } - ast::AssocItemKind::Macro(m) => { + ast::AssocItemKind::MacCall(m) => { self.print_mac(m); if m.args.need_semicolon() { self.s.word(";"); @@ -1460,7 +1460,7 @@ impl<'a> State<'a> { self.space_if_not_bol(); self.s.word(";"); } - ast::StmtKind::Mac(ref mac) => { + ast::StmtKind::MacCall(ref mac) => { let (ref mac, style, ref attrs) = **mac; self.space_if_not_bol(); self.print_outer_attributes(attrs); @@ -1570,7 +1570,7 @@ impl<'a> State<'a> { 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( Some(MacHeader::Path(&m.path)), true, @@ -2070,7 +2070,7 @@ impl<'a> State<'a> { 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) => { self.popen(); self.print_inner_attributes_inline(attrs); @@ -2254,7 +2254,7 @@ impl<'a> State<'a> { self.print_pat(inner); 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)) } diff --git a/src/librustc_builtin_macros/assert.rs b/src/librustc_builtin_macros/assert.rs index 5da4a540940c2..d52a589b1c18f 100644 --- a/src/librustc_builtin_macros/assert.rs +++ b/src/librustc_builtin_macros/assert.rs @@ -40,7 +40,7 @@ pub fn expand_assert<'cx>( )) }); 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)), args, prior_type_ascription: None, @@ -48,7 +48,7 @@ pub fn expand_assert<'cx>( let if_expr = cx.expr_if( sp, cx.expr(sp, ExprKind::Unary(UnOp::Not, cond_expr)), - cx.expr(sp, ExprKind::Mac(panic_call)), + cx.expr(sp, ExprKind::MacCall(panic_call)), None, ); MacEager::expr(if_expr) diff --git a/src/librustc_builtin_macros/deriving/generic/mod.rs b/src/librustc_builtin_macros/deriving/generic/mod.rs index 311298c0f4083..00beaa496e96d 100644 --- a/src/librustc_builtin_macros/deriving/generic/mod.rs +++ b/src/librustc_builtin_macros/deriving/generic/mod.rs @@ -360,7 +360,7 @@ fn find_type_parameters( 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"); } } diff --git a/src/librustc_builtin_macros/proc_macro_harness.rs b/src/librustc_builtin_macros/proc_macro_harness.rs index 7972466236333..179b013342633 100644 --- a/src/librustc_builtin_macros/proc_macro_harness.rs +++ b/src/librustc_builtin_macros/proc_macro_harness.rs @@ -341,7 +341,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> { 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) } } diff --git a/src/librustc_builtin_macros/test.rs b/src/librustc_builtin_macros/test.rs index bc194a3eec4c3..39009ca27f102 100644 --- a/src/librustc_builtin_macros/test.rs +++ b/src/librustc_builtin_macros/test.rs @@ -86,7 +86,7 @@ pub fn expand_test_or_bench( .raise(); }; - if let ast::ItemKind::Mac(_) = item.kind { + if let ast::ItemKind::MacCall(_) = item.kind { cx.parse_sess.span_diagnostic.span_warn( item.span, "`#[test]` attribute should not be used on macros. Use `#[cfg(test)]` instead.", diff --git a/src/librustc_builtin_macros/test_harness.rs b/src/librustc_builtin_macros/test_harness.rs index e7e1ad8eda784..15997a27fadf2 100644 --- a/src/librustc_builtin_macros/test_harness.rs +++ b/src/librustc_builtin_macros/test_harness.rs @@ -138,7 +138,7 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> { smallvec![P(item)] } - fn visit_mac(&mut self, _mac: &mut ast::Mac) { + fn visit_mac(&mut self, _mac: &mut ast::MacCall) { // Do nothing. } } @@ -184,7 +184,7 @@ impl MutVisitor for EntryPointCleaner { smallvec![item] } - fn visit_mac(&mut self, _mac: &mut ast::Mac) { + fn visit_mac(&mut self, _mac: &mut ast::MacCall) { // Do nothing. } } diff --git a/src/librustc_expand/base.rs b/src/librustc_expand/base.rs index 9258b59f79be8..81da40d280232 100644 --- a/src/librustc_expand/base.rs +++ b/src/librustc_expand/base.rs @@ -347,7 +347,7 @@ where 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) } } diff --git a/src/librustc_expand/expand.rs b/src/librustc_expand/expand.rs index b16659725db73..3480dfecf8d0c 100644 --- a/src/librustc_expand/expand.rs +++ b/src/librustc_expand/expand.rs @@ -272,7 +272,7 @@ pub struct Invocation { pub enum InvocationKind { Bang { - mac: ast::Mac, + mac: ast::MacCall, span: Span, }, Attr { @@ -626,7 +626,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { /// A macro's expansion does not fit in this fragment kind. /// 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!( "non-{kind} macro in {kind} position: {path}", kind = kind.name(), @@ -793,7 +793,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { 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() { @@ -992,7 +992,12 @@ impl<'a, 'b> InvocationCollector<'a, 'b> { 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 }) } @@ -1135,7 +1140,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { .into_inner(); } - if let ast::ExprKind::Mac(mac) = expr.kind { + if let ast::ExprKind::MacCall(mac) = expr.kind { self.check_attributes(&expr.attrs); self.collect_bang(mac, expr.span, AstFragmentKind::Expr).make_expr().into_inner() } else { @@ -1282,7 +1287,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { .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.collect_bang(mac, expr.span, AstFragmentKind::OptExpr) .make_opt_expr() @@ -1299,12 +1304,14 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { fn visit_pat(&mut self, pat: &mut P) { self.cfg.configure_pat(pat); match pat.kind { - PatKind::Mac(_) => {} + PatKind::MacCall(_) => {} _ => return noop_visit_pat(pat, self), } 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!(), }); } @@ -1336,7 +1343,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(); self.check_attributes(&attrs); let mut placeholder = @@ -1385,10 +1392,10 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { } match item.kind { - ast::ItemKind::Mac(..) => { + ast::ItemKind::MacCall(..) => { self.check_attributes(&item.attrs); item.and_then(|item| match item.kind { - ItemKind::Mac(mac) => self + ItemKind::MacCall(mac) => self .collect( AstFragmentKind::Items, InvocationKind::Bang { mac, span: item.span }, @@ -1457,10 +1464,10 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { } match item.kind { - ast::AssocItemKind::Macro(..) => { + ast::AssocItemKind::MacCall(..) => { self.check_attributes(&item.attrs); item.and_then(|item| match item.kind { - ast::AssocItemKind::Macro(mac) => self + ast::AssocItemKind::MacCall(mac) => self .collect_bang(mac, item.span, AstFragmentKind::TraitItems) .make_trait_items(), _ => unreachable!(), @@ -1487,10 +1494,10 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { } match item.kind { - ast::AssocItemKind::Macro(..) => { + ast::AssocItemKind::MacCall(..) => { self.check_attributes(&item.attrs); item.and_then(|item| match item.kind { - ast::AssocItemKind::Macro(mac) => self + ast::AssocItemKind::MacCall(mac) => self .collect_bang(mac, item.span, AstFragmentKind::ImplItems) .make_impl_items(), _ => unreachable!(), @@ -1502,12 +1509,14 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { fn visit_ty(&mut self, ty: &mut P) { match ty.kind { - ast::TyKind::Mac(_) => {} + ast::TyKind::MacCall(_) => {} _ => return noop_visit_ty(ty, self), }; 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!(), }); } @@ -1536,10 +1545,10 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { } match foreign_item.kind { - ast::ForeignItemKind::Macro(..) => { + ast::ForeignItemKind::MacCall(..) => { self.check_attributes(&foreign_item.attrs); 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) .make_foreign_items(), _ => unreachable!(), diff --git a/src/librustc_expand/mbe/transcribe.rs b/src/librustc_expand/mbe/transcribe.rs index d12dedf9e0c7a..7a64d40785e09 100644 --- a/src/librustc_expand/mbe/transcribe.rs +++ b/src/librustc_expand/mbe/transcribe.rs @@ -2,7 +2,7 @@ use crate::base::ExtCtxt; use crate::mbe; 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::token::{self, NtTT, Token}; use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree, TreeAndJoint}; @@ -23,7 +23,7 @@ impl MutVisitor for Marker { *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) } } diff --git a/src/librustc_expand/mut_visit/tests.rs b/src/librustc_expand/mut_visit/tests.rs index 4c947d8fa2b4e..70fb8975d4d08 100644 --- a/src/librustc_expand/mut_visit/tests.rs +++ b/src/librustc_expand/mut_visit/tests.rs @@ -17,7 +17,7 @@ impl MutVisitor for ToZzIdentMutVisitor { fn visit_ident(&mut self, ident: &mut ast::Ident) { *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) } } diff --git a/src/librustc_expand/parse/tests.rs b/src/librustc_expand/parse/tests.rs index 55e815bd4a4e0..4add896258fa8 100644 --- a/src/librustc_expand/parse/tests.rs +++ b/src/librustc_expand/parse/tests.rs @@ -281,7 +281,7 @@ fn ttdelim_span() { .unwrap(); 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"), }; diff --git a/src/librustc_expand/placeholders.rs b/src/librustc_expand/placeholders.rs index cd4f0a61d424a..e1781f8636e58 100644 --- a/src/librustc_expand/placeholders.rs +++ b/src/librustc_expand/placeholders.rs @@ -15,8 +15,8 @@ pub fn placeholder( id: ast::NodeId, vis: Option, ) -> AstFragment { - fn mac_placeholder() -> ast::Mac { - ast::Mac { + fn mac_placeholder() -> ast::MacCall { + ast::MacCall { path: ast::Path { span: DUMMY_SP, segments: Vec::new() }, args: P(ast::MacArgs::Empty), prior_type_ascription: None, @@ -32,11 +32,11 @@ pub fn placeholder( id, span, 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 pat = || P(ast::Pat { id, kind: ast::PatKind::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::MacCall(mac_placeholder()), span }); match kind { AstFragmentKind::Expr => AstFragment::Expr(expr_placeholder()), @@ -47,7 +47,7 @@ pub fn placeholder( ident, vis, attrs, - kind: ast::ItemKind::Mac(mac_placeholder()), + kind: ast::ItemKind::MacCall(mac_placeholder()), tokens: None, })]), AstFragmentKind::TraitItems => AstFragment::TraitItems(smallvec![P(ast::AssocItem { @@ -56,7 +56,7 @@ pub fn placeholder( ident, vis, attrs, - kind: ast::AssocItemKind::Macro(mac_placeholder()), + kind: ast::AssocItemKind::MacCall(mac_placeholder()), tokens: None, })]), AstFragmentKind::ImplItems => AstFragment::ImplItems(smallvec![P(ast::AssocItem { @@ -65,7 +65,7 @@ pub fn placeholder( ident, vis, attrs, - kind: ast::AssocItemKind::Macro(mac_placeholder()), + kind: ast::AssocItemKind::MacCall(mac_placeholder()), tokens: None, })]), AstFragmentKind::ForeignItems => { @@ -75,19 +75,21 @@ pub fn placeholder( ident, vis, attrs, - kind: ast::ForeignItemKind::Macro(mac_placeholder()), + kind: ast::ForeignItemKind::MacCall(mac_placeholder()), tokens: None, })]) } - AstFragmentKind::Pat => { - AstFragment::Pat(P(ast::Pat { id, span, kind: ast::PatKind::Mac(mac_placeholder()) })) - } + AstFragmentKind::Pat => AstFragment::Pat(P(ast::Pat { + id, + span, + kind: ast::PatKind::MacCall(mac_placeholder()), + })), 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![{ 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 { attrs: Default::default(), @@ -239,7 +241,7 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> { fn flat_map_item(&mut self, item: P) -> SmallVec<[P; 1]> { 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], _ => {} } @@ -249,14 +251,14 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> { fn flat_map_trait_item(&mut self, item: P) -> SmallVec<[P; 1]> { 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), } } fn flat_map_impl_item(&mut self, item: P) -> SmallVec<[P; 1]> { 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), } } @@ -266,28 +268,28 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> { item: P, ) -> SmallVec<[P; 1]> { 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), } } fn visit_expr(&mut self, expr: &mut P) { 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), } } fn filter_map_expr(&mut self, expr: P) -> Option> { 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), } } fn flat_map_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> { 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), }; @@ -302,14 +304,14 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> { fn visit_pat(&mut self, pat: &mut P) { 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), } } fn visit_ty(&mut self, ty: &mut P) { 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), } } @@ -328,12 +330,12 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> { fn visit_mod(&mut self, module: &mut ast::Mod) { noop_visit_mod(module, self); 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, }); } - fn visit_mac(&mut self, _mac: &mut ast::Mac) { + fn visit_mac(&mut self, _mac: &mut ast::MacCall) { // Do nothing. } } diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index 7866ddbd4ccd8..df05bd7c5117d 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -780,7 +780,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> { // in general the pretty printer processes unexpanded code, so // 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) } } diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index e1680015beadd..c97dbb955ba85 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -778,7 +778,7 @@ impl EarlyLintPass for UnusedDocComment { ast::StmtKind::Empty | ast::StmtKind::Semi(_) | ast::StmtKind::Expr(_) - | ast::StmtKind::Mac(_) => return, + | ast::StmtKind::MacCall(_) => return, }; 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) { 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()); } fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: ast::Ident) { diff --git a/src/librustc_lint/early.rs b/src/librustc_lint/early.rs index ff6e9e000b097..a5da960d8881c 100644 --- a/src/librustc_lint/early.rs +++ b/src/librustc_lint/early.rs @@ -249,7 +249,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T> 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 // that (a) the librustc_ast visitor ought to be doing this as // part of `walk_mac`, and (b) we should be calling diff --git a/src/librustc_lint/passes.rs b/src/librustc_lint/passes.rs index 813be2a032f8b..ace154714458e 100644 --- a/src/librustc_lint/passes.rs +++ b/src/librustc_lint/passes.rs @@ -198,7 +198,7 @@ macro_rules! early_lint_methods { fn check_path(a: &ast::Path, b: ast::NodeId); fn check_attribute(a: &ast::Attribute); 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 /// as `#[allow(...)]`. Called with *all* the attributes of that node. diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 02f04b2345932..e88600239e765 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -538,7 +538,7 @@ impl EarlyLintPass for UnusedParens { // Do not lint on `(..)` as that will result in the other arms being useless. Paren(_) // 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. TupleStruct(_, ps) | Tuple(ps) | Slice(ps) | Or(ps) => for p in ps { self.check_unused_parens_pat(cx, p, false, false); diff --git a/src/librustc_parse/config.rs b/src/librustc_parse/config.rs index 17b9e78e5df46..86533a1662854 100644 --- a/src/librustc_parse/config.rs +++ b/src/librustc_parse/config.rs @@ -519,7 +519,7 @@ impl<'a> MutVisitor for StripUnconfigured<'a> { 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). // Interpolated AST will get configured once the surrounding tokens are parsed. } diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs index 18ddd23588e48..54eb995e7f0f0 100644 --- a/src/librustc_parse/parser/expr.rs +++ b/src/librustc_parse/parser/expr.rs @@ -4,8 +4,8 @@ use super::{BlockMode, Parser, PathStyle, Restrictions, TokenType}; use super::{SemiColonMode, SeqSep, TokenExpectType}; 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::{AnonConst, BinOp, BinOpKind, FnDecl, FnRetTy, Mac, Param, Ty, TyKind, UnOp}; +use rustc_ast::ast::{self, AttrStyle, AttrVec, CaptureBy, Field, Ident, Lit, UnOp, DUMMY_NODE_ID}; +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::ptr::P; use rustc_ast::token::{self, Token, TokenKind}; @@ -1006,12 +1006,12 @@ impl<'a> Parser<'a> { // `!`, as an operator, is prefix, so we know this isn't that. let (hi, kind) = if self.eat(&token::Not) { // MACRO INVOCATION expression - let mac = Mac { + let mac = MacCall { path, args: self.parse_mac_args()?, 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)) { if let Some(expr) = self.maybe_parse_struct_expr(lo, &path, &attrs) { return expr; diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs index 01dd2f885ff5e..c55dd827dae10 100644 --- a/src/librustc_parse/parser/item.rs +++ b/src/librustc_parse/parser/item.rs @@ -4,16 +4,12 @@ use super::{FollowedByType, Parser, PathStyle}; 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::{ - Async, Const, Defaultness, IsAuto, PathSegment, Unsafe, UseTree, UseTreeKind, -}; -use rustc_ast::ast::{ - BindingMode, Block, FnDecl, FnSig, Mac, MacArgs, MacDelimiter, Param, SelfKind, -}; +use rustc_ast::ast::{BindingMode, Block, FnDecl, FnSig, MacArgs, MacCall, MacDelimiter, Param}; +use rustc_ast::ast::{Const, Defaultness, IsAuto, PathSegment, Unsafe, UseTree, UseTreeKind}; 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::token; use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree}; @@ -220,7 +216,7 @@ impl<'a> Parser<'a> { return Ok(None); } else if macros_allowed && self.token.is_path_start() { // MACRO INVOCATION ITEM - (Ident::invalid(), ItemKind::Mac(self.parse_item_macro(vis)?)) + (Ident::invalid(), ItemKind::MacCall(self.parse_item_macro(vis)?)) } else { return Ok(None); }; @@ -339,13 +335,13 @@ impl<'a> Parser<'a> { } /// 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` self.expect(&token::Not)?; // `!` let args = self.parse_mac_args()?; // `( .. )` or `[ .. ]` (followed by `;`), or `{ .. }`. self.eat_semi_for_macro_if_needed(&args); 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. diff --git a/src/librustc_parse/parser/pat.rs b/src/librustc_parse/parser/pat.rs index 45d1aacdd3cc6..9c7dfd0c22c1e 100644 --- a/src/librustc_parse/parser/pat.rs +++ b/src/librustc_parse/parser/pat.rs @@ -1,9 +1,7 @@ use super::{Parser, PathStyle}; use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole}; -use rustc_ast::ast::{ - self, AttrVec, Attribute, FieldPat, Mac, Pat, PatKind, RangeEnd, RangeSyntax, -}; -use rustc_ast::ast::{BindingMode, Expr, ExprKind, Ident, Mutability, Path, QSelf}; +use rustc_ast::ast::{self, AttrVec, Attribute, FieldPat, MacCall, Pat, PatKind, RangeEnd}; +use rustc_ast::ast::{BindingMode, Expr, ExprKind, Ident, Mutability, Path, QSelf, RangeSyntax}; use rustc_ast::mut_visit::{noop_visit_mac, noop_visit_pat, MutVisitor}; use rustc_ast::ptr::P; use rustc_ast::token; @@ -540,7 +538,7 @@ impl<'a> Parser<'a> { fn make_all_value_bindings_mutable(pat: &mut P) -> bool { struct AddMut(bool); 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); } @@ -597,8 +595,8 @@ impl<'a> Parser<'a> { fn parse_pat_mac_invoc(&mut self, path: Path) -> PResult<'a, PatKind> { self.bump(); let args = self.parse_mac_args()?; - let mac = Mac { path, args, prior_type_ascription: self.last_type_ascription }; - Ok(PatKind::Mac(mac)) + let mac = MacCall { path, args, prior_type_ascription: self.last_type_ascription }; + Ok(PatKind::MacCall(mac)) } fn fatal_unexpected_non_pat( diff --git a/src/librustc_parse/parser/stmt.rs b/src/librustc_parse/parser/stmt.rs index 3864ec3aaa163..287217483d818 100644 --- a/src/librustc_parse/parser/stmt.rs +++ b/src/librustc_parse/parser/stmt.rs @@ -7,7 +7,7 @@ use crate::maybe_whole; use crate::DirectoryOwnership; 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::ptr::P; use rustc_ast::token::{self, TokenKind}; @@ -112,14 +112,14 @@ impl<'a> Parser<'a> { let style = 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 { - StmtKind::Mac(P((mac, style, attrs))) + StmtKind::MacCall(P((mac, style, attrs))) } else { // 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.parse_dot_or_call_expr_with(e, lo, attrs)?; let e = self.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(e))?; diff --git a/src/librustc_parse/parser/ty.rs b/src/librustc_parse/parser/ty.rs index 3d2b0c014ac49..48c90d60e5f5d 100644 --- a/src/librustc_parse/parser/ty.rs +++ b/src/librustc_parse/parser/ty.rs @@ -3,10 +3,8 @@ use super::{Parser, PathStyle, TokenType}; 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::{ - GenericBound, GenericBounds, PolyTraitRef, TraitBoundModifier, TraitObjectSyntax, -}; -use rustc_ast::ast::{Mac, Mutability}; +use rustc_ast::ast::{GenericBound, GenericBounds, MacCall, Mutability}; +use rustc_ast::ast::{PolyTraitRef, TraitBoundModifier, TraitObjectSyntax}; use rustc_ast::ptr::P; use rustc_ast::token::{self, Token, TokenKind}; use rustc_errors::{pluralize, struct_span_err, Applicability, PResult}; @@ -351,7 +349,7 @@ impl<'a> Parser<'a> { let path = self.parse_path(PathStyle::Type)?; if self.eat(&token::Not) { // Macro invocation in type position - Ok(TyKind::Mac(Mac { + Ok(TyKind::MacCall(MacCall { path, args: self.parse_mac_args()?, prior_type_ascription: self.last_type_ascription, diff --git a/src/librustc_passes/hir_stats.rs b/src/librustc_passes/hir_stats.rs index c819809041f28..65b3b7efdc0f1 100644 --- a/src/librustc_passes/hir_stats.rs +++ b/src/librustc_passes/hir_stats.rs @@ -336,8 +336,8 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> { ast_visit::walk_lifetime(self, lifetime) } - fn visit_mac(&mut self, mac: &'v ast::Mac) { - self.record("Mac", Id::None, mac); + fn visit_mac(&mut self, mac: &'v ast::MacCall) { + self.record("MacCall", Id::None, mac); } fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v ast::PathSegment) { diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 43cfe05ac230e..5ec113b37418a 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -303,7 +303,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { fn block_needs_anonymous_module(&mut self, block: &Block) -> bool { // If any statements are items, we need to create an anonymous module block.stmts.iter().any(|statement| match statement.kind { - StmtKind::Item(_) | StmtKind::Mac(_) => true, + StmtKind::Item(_) | StmtKind::MacCall(_) => true, _ => false, }) } @@ -816,7 +816,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { // These items do not add names to modules. ItemKind::Impl { .. } | ItemKind::ForeignMod(..) | ItemKind::GlobalAsm(..) => {} - ItemKind::MacroDef(..) | ItemKind::Mac(_) => unreachable!(), + ItemKind::MacroDef(..) | ItemKind::MacCall(_) => unreachable!(), } } @@ -832,7 +832,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { ForeignItemKind::TyAlias(..) => { (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 expansion = self.parent_scope.expansion; @@ -1180,9 +1180,9 @@ macro_rules! method { } impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { - method!(visit_expr: ast::Expr, ast::ExprKind::Mac, walk_expr); - method!(visit_pat: ast::Pat, ast::PatKind::Mac, walk_pat); - method!(visit_ty: ast::Ty, ast::TyKind::Mac, walk_ty); + method!(visit_expr: ast::Expr, ast::ExprKind::MacCall, walk_expr); + method!(visit_pat: ast::Pat, ast::PatKind::MacCall, walk_pat); + method!(visit_ty: ast::Ty, ast::TyKind::MacCall, walk_ty); fn visit_item(&mut self, item: &'b Item) { let macro_use = match item.kind { @@ -1190,7 +1190,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { self.parent_scope.legacy = self.define_macro(item); return; } - ItemKind::Mac(..) => { + ItemKind::MacCall(..) => { self.parent_scope.legacy = self.visit_invoc(item.id); return; } @@ -1208,7 +1208,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { } 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); } else { visit::walk_stmt(self, stmt); @@ -1216,7 +1216,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { } 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); return; } @@ -1237,7 +1237,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { fn visit_assoc_item(&mut self, item: &'b AssocItem, ctxt: AssocCtxt) { let parent = self.parent_scope.module; - if let AssocItemKind::Macro(_) = item.kind { + if let AssocItemKind::MacCall(_) = item.kind { self.visit_invoc(item.id); return; } @@ -1259,7 +1259,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { (Res::Def(DefKind::Method, item_def_id), ValueNS) } 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; @@ -1272,7 +1272,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { fn visit_token(&mut self, t: Token) { if let token::Interpolated(nt) = t.kind { 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); } } diff --git a/src/librustc_resolve/def_collector.rs b/src/librustc_resolve/def_collector.rs index 0d276e6861452..c55090d7e931e 100644 --- a/src/librustc_resolve/def_collector.rs +++ b/src/librustc_resolve/def_collector.rs @@ -132,7 +132,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { DefPathData::ValueNs(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::Use(..) => { 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) { - if let ForeignItemKind::Macro(_) = foreign_item.kind { + if let ForeignItemKind::MacCall(_) = foreign_item.kind { 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::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); @@ -239,7 +239,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { fn visit_pat(&mut self, pat: &'a Pat) { 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), } } @@ -251,7 +251,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { fn visit_expr(&mut self, expr: &'a Expr) { 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, ..) => { // Async closures desugar to closures inside of closures, so // 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) { 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, _) => { 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) { match stmt.kind { - StmtKind::Mac(..) => self.visit_macro_invoc(stmt.id), + StmtKind::MacCall(..) => self.visit_macro_invoc(stmt.id), _ => visit::walk_stmt(self, stmt), } } @@ -293,7 +293,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> { fn visit_token(&mut self, t: Token) { if let token::Interpolated(nt) = t.kind { 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); } } diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index a3554ea2ee0a3..cb5548aad34a7 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -449,7 +449,7 @@ impl<'a, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> { visit::walk_foreign_item(this, foreign_item); }); } - ForeignItemKind::Macro(..) => { + ForeignItemKind::MacCall(..) => { visit::walk_foreign_item(self, foreign_item); } } @@ -852,7 +852,7 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { AssocItemKind::TyAlias(_, generics, _, _) => { walk_assoc_item(this, generics, item); } - AssocItemKind::Macro(_) => { + AssocItemKind::MacCall(_) => { 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 } - 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!") } } diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 72c962749c8be..cf4a9e947be94 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -1067,7 +1067,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> { self.visit_ty(default_ty) } } - ast::AssocItemKind::Macro(_) => {} + ast::AssocItemKind::MacCall(_) => {} } } @@ -1103,7 +1103,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> { // trait. 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); self.process_generic_params(ty_params, &qualname, item.id); } - Mac(_) => (), + MacCall(_) => (), _ => 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); } } - ast::ForeignItemKind::Macro(..) => {} + ast::ForeignItemKind::MacCall(..) => {} } } } diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 9da8ee548fddd..c4d8244eb68fd 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -174,7 +174,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> { } // FIXME(plietar): needs a new DefKind in rls-data ast::ForeignItemKind::TyAlias(..) => None, - ast::ForeignItemKind::Macro(..) => None, + ast::ForeignItemKind::MacCall(..) => None, } } diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index a295e1637aa4c..f3bc3cc88b036 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -308,7 +308,7 @@ impl Sig for ast::Ty { | ast::TyKind::Infer | ast::TyKind::Err | 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"), // FIXME should implement this (e.g., pub use). 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: text, defs: defs, refs: vec![] }) } - ast::ForeignItemKind::Macro(..) => Err("macro"), + ast::ForeignItemKind::MacCall(..) => Err("macro"), } } } diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index b63dbbf80d864..9ad0f85ec9419 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -449,7 +449,7 @@ pub fn make_test( } if !found_macro { - if let ast::ItemKind::Mac(..) = item.kind { + if let ast::ItemKind::MacCall(..) = item.kind { found_macro = true; } }