Skip to content

Commit e809e02

Browse files
committed
ast: Mac/Macro -> MacCall
1 parent 23de827 commit e809e02

File tree

43 files changed

+200
-197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+200
-197
lines changed

src/librustc_ast/ast.rs

+24-24
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//! - [`Generics`], [`GenericParam`], [`WhereClause`]: Metadata associated with generic parameters.
1515
//! - [`EnumDef`] and [`Variant`]: Enum declaration.
1616
//! - [`Lit`] and [`LitKind`]: Literal expressions.
17-
//! - [`MacroDef`], [`MacStmtStyle`], [`Mac`], [`MacDelimeter`]: Macro definition and invocation.
17+
//! - [`MacroDef`], [`MacStmtStyle`], [`MacCall`], [`MacDelimeter`]: Macro definition and invocation.
1818
//! - [`Attribute`]: Metadata associated with item.
1919
//! - [`UnOp`], [`UnOpKind`], [`BinOp`], [`BinOpKind`]: Unary and binary operators.
2020
@@ -513,7 +513,7 @@ impl Pat {
513513
TyKind::Path(None, Path::from_ident(*ident))
514514
}
515515
PatKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()),
516-
PatKind::Mac(mac) => TyKind::Mac(mac.clone()),
516+
PatKind::MacCall(mac) => TyKind::MacCall(mac.clone()),
517517
// `&mut? P` can be reinterpreted as `&mut? T` where `T` is `P` reparsed as a type.
518518
PatKind::Ref(pat, mutbl) => {
519519
pat.to_ty().map(|ty| TyKind::Rptr(None, MutTy { ty, mutbl: *mutbl }))?
@@ -567,7 +567,7 @@ impl Pat {
567567
| PatKind::Range(..)
568568
| PatKind::Ident(..)
569569
| PatKind::Path(..)
570-
| PatKind::Mac(_) => {}
570+
| PatKind::MacCall(_) => {}
571571
}
572572
}
573573

@@ -682,7 +682,7 @@ pub enum PatKind {
682682
Paren(P<Pat>),
683683

684684
/// A macro pattern; pre-expansion.
685-
Mac(Mac),
685+
MacCall(MacCall),
686686
}
687687

688688
#[derive(
@@ -881,9 +881,9 @@ impl Stmt {
881881
pub fn add_trailing_semicolon(mut self) -> Self {
882882
self.kind = match self.kind {
883883
StmtKind::Expr(expr) => StmtKind::Semi(expr),
884-
StmtKind::Mac(mac) => {
885-
StmtKind::Mac(mac.map(|(mac, _style, attrs)| (mac, MacStmtStyle::Semicolon, attrs)))
886-
}
884+
StmtKind::MacCall(mac) => StmtKind::MacCall(
885+
mac.map(|(mac, _style, attrs)| (mac, MacStmtStyle::Semicolon, attrs)),
886+
),
887887
kind => kind,
888888
};
889889
self
@@ -917,7 +917,7 @@ pub enum StmtKind {
917917
/// Just a trailing semi-colon.
918918
Empty,
919919
/// Macro.
920-
Mac(P<(Mac, MacStmtStyle, AttrVec)>),
920+
MacCall(P<(MacCall, MacStmtStyle, AttrVec)>),
921921
}
922922

923923
#[derive(Clone, Copy, PartialEq, RustcEncodable, RustcDecodable, Debug)]
@@ -1057,7 +1057,7 @@ impl Expr {
10571057
let kind = match &self.kind {
10581058
// Trivial conversions.
10591059
ExprKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()),
1060-
ExprKind::Mac(mac) => TyKind::Mac(mac.clone()),
1060+
ExprKind::MacCall(mac) => TyKind::MacCall(mac.clone()),
10611061

10621062
ExprKind::Paren(expr) => expr.to_ty().map(TyKind::Paren)?,
10631063

@@ -1127,7 +1127,7 @@ impl Expr {
11271127
ExprKind::Continue(..) => ExprPrecedence::Continue,
11281128
ExprKind::Ret(..) => ExprPrecedence::Ret,
11291129
ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm,
1130-
ExprKind::Mac(..) => ExprPrecedence::Mac,
1130+
ExprKind::MacCall(..) => ExprPrecedence::Mac,
11311131
ExprKind::Struct(..) => ExprPrecedence::Struct,
11321132
ExprKind::Repeat(..) => ExprPrecedence::Repeat,
11331133
ExprKind::Paren(..) => ExprPrecedence::Paren,
@@ -1259,7 +1259,7 @@ pub enum ExprKind {
12591259
InlineAsm(P<InlineAsm>),
12601260

12611261
/// A macro invocation; pre-expansion.
1262-
Mac(Mac),
1262+
MacCall(MacCall),
12631263

12641264
/// A struct literal expression.
12651265
///
@@ -1345,13 +1345,13 @@ pub enum Movability {
13451345
/// Represents a macro invocation. The `path` indicates which macro
13461346
/// is being invoked, and the `args` are arguments passed to it.
13471347
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
1348-
pub struct Mac {
1348+
pub struct MacCall {
13491349
pub path: Path,
13501350
pub args: P<MacArgs>,
13511351
pub prior_type_ascription: Option<(Span, bool)>,
13521352
}
13531353

1354-
impl Mac {
1354+
impl MacCall {
13551355
pub fn span(&self) -> Span {
13561356
self.path.span.to(self.args.span().unwrap_or(self.path.span))
13571357
}
@@ -1881,7 +1881,7 @@ pub enum TyKind {
18811881
/// Inferred type of a `self` or `&self` argument in a method.
18821882
ImplicitSelf,
18831883
/// A macro in the type position.
1884-
Mac(Mac),
1884+
MacCall(MacCall),
18851885
/// Placeholder for a kind that has failed to be defined.
18861886
Err,
18871887
/// Placeholder for a `va_list`.
@@ -2574,7 +2574,7 @@ pub enum ItemKind {
25742574
/// A macro invocation.
25752575
///
25762576
/// E.g., `foo!(..)`.
2577-
Mac(Mac),
2577+
MacCall(MacCall),
25782578

25792579
/// A macro definition.
25802580
MacroDef(MacroDef),
@@ -2586,7 +2586,7 @@ impl ItemKind {
25862586
match self {
25872587
Use(..) | Static(..) | Const(..) | Fn(..) | Mod(..) | GlobalAsm(..) | TyAlias(..)
25882588
| Struct(..) | Union(..) | Trait(..) | TraitAlias(..) | MacroDef(..) => "a",
2589-
ExternCrate(..) | ForeignMod(..) | Mac(..) | Enum(..) | Impl { .. } => "an",
2589+
ExternCrate(..) | ForeignMod(..) | MacCall(..) | Enum(..) | Impl { .. } => "an",
25902590
}
25912591
}
25922592

@@ -2606,7 +2606,7 @@ impl ItemKind {
26062606
ItemKind::Union(..) => "union",
26072607
ItemKind::Trait(..) => "trait",
26082608
ItemKind::TraitAlias(..) => "trait alias",
2609-
ItemKind::Mac(..) => "item macro invocation",
2609+
ItemKind::MacCall(..) => "item macro invocation",
26102610
ItemKind::MacroDef(..) => "macro definition",
26112611
ItemKind::Impl { .. } => "implementation",
26122612
}
@@ -2648,14 +2648,14 @@ pub enum AssocItemKind {
26482648
/// An associated type.
26492649
TyAlias(Defaultness, Generics, GenericBounds, Option<P<Ty>>),
26502650
/// A macro expanding to associated items.
2651-
Macro(Mac),
2651+
MacCall(MacCall),
26522652
}
26532653

26542654
impl AssocItemKind {
26552655
pub fn defaultness(&self) -> Defaultness {
26562656
match *self {
26572657
Self::Const(def, ..) | Self::Fn(def, ..) | Self::TyAlias(def, ..) => def,
2658-
Self::Macro(..) => Defaultness::Final,
2658+
Self::MacCall(..) => Defaultness::Final,
26592659
}
26602660
}
26612661
}
@@ -2666,7 +2666,7 @@ impl From<AssocItemKind> for ItemKind {
26662666
AssocItemKind::Const(a, b, c) => ItemKind::Const(a, b, c),
26672667
AssocItemKind::Fn(a, b, c, d) => ItemKind::Fn(a, b, c, d),
26682668
AssocItemKind::TyAlias(a, b, c, d) => ItemKind::TyAlias(a, b, c, d),
2669-
AssocItemKind::Macro(a) => ItemKind::Mac(a),
2669+
AssocItemKind::MacCall(a) => ItemKind::MacCall(a),
26702670
}
26712671
}
26722672
}
@@ -2679,7 +2679,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
26792679
ItemKind::Const(a, b, c) => AssocItemKind::Const(a, b, c),
26802680
ItemKind::Fn(a, b, c, d) => AssocItemKind::Fn(a, b, c, d),
26812681
ItemKind::TyAlias(a, b, c, d) => AssocItemKind::TyAlias(a, b, c, d),
2682-
ItemKind::Mac(a) => AssocItemKind::Macro(a),
2682+
ItemKind::MacCall(a) => AssocItemKind::MacCall(a),
26832683
_ => return Err(item_kind),
26842684
})
26852685
}
@@ -2695,7 +2695,7 @@ pub enum ForeignItemKind {
26952695
/// A foreign type.
26962696
TyAlias(Defaultness, Generics, GenericBounds, Option<P<Ty>>),
26972697
/// A macro expanding to foreign items.
2698-
Macro(Mac),
2698+
MacCall(MacCall),
26992699
}
27002700

27012701
impl From<ForeignItemKind> for ItemKind {
@@ -2704,7 +2704,7 @@ impl From<ForeignItemKind> for ItemKind {
27042704
ForeignItemKind::Static(a, b, c) => ItemKind::Static(a, b, c),
27052705
ForeignItemKind::Fn(a, b, c, d) => ItemKind::Fn(a, b, c, d),
27062706
ForeignItemKind::TyAlias(a, b, c, d) => ItemKind::TyAlias(a, b, c, d),
2707-
ForeignItemKind::Macro(a) => ItemKind::Mac(a),
2707+
ForeignItemKind::MacCall(a) => ItemKind::MacCall(a),
27082708
}
27092709
}
27102710
}
@@ -2717,7 +2717,7 @@ impl TryFrom<ItemKind> for ForeignItemKind {
27172717
ItemKind::Static(a, b, c) => ForeignItemKind::Static(a, b, c),
27182718
ItemKind::Fn(a, b, c, d) => ForeignItemKind::Fn(a, b, c, d),
27192719
ItemKind::TyAlias(a, b, c, d) => ForeignItemKind::TyAlias(a, b, c, d),
2720-
ItemKind::Mac(a) => ForeignItemKind::Macro(a),
2720+
ItemKind::MacCall(a) => ForeignItemKind::MacCall(a),
27212721
_ => return Err(item_kind),
27222722
})
27232723
}

src/librustc_ast/attr/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ impl HasAttrs for StmtKind {
679679
StmtKind::Local(ref local) => local.attrs(),
680680
StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => expr.attrs(),
681681
StmtKind::Empty | StmtKind::Item(..) => &[],
682-
StmtKind::Mac(ref mac) => {
682+
StmtKind::MacCall(ref mac) => {
683683
let (_, _, ref attrs) = **mac;
684684
attrs.attrs()
685685
}
@@ -691,7 +691,7 @@ impl HasAttrs for StmtKind {
691691
StmtKind::Local(local) => local.visit_attrs(f),
692692
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.visit_attrs(f),
693693
StmtKind::Empty | StmtKind::Item(..) => {}
694-
StmtKind::Mac(mac) => {
694+
StmtKind::MacCall(mac) => {
695695
let (_mac, _style, attrs) = mac.deref_mut();
696696
attrs.visit_attrs(f);
697697
}

src/librustc_ast/mut_visit.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ pub trait MutVisitor: Sized {
202202
noop_visit_local(l, self);
203203
}
204204

205-
fn visit_mac(&mut self, _mac: &mut Mac) {
205+
fn visit_mac(&mut self, _mac: &mut MacCall) {
206206
panic!("visit_mac disabled by default");
207207
// N.B., see note about macros above. If you really want a visitor that
208208
// 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) {
482482
vis.visit_id(id);
483483
visit_vec(bounds, |bound| vis.visit_param_bound(bound));
484484
}
485-
TyKind::Mac(mac) => vis.visit_mac(mac),
485+
TyKind::MacCall(mac) => vis.visit_mac(mac),
486486
}
487487
vis.visit_span(span);
488488
}
@@ -584,8 +584,8 @@ pub fn noop_visit_attribute<T: MutVisitor>(attr: &mut Attribute, vis: &mut T) {
584584
vis.visit_span(span);
585585
}
586586

587-
pub fn noop_visit_mac<T: MutVisitor>(mac: &mut Mac, vis: &mut T) {
588-
let Mac { path, args, prior_type_ascription: _ } = mac;
587+
pub fn noop_visit_mac<T: MutVisitor>(mac: &mut MacCall, vis: &mut T) {
588+
let MacCall { path, args, prior_type_ascription: _ } = mac;
589589
vis.visit_path(path);
590590
visit_mac_args(args, vis);
591591
}
@@ -926,7 +926,7 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) {
926926
vis.visit_generics(generics);
927927
visit_bounds(bounds, vis);
928928
}
929-
ItemKind::Mac(m) => vis.visit_mac(m),
929+
ItemKind::MacCall(m) => vis.visit_mac(m),
930930
ItemKind::MacroDef(def) => vis.visit_macro_def(def),
931931
}
932932
}
@@ -955,7 +955,7 @@ pub fn noop_flat_map_assoc_item<T: MutVisitor>(
955955
visit_bounds(bounds, visitor);
956956
visit_opt(ty, |ty| visitor.visit_ty(ty));
957957
}
958-
AssocItemKind::Macro(mac) => visitor.visit_mac(mac),
958+
AssocItemKind::MacCall(mac) => visitor.visit_mac(mac),
959959
}
960960
visitor.visit_span(span);
961961
smallvec![item]
@@ -1043,7 +1043,7 @@ pub fn noop_flat_map_foreign_item<T: MutVisitor>(
10431043
visit_bounds(bounds, visitor);
10441044
visit_opt(ty, |ty| visitor.visit_ty(ty));
10451045
}
1046-
ForeignItemKind::Macro(mac) => visitor.visit_mac(mac),
1046+
ForeignItemKind::MacCall(mac) => visitor.visit_mac(mac),
10471047
}
10481048
visitor.visit_span(span);
10491049
smallvec![item]
@@ -1082,7 +1082,7 @@ pub fn noop_visit_pat<T: MutVisitor>(pat: &mut P<Pat>, vis: &mut T) {
10821082
visit_vec(elems, |elem| vis.visit_pat(elem))
10831083
}
10841084
PatKind::Paren(inner) => vis.visit_pat(inner),
1085-
PatKind::Mac(mac) => vis.visit_mac(mac),
1085+
PatKind::MacCall(mac) => vis.visit_mac(mac),
10861086
}
10871087
vis.visit_span(span);
10881088
}
@@ -1219,7 +1219,7 @@ pub fn noop_visit_expr<T: MutVisitor>(Expr { kind, id, span, attrs }: &mut Expr,
12191219
}
12201220
visit_vec(inputs, |(_c, expr)| vis.visit_expr(expr));
12211221
}
1222-
ExprKind::Mac(mac) => vis.visit_mac(mac),
1222+
ExprKind::MacCall(mac) => vis.visit_mac(mac),
12231223
ExprKind::Struct(path, fields, expr) => {
12241224
vis.visit_path(path);
12251225
fields.flat_map_in_place(|field| vis.flat_map_field(field));
@@ -1275,11 +1275,11 @@ pub fn noop_flat_map_stmt_kind<T: MutVisitor>(
12751275
StmtKind::Expr(expr) => vis.filter_map_expr(expr).into_iter().map(StmtKind::Expr).collect(),
12761276
StmtKind::Semi(expr) => vis.filter_map_expr(expr).into_iter().map(StmtKind::Semi).collect(),
12771277
StmtKind::Empty => smallvec![StmtKind::Empty],
1278-
StmtKind::Mac(mut mac) => {
1278+
StmtKind::MacCall(mut mac) => {
12791279
let (mac_, _semi, attrs) = mac.deref_mut();
12801280
vis.visit_mac(mac_);
12811281
visit_thin_attrs(attrs, vis);
1282-
smallvec![StmtKind::Mac(mac)]
1282+
smallvec![StmtKind::MacCall(mac)]
12831283
}
12841284
}
12851285
}

src/librustc_ast/visit.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub trait Visitor<'ast>: Sized {
168168
fn visit_lifetime(&mut self, lifetime: &'ast Lifetime) {
169169
walk_lifetime(self, lifetime)
170170
}
171-
fn visit_mac(&mut self, _mac: &'ast Mac) {
171+
fn visit_mac(&mut self, _mac: &'ast MacCall) {
172172
panic!("visit_mac disabled by default");
173173
// N.B., see note about macros above.
174174
// 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) {
350350
visitor.visit_generics(generics);
351351
walk_list!(visitor, visit_param_bound, bounds);
352352
}
353-
ItemKind::Mac(ref mac) => visitor.visit_mac(mac),
353+
ItemKind::MacCall(ref mac) => visitor.visit_mac(mac),
354354
ItemKind::MacroDef(ref ts) => visitor.visit_mac_def(ts, item.id),
355355
}
356356
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) {
418418
}
419419
TyKind::Typeof(ref expression) => visitor.visit_anon_const(expression),
420420
TyKind::Infer | TyKind::ImplicitSelf | TyKind::Err => {}
421-
TyKind::Mac(ref mac) => visitor.visit_mac(mac),
421+
TyKind::MacCall(ref mac) => visitor.visit_mac(mac),
422422
TyKind::Never | TyKind::CVarArgs => {}
423423
}
424424
}
@@ -521,7 +521,7 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) {
521521
PatKind::Tuple(ref elems) | PatKind::Slice(ref elems) | PatKind::Or(ref elems) => {
522522
walk_list!(visitor, visit_pat, elems);
523523
}
524-
PatKind::Mac(ref mac) => visitor.visit_mac(mac),
524+
PatKind::MacCall(ref mac) => visitor.visit_mac(mac),
525525
}
526526
}
527527

@@ -545,7 +545,7 @@ pub fn walk_foreign_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a ForeignI
545545
walk_list!(visitor, visit_param_bound, bounds);
546546
walk_list!(visitor, visit_ty, ty);
547547
}
548-
ForeignItemKind::Macro(mac) => {
548+
ForeignItemKind::MacCall(mac) => {
549549
visitor.visit_mac(mac);
550550
}
551551
}
@@ -650,7 +650,7 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a AssocItem,
650650
walk_list!(visitor, visit_param_bound, bounds);
651651
walk_list!(visitor, visit_ty, ty);
652652
}
653-
AssocItemKind::Macro(mac) => {
653+
AssocItemKind::MacCall(mac) => {
654654
visitor.visit_mac(mac);
655655
}
656656
}
@@ -679,7 +679,7 @@ pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) {
679679
StmtKind::Item(ref item) => visitor.visit_item(item),
680680
StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => visitor.visit_expr(expr),
681681
StmtKind::Empty => {}
682-
StmtKind::Mac(ref mac) => {
682+
StmtKind::MacCall(ref mac) => {
683683
let (ref mac, _, ref attrs) = **mac;
684684
visitor.visit_mac(mac);
685685
for attr in attrs.iter() {
@@ -689,7 +689,7 @@ pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) {
689689
}
690690
}
691691

692-
pub fn walk_mac<'a, V: Visitor<'a>>(visitor: &mut V, mac: &'a Mac) {
692+
pub fn walk_mac<'a, V: Visitor<'a>>(visitor: &mut V, mac: &'a MacCall) {
693693
visitor.visit_path(&mac.path, DUMMY_NODE_ID);
694694
}
695695

@@ -811,7 +811,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
811811
ExprKind::Ret(ref optional_expression) => {
812812
walk_list!(visitor, visit_expr, optional_expression);
813813
}
814-
ExprKind::Mac(ref mac) => visitor.visit_mac(mac),
814+
ExprKind::MacCall(ref mac) => visitor.visit_mac(mac),
815815
ExprKind::Paren(ref subexpression) => visitor.visit_expr(subexpression),
816816
ExprKind::InlineAsm(ref ia) => {
817817
for &(_, ref input) in &ia.inputs {

src/librustc_ast_lowering/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
198198
return self.lower_expr_for(e, pat, head, body, opt_label);
199199
}
200200
ExprKind::Try(ref sub_expr) => self.lower_expr_try(e.span, sub_expr),
201-
ExprKind::Mac(_) => panic!("Shouldn't exist here"),
201+
ExprKind::MacCall(_) => panic!("Shouldn't exist here"),
202202
};
203203

204204
hir::Expr {

0 commit comments

Comments
 (0)