Skip to content

Commit 65bf483

Browse files
committed
ast/hir: MacroDef::legacy -> MacroDef::macro_rules
1 parent e0f5df0 commit 65bf483

File tree

9 files changed

+18
-18
lines changed

9 files changed

+18
-18
lines changed

src/librustc_ast/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@ impl MacDelimiter {
14501450
pub struct MacroDef {
14511451
pub body: P<MacArgs>,
14521452
/// `true` if macro was defined with `macro_rules`.
1453-
pub legacy: bool,
1453+
pub macro_rules: bool,
14541454
}
14551455

14561456
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy, Hash, Eq, PartialEq)]

src/librustc_ast/mut_visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ pub fn noop_visit_mac<T: MutVisitor>(mac: &mut MacCall, vis: &mut T) {
591591
}
592592

593593
pub fn noop_visit_macro_def<T: MutVisitor>(macro_def: &mut MacroDef, vis: &mut T) {
594-
let MacroDef { body, legacy: _ } = macro_def;
594+
let MacroDef { body, macro_rules: _ } = macro_def;
595595
visit_mac_args(body, vis);
596596
}
597597

src/librustc_ast_lowering/item.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
220220
let mut vis = self.lower_visibility(&i.vis, None);
221221
let attrs = self.lower_attrs(&i.attrs);
222222

223-
if let ItemKind::MacroDef(MacroDef { ref body, legacy }) = i.kind {
224-
if !legacy || attr::contains_name(&i.attrs, sym::macro_export) {
223+
if let ItemKind::MacroDef(MacroDef { ref body, macro_rules }) = i.kind {
224+
if !macro_rules || attr::contains_name(&i.attrs, sym::macro_export) {
225225
let hir_id = self.lower_node_id(i.id);
226226
let body = P(self.lower_mac_args(body));
227227
self.exported_macros.push(hir::MacroDef {
@@ -230,7 +230,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
230230
attrs,
231231
hir_id,
232232
span: i.span,
233-
ast: MacroDef { body, legacy },
233+
ast: MacroDef { body, macro_rules },
234234
});
235235
} else {
236236
self.non_exported_macro_attrs.extend(attrs.iter().cloned());

src/librustc_ast_passes/feature_gate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
366366
gate_feature_post!(&self, trait_alias, i.span, "trait aliases are experimental");
367367
}
368368

369-
ast::ItemKind::MacroDef(ast::MacroDef { legacy: false, .. }) => {
369+
ast::ItemKind::MacroDef(ast::MacroDef { macro_rules: false, .. }) => {
370370
let msg = "`macro` is experimental";
371371
gate_feature_post!(&self, decl_macro, i.span, msg);
372372
}

src/librustc_ast_pretty/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ impl<'a> State<'a> {
12381238
}
12391239
}
12401240
ast::ItemKind::MacroDef(ref macro_def) => {
1241-
let (kw, has_bang) = if macro_def.legacy {
1241+
let (kw, has_bang) = if macro_def.macro_rules {
12421242
("macro_rules", true)
12431243
} else {
12441244
self.print_visibility(&item.vis);

src/librustc_expand/mbe/macro_rules.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ pub fn compile_declarative_macro(
350350
let tt_spec = ast::Ident::new(sym::tt, def.span);
351351

352352
// Parse the macro_rules! invocation
353-
let (is_legacy, body) = match &def.kind {
354-
ast::ItemKind::MacroDef(macro_def) => (macro_def.legacy, macro_def.body.inner_tokens()),
353+
let (macro_rules, body) = match &def.kind {
354+
ast::ItemKind::MacroDef(def) => (def.macro_rules, def.body.inner_tokens()),
355355
_ => unreachable!(),
356356
};
357357

@@ -370,7 +370,7 @@ pub fn compile_declarative_macro(
370370
mbe::TokenTree::MetaVarDecl(def.span, rhs_nm, tt_spec),
371371
],
372372
separator: Some(Token::new(
373-
if is_legacy { token::Semi } else { token::Comma },
373+
if macro_rules { token::Semi } else { token::Comma },
374374
def.span,
375375
)),
376376
kleene: mbe::KleeneToken::new(mbe::KleeneOp::OneOrMore, def.span),
@@ -382,7 +382,7 @@ pub fn compile_declarative_macro(
382382
DelimSpan::dummy(),
383383
Lrc::new(mbe::SequenceRepetition {
384384
tts: vec![mbe::TokenTree::token(
385-
if is_legacy { token::Semi } else { token::Comma },
385+
if macro_rules { token::Semi } else { token::Comma },
386386
def.span,
387387
)],
388388
separator: None,
@@ -456,7 +456,7 @@ pub fn compile_declarative_macro(
456456
// that is not lint-checked and trigger the "failed to process buffered lint here" bug.
457457
valid &= macro_check::check_meta_variables(sess, ast::CRATE_NODE_ID, def.span, &lhses, &rhses);
458458

459-
let (transparency, transparency_error) = attr::find_transparency(&def.attrs, is_legacy);
459+
let (transparency, transparency_error) = attr::find_transparency(&def.attrs, macro_rules);
460460
match transparency_error {
461461
Some(TransparencyError::UnknownTransparency(value, span)) => {
462462
diag.span_err(span, &format!("unknown macro transparency: `{}`", value))

src/librustc_parse/parser/item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ impl<'a> Parser<'a> {
12601260
};
12611261

12621262
self.sess.gated_spans.gate(sym::decl_macro, lo.to(self.prev_token.span));
1263-
Ok((ident, ItemKind::MacroDef(ast::MacroDef { body, legacy: false })))
1263+
Ok((ident, ItemKind::MacroDef(ast::MacroDef { body, macro_rules: false })))
12641264
}
12651265

12661266
/// Is this unambiguously the start of a `macro_rules! foo` item defnition?
@@ -1280,7 +1280,7 @@ impl<'a> Parser<'a> {
12801280
self.eat_semi_for_macro_if_needed(&body);
12811281
self.complain_if_pub_macro(vis, true);
12821282

1283-
Ok((ident, ItemKind::MacroDef(ast::MacroDef { body, legacy: true })))
1283+
Ok((ident, ItemKind::MacroDef(ast::MacroDef { body, macro_rules: true })))
12841284
}
12851285

12861286
/// Item macro invocations or `macro_rules!` definitions need inherited visibility.

src/librustc_privacy/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
920920
}
921921

922922
fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef<'tcx>) {
923-
if attr::find_transparency(&md.attrs, md.ast.legacy).0 != Transparency::Opaque {
923+
if attr::find_transparency(&md.attrs, md.ast.macro_rules).0 != Transparency::Opaque {
924924
self.update(md.hir_id, Some(AccessLevel::Public));
925925
return;
926926
}

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,10 +1098,10 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
10981098
fn define_macro(&mut self, item: &ast::Item) -> LegacyScope<'a> {
10991099
let parent_scope = self.parent_scope;
11001100
let expansion = parent_scope.expansion;
1101-
let (ext, ident, span, is_legacy) = match &item.kind {
1101+
let (ext, ident, span, macro_rules) = match &item.kind {
11021102
ItemKind::MacroDef(def) => {
11031103
let ext = Lrc::new(self.r.compile_macro(item, self.r.session.edition()));
1104-
(ext, item.ident, item.span, def.legacy)
1104+
(ext, item.ident, item.span, def.macro_rules)
11051105
}
11061106
ItemKind::Fn(..) => match Self::proc_macro_stub(item) {
11071107
Some((macro_kind, ident, span)) => {
@@ -1118,7 +1118,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
11181118
self.r.macro_map.insert(def_id, ext);
11191119
self.r.local_macro_def_scopes.insert(item.id, parent_scope.module);
11201120

1121-
if is_legacy {
1121+
if macro_rules {
11221122
let ident = ident.modern();
11231123
self.r.macro_names.insert(ident);
11241124
let is_macro_export = attr::contains_name(&item.attrs, sym::macro_export);

0 commit comments

Comments
 (0)