Skip to content

Commit 27becb2

Browse files
committed
ast: Mac/Macro -> MacCall
1 parent 2b0cfa5 commit 27becb2

File tree

43 files changed

+195
-192
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

+195
-192
lines changed

src/librustc_ast/ast.rs

+20-20
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
@@ -512,7 +512,7 @@ impl Pat {
512512
TyKind::Path(None, Path::from_ident(*ident))
513513
}
514514
PatKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()),
515-
PatKind::Mac(mac) => TyKind::Mac(mac.clone()),
515+
PatKind::MacCall(mac) => TyKind::MacCall(mac.clone()),
516516
// `&mut? P` can be reinterpreted as `&mut? T` where `T` is `P` reparsed as a type.
517517
PatKind::Ref(pat, mutbl) => {
518518
pat.to_ty().map(|ty| TyKind::Rptr(None, MutTy { ty, mutbl: *mutbl }))?
@@ -566,7 +566,7 @@ impl Pat {
566566
| PatKind::Range(..)
567567
| PatKind::Ident(..)
568568
| PatKind::Path(..)
569-
| PatKind::Mac(_) => {}
569+
| PatKind::MacCall(_) => {}
570570
}
571571
}
572572

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

683683
/// A macro pattern; pre-expansion.
684-
Mac(Mac),
684+
MacCall(MacCall),
685685
}
686686

687687
#[derive(
@@ -880,9 +880,9 @@ impl Stmt {
880880
pub fn add_trailing_semicolon(mut self) -> Self {
881881
self.kind = match self.kind {
882882
StmtKind::Expr(expr) => StmtKind::Semi(expr),
883-
StmtKind::Mac(mac) => {
884-
StmtKind::Mac(mac.map(|(mac, _style, attrs)| (mac, MacStmtStyle::Semicolon, attrs)))
885-
}
883+
StmtKind::MacCall(mac) => StmtKind::MacCall(
884+
mac.map(|(mac, _style, attrs)| (mac, MacStmtStyle::Semicolon, attrs)),
885+
),
886886
kind => kind,
887887
};
888888
self
@@ -916,7 +916,7 @@ pub enum StmtKind {
916916
/// Just a trailing semi-colon.
917917
Empty,
918918
/// Macro.
919-
Mac(P<(Mac, MacStmtStyle, AttrVec)>),
919+
MacCall(P<(MacCall, MacStmtStyle, AttrVec)>),
920920
}
921921

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

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

@@ -1126,7 +1126,7 @@ impl Expr {
11261126
ExprKind::Continue(..) => ExprPrecedence::Continue,
11271127
ExprKind::Ret(..) => ExprPrecedence::Ret,
11281128
ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm,
1129-
ExprKind::Mac(..) => ExprPrecedence::Mac,
1129+
ExprKind::MacCall(..) => ExprPrecedence::Mac,
11301130
ExprKind::Struct(..) => ExprPrecedence::Struct,
11311131
ExprKind::Repeat(..) => ExprPrecedence::Repeat,
11321132
ExprKind::Paren(..) => ExprPrecedence::Paren,
@@ -1258,7 +1258,7 @@ pub enum ExprKind {
12581258
InlineAsm(P<InlineAsm>),
12591259

12601260
/// A macro invocation; pre-expansion.
1261-
Mac(Mac),
1261+
MacCall(MacCall),
12621262

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

1353-
impl Mac {
1353+
impl MacCall {
13541354
pub fn span(&self) -> Span {
13551355
self.path.span.to(self.args.span().unwrap_or(self.path.span))
13561356
}
@@ -1880,7 +1880,7 @@ pub enum TyKind {
18801880
/// Inferred type of a `self` or `&self` argument in a method.
18811881
ImplicitSelf,
18821882
/// A macro in the type position.
1883-
Mac(Mac),
1883+
MacCall(MacCall),
18841884
/// Placeholder for a kind that has failed to be defined.
18851885
Err,
18861886
/// Placeholder for a `va_list`.
@@ -2573,7 +2573,7 @@ pub enum ItemKind {
25732573
/// A macro invocation.
25742574
///
25752575
/// E.g., `foo!(..)`.
2576-
Mac(Mac),
2576+
MacCall(MacCall),
25772577

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

@@ -2605,7 +2605,7 @@ impl ItemKind {
26052605
ItemKind::Union(..) => "union",
26062606
ItemKind::Trait(..) => "trait",
26072607
ItemKind::TraitAlias(..) => "trait alias",
2608-
ItemKind::Mac(..) => "item macro invocation",
2608+
ItemKind::MacCall(..) => "item macro invocation",
26092609
ItemKind::MacroDef(..) => "macro definition",
26102610
ItemKind::Impl { .. } => "implementation",
26112611
}
@@ -2658,14 +2658,14 @@ pub enum AssocItemKind {
26582658
/// A type.
26592659
TyAlias(Defaultness, Generics, GenericBounds, Option<P<Ty>>),
26602660
/// A macro expanding to items.
2661-
Macro(Mac),
2661+
MacCall(MacCall),
26622662
}
26632663

26642664
impl AssocItemKind {
26652665
pub fn defaultness(&self) -> Defaultness {
26662666
match *self {
26672667
Self::Const(def, ..) | Self::Fn(def, ..) | Self::TyAlias(def, ..) => def,
2668-
Self::Macro(..) | Self::Static(..) => Defaultness::Final,
2668+
Self::MacCall(..) | Self::Static(..) => Defaultness::Final,
26692669
}
26702670
}
26712671
}
@@ -2677,7 +2677,7 @@ impl IntoItemKind for AssocItemKind {
26772677
AssocItemKind::Static(a, b, c) => ItemKind::Static(a, b, c),
26782678
AssocItemKind::Fn(a, b, c, d) => ItemKind::Fn(a, b, c, d),
26792679
AssocItemKind::TyAlias(a, b, c, d) => ItemKind::TyAlias(a, b, c, d),
2680-
AssocItemKind::Macro(a) => ItemKind::Mac(a),
2680+
AssocItemKind::MacCall(a) => ItemKind::MacCall(a),
26812681
}
26822682
}
26832683
}

src/librustc_ast/attr/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ impl HasAttrs for StmtKind {
676676
StmtKind::Local(ref local) => local.attrs(),
677677
StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => expr.attrs(),
678678
StmtKind::Empty | StmtKind::Item(..) => &[],
679-
StmtKind::Mac(ref mac) => {
679+
StmtKind::MacCall(ref mac) => {
680680
let (_, _, ref attrs) = **mac;
681681
attrs.attrs()
682682
}
@@ -688,7 +688,7 @@ impl HasAttrs for StmtKind {
688688
StmtKind::Local(local) => local.visit_attrs(f),
689689
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.visit_attrs(f),
690690
StmtKind::Empty | StmtKind::Item(..) => {}
691-
StmtKind::Mac(mac) => {
691+
StmtKind::MacCall(mac) => {
692692
let (_mac, _style, attrs) = mac.deref_mut();
693693
attrs.visit_attrs(f);
694694
}

src/librustc_ast/mut_visit.rs

+10-10
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
}
@@ -968,7 +968,7 @@ pub fn walk_nested_item(
968968
visit_bounds(bounds, visitor);
969969
visit_opt(ty, |ty| visitor.visit_ty(ty));
970970
}
971-
AssocItemKind::Macro(mac) => visitor.visit_mac(mac),
971+
AssocItemKind::MacCall(mac) => visitor.visit_mac(mac),
972972
}
973973
visitor.visit_span(span);
974974
}
@@ -1073,7 +1073,7 @@ pub fn noop_visit_pat<T: MutVisitor>(pat: &mut P<Pat>, vis: &mut T) {
10731073
visit_vec(elems, |elem| vis.visit_pat(elem))
10741074
}
10751075
PatKind::Paren(inner) => vis.visit_pat(inner),
1076-
PatKind::Mac(mac) => vis.visit_mac(mac),
1076+
PatKind::MacCall(mac) => vis.visit_mac(mac),
10771077
}
10781078
vis.visit_span(span);
10791079
}
@@ -1210,7 +1210,7 @@ pub fn noop_visit_expr<T: MutVisitor>(Expr { kind, id, span, attrs }: &mut Expr,
12101210
}
12111211
visit_vec(inputs, |(_c, expr)| vis.visit_expr(expr));
12121212
}
1213-
ExprKind::Mac(mac) => vis.visit_mac(mac),
1213+
ExprKind::MacCall(mac) => vis.visit_mac(mac),
12141214
ExprKind::Struct(path, fields, expr) => {
12151215
vis.visit_path(path);
12161216
fields.flat_map_in_place(|field| vis.flat_map_field(field));
@@ -1266,11 +1266,11 @@ pub fn noop_flat_map_stmt_kind<T: MutVisitor>(
12661266
StmtKind::Expr(expr) => vis.filter_map_expr(expr).into_iter().map(StmtKind::Expr).collect(),
12671267
StmtKind::Semi(expr) => vis.filter_map_expr(expr).into_iter().map(StmtKind::Semi).collect(),
12681268
StmtKind::Empty => smallvec![StmtKind::Empty],
1269-
StmtKind::Mac(mut mac) => {
1269+
StmtKind::MacCall(mut mac) => {
12701270
let (mac_, _semi, attrs) = mac.deref_mut();
12711271
vis.visit_mac(mac_);
12721272
visit_thin_attrs(attrs, vis);
1273-
smallvec![StmtKind::Mac(mac)]
1273+
smallvec![StmtKind::MacCall(mac)]
12741274
}
12751275
}
12761276
}

src/librustc_ast/visit.rs

+8-8
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

@@ -642,7 +642,7 @@ fn walk_nested_item<'a, V: Visitor<'a>>(
642642
walk_list!(visitor, visit_param_bound, bounds);
643643
walk_list!(visitor, visit_ty, ty);
644644
}
645-
AssocItemKind::Macro(mac) => {
645+
AssocItemKind::MacCall(mac) => {
646646
visitor.visit_mac(mac);
647647
}
648648
}
@@ -671,7 +671,7 @@ pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) {
671671
StmtKind::Item(ref item) => visitor.visit_item(item),
672672
StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => visitor.visit_expr(expr),
673673
StmtKind::Empty => {}
674-
StmtKind::Mac(ref mac) => {
674+
StmtKind::MacCall(ref mac) => {
675675
let (ref mac, _, ref attrs) = **mac;
676676
visitor.visit_mac(mac);
677677
for attr in attrs.iter() {
@@ -681,7 +681,7 @@ pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) {
681681
}
682682
}
683683

684-
pub fn walk_mac<'a, V: Visitor<'a>>(visitor: &mut V, mac: &'a Mac) {
684+
pub fn walk_mac<'a, V: Visitor<'a>>(visitor: &mut V, mac: &'a MacCall) {
685685
visitor.visit_path(&mac.path, DUMMY_NODE_ID);
686686
}
687687

@@ -803,7 +803,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
803803
ExprKind::Ret(ref optional_expression) => {
804804
walk_list!(visitor, visit_expr, optional_expression);
805805
}
806-
ExprKind::Mac(ref mac) => visitor.visit_mac(mac),
806+
ExprKind::MacCall(ref mac) => visitor.visit_mac(mac),
807807
ExprKind::Paren(ref subexpression) => visitor.visit_expr(subexpression),
808808
ExprKind::InlineAsm(ref ia) => {
809809
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 {

src/librustc_ast_lowering/item.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
426426
self.lower_generics(generics, ImplTraitContext::disallowed()),
427427
self.lower_param_bounds(bounds, ImplTraitContext::disallowed()),
428428
),
429-
ItemKind::MacroDef(..) | ItemKind::Mac(..) => {
429+
ItemKind::MacroDef(..) | ItemKind::MacCall(..) => {
430430
bug!("`TyMac` should have been expanded by now")
431431
}
432432
}
@@ -681,7 +681,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
681681
hir::ForeignItemKind::Static(ty, Mutability::Not)
682682
}
683683
ForeignItemKind::TyAlias(..) => hir::ForeignItemKind::Type,
684-
ForeignItemKind::Macro(_) => panic!("macro shouldn't exist here"),
684+
ForeignItemKind::MacCall(_) => panic!("macro shouldn't exist here"),
685685
},
686686
vis: self.lower_visibility(&i.vis, None),
687687
span: i.span,
@@ -785,7 +785,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
785785

786786
(generics, kind)
787787
}
788-
AssocItemKind::Macro(..) => bug!("macro item shouldn't exist at this point"),
788+
AssocItemKind::MacCall(..) => bug!("macro item shouldn't exist at this point"),
789789
};
790790

791791
hir::TraitItem {
@@ -808,7 +808,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
808808
AssocItemKind::Fn(_, sig, _, default) => {
809809
(hir::AssocItemKind::Method { has_self: sig.decl.has_self() }, default.is_some())
810810
}
811-
AssocItemKind::Macro(..) => unimplemented!(),
811+
AssocItemKind::MacCall(..) => unimplemented!(),
812812
};
813813
let id = hir::TraitItemId { hir_id: self.lower_node_id(i.id) };
814814
let defaultness = hir::Defaultness::Default { has_value: has_default };
@@ -867,7 +867,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
867867
};
868868
(generics, kind)
869869
}
870-
AssocItemKind::Macro(..) => bug!("`TyMac` should have been expanded by now"),
870+
AssocItemKind::MacCall(..) => bug!("`TyMac` should have been expanded by now"),
871871
};
872872

873873
hir::ImplItem {
@@ -903,7 +903,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
903903
AssocItemKind::Fn(_, sig, ..) => {
904904
hir::AssocItemKind::Method { has_self: sig.decl.has_self() }
905905
}
906-
AssocItemKind::Macro(..) => unimplemented!(),
906+
AssocItemKind::MacCall(..) => unimplemented!(),
907907
},
908908
}
909909

0 commit comments

Comments
 (0)