pub struct MacroDef {
pub body: P<MacArgs>,
/// `true` if macro was defined with `macro_rules`.
- pub legacy: bool,
+ pub macro_rules: bool,
}
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy, Hash, Eq, PartialEq)]
}
pub fn noop_visit_macro_def<T: MutVisitor>(macro_def: &mut MacroDef, vis: &mut T) {
- let MacroDef { body, legacy: _ } = macro_def;
+ let MacroDef { body, macro_rules: _ } = macro_def;
visit_mac_args(body, vis);
}
let mut vis = self.lower_visibility(&i.vis, None);
let attrs = self.lower_attrs(&i.attrs);
- if let ItemKind::MacroDef(MacroDef { ref body, legacy }) = i.kind {
- if !legacy || attr::contains_name(&i.attrs, sym::macro_export) {
+ if let ItemKind::MacroDef(MacroDef { ref body, macro_rules }) = i.kind {
+ if !macro_rules || attr::contains_name(&i.attrs, sym::macro_export) {
let hir_id = self.lower_node_id(i.id);
let body = P(self.lower_mac_args(body));
self.exported_macros.push(hir::MacroDef {
attrs,
hir_id,
span: i.span,
- ast: MacroDef { body, legacy },
+ ast: MacroDef { body, macro_rules },
});
} else {
self.non_exported_macro_attrs.extend(attrs.iter().cloned());
gate_feature_post!(&self, trait_alias, i.span, "trait aliases are experimental");
}
- ast::ItemKind::MacroDef(ast::MacroDef { legacy: false, .. }) => {
+ ast::ItemKind::MacroDef(ast::MacroDef { macro_rules: false, .. }) => {
let msg = "`macro` is experimental";
gate_feature_post!(&self, decl_macro, i.span, msg);
}
}
}
ast::ItemKind::MacroDef(ref macro_def) => {
- let (kw, has_bang) = if macro_def.legacy {
+ let (kw, has_bang) = if macro_def.macro_rules {
("macro_rules", true)
} else {
self.print_visibility(&item.vis);
let tt_spec = ast::Ident::new(sym::tt, def.span);
// Parse the macro_rules! invocation
- let (is_legacy, body) = match &def.kind {
- ast::ItemKind::MacroDef(macro_def) => (macro_def.legacy, macro_def.body.inner_tokens()),
+ let (macro_rules, body) = match &def.kind {
+ ast::ItemKind::MacroDef(def) => (def.macro_rules, def.body.inner_tokens()),
_ => unreachable!(),
};
mbe::TokenTree::MetaVarDecl(def.span, rhs_nm, tt_spec),
],
separator: Some(Token::new(
- if is_legacy { token::Semi } else { token::Comma },
+ if macro_rules { token::Semi } else { token::Comma },
def.span,
)),
kleene: mbe::KleeneToken::new(mbe::KleeneOp::OneOrMore, def.span),
DelimSpan::dummy(),
Lrc::new(mbe::SequenceRepetition {
tts: vec![mbe::TokenTree::token(
- if is_legacy { token::Semi } else { token::Comma },
+ if macro_rules { token::Semi } else { token::Comma },
def.span,
)],
separator: None,
// that is not lint-checked and trigger the "failed to process buffered lint here" bug.
valid &= macro_check::check_meta_variables(sess, ast::CRATE_NODE_ID, def.span, &lhses, &rhses);
- let (transparency, transparency_error) = attr::find_transparency(&def.attrs, is_legacy);
+ let (transparency, transparency_error) = attr::find_transparency(&def.attrs, macro_rules);
match transparency_error {
Some(TransparencyError::UnknownTransparency(value, span)) => {
diag.span_err(span, &format!("unknown macro transparency: `{}`", value))
};
self.sess.gated_spans.gate(sym::decl_macro, lo.to(self.prev_token.span));
- Ok((ident, ItemKind::MacroDef(ast::MacroDef { body, legacy: false })))
+ Ok((ident, ItemKind::MacroDef(ast::MacroDef { body, macro_rules: false })))
}
/// Is this unambiguously the start of a `macro_rules! foo` item defnition?
self.eat_semi_for_macro_if_needed(&body);
self.complain_if_pub_macro(vis, true);
- Ok((ident, ItemKind::MacroDef(ast::MacroDef { body, legacy: true })))
+ Ok((ident, ItemKind::MacroDef(ast::MacroDef { body, macro_rules: true })))
}
/// Item macro invocations or `macro_rules!` definitions need inherited visibility.
}
fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef<'tcx>) {
- if attr::find_transparency(&md.attrs, md.ast.legacy).0 != Transparency::Opaque {
+ if attr::find_transparency(&md.attrs, md.ast.macro_rules).0 != Transparency::Opaque {
self.update(md.hir_id, Some(AccessLevel::Public));
return;
}
fn define_macro(&mut self, item: &ast::Item) -> LegacyScope<'a> {
let parent_scope = self.parent_scope;
let expansion = parent_scope.expansion;
- let (ext, ident, span, is_legacy) = match &item.kind {
+ let (ext, ident, span, macro_rules) = match &item.kind {
ItemKind::MacroDef(def) => {
let ext = Lrc::new(self.r.compile_macro(item, self.r.session.edition()));
- (ext, item.ident, item.span, def.legacy)
+ (ext, item.ident, item.span, def.macro_rules)
}
ItemKind::Fn(..) => match Self::proc_macro_stub(item) {
Some((macro_kind, ident, span)) => {
self.r.macro_map.insert(def_id, ext);
self.r.local_macro_def_scopes.insert(item.id, parent_scope.module);
- if is_legacy {
+ if macro_rules {
let ident = ident.modern();
self.r.macro_names.insert(ident);
let is_macro_export = attr::contains_name(&item.attrs, sym::macro_export);