- fn gate_proc_macro_expansion(&self, span: Span, fragment: &AstFragment) {
- if self.cx.ecfg.proc_macro_hygiene() {
- return
- }
-
- fragment.visit_with(&mut DisallowMacros {
- span,
- parse_sess: self.cx.parse_sess,
- });
-
- struct DisallowMacros<'a> {
- span: Span,
- parse_sess: &'a ParseSess,
- }
-
- impl<'ast, 'a> Visitor<'ast> for DisallowMacros<'a> {
- fn visit_item(&mut self, i: &'ast ast::Item) {
- if let ast::ItemKind::MacroDef(_) = i.kind {
- emit_feature_err(
- self.parse_sess,
- sym::proc_macro_hygiene,
- self.span,
- GateIssue::Language,
- "procedural macros cannot expand to macro definitions",
- );
- }
- visit::walk_item(self, i);
- }
-
- fn visit_mac(&mut self, _mac: &'ast ast::Mac) {
- // ...
- }
- }
- }
-