diff --git a/compiler/rustc_ast/src/visitors.rs b/compiler/rustc_ast/src/visitors.rs index 16849bd4ee05b..7b36faa0eca32 100644 --- a/compiler/rustc_ast/src/visitors.rs +++ b/compiler/rustc_ast/src/visitors.rs @@ -202,7 +202,6 @@ macro_rules! make_ast_visitor { make_visit!{CoroutineKind; visit_coroutine_kind, walk_coroutine_kind} make_visit!{FnHeader; visit_fn_header, walk_fn_header} - make_visit!{MacroDef; visit_macro_def, walk_macro_def} make_visit!{MetaItem; visit_meta_item, walk_meta_item} make_visit!{MetaItemInner; visit_meta_list_item, walk_meta_list_item} @@ -297,9 +296,6 @@ macro_rules! make_ast_visitor { fn visit_fn(&mut self, fk: FnKind<'ast>, _: Span, _: NodeId) -> Self::Result { walk_fn(self, fk) } - fn visit_mac_def(&mut self, _mac: &'ast MacroDef, _id: NodeId) -> Self::Result { - Self::Result::output() - } fn visit_fn_header(&mut self, _header: &'ast FnHeader) -> Self::Result { Self::Result::output() } @@ -334,6 +330,7 @@ macro_rules! make_ast_visitor { make_visit!{Lifetime, _ ctxt: LifetimeCtxt; visit_lifetime, walk_lifetime} make_visit!{Local; visit_local, walk_local} make_visit!{MacCall; visit_mac_call, walk_mac_call} + make_visit!{MacroDef, _ id: NodeId; visit_macro_def, walk_macro_def} make_visit!{MutTy; visit_mt, walk_mt} make_visit!{Option>; visit_qself, walk_qself} make_visit!{Param; visit_param, walk_param} @@ -813,6 +810,15 @@ macro_rules! make_ast_visitor { return_result!(V) } + pub fn walk_macro_def<$($lt,)? V: $trait$(<$lt>)?>( + vis: &mut V, + macro_def: ref_t!(MacroDef), + ) -> result!(V) { + let MacroDef { body, macro_rules: _ } = macro_def; + visit_delim_args!(vis, body); + return_result!(V) + } + pub fn walk_mt<$($lt,)? V: $trait$(<$lt>)?>( vis: &mut V, mt: ref_t!(MutTy) @@ -1388,7 +1394,7 @@ pub mod visit { walk_list!(visitor, visit_param_bound, bounds, BoundKind::Bound); } ItemKind::MacCall(mac) => try_visit!(visitor.visit_mac_call(mac)), - ItemKind::MacroDef(ts) => try_visit!(visitor.visit_mac_def(ts, *id)), + ItemKind::MacroDef(ts) => try_visit!(visitor.visit_macro_def(ts, *id)), ItemKind::Delegation(box Delegation { id, qself, @@ -1872,11 +1878,6 @@ pub mod mut_visit { smallvec![variant] } - fn walk_macro_def(vis: &mut T, macro_def: &mut MacroDef) { - let MacroDef { body, macro_rules: _ } = macro_def; - visit_delim_args(vis, body); - } - fn walk_meta_list_item(vis: &mut T, li: &mut MetaItemInner) { match li { MetaItemInner::MetaItem(mi) => vis.visit_meta_item(mi), @@ -2230,7 +2231,7 @@ pub mod mut_visit { visit_bounds(vis, bounds, BoundKind::Bound); } ItemKind::MacCall(m) => vis.visit_mac_call(m), - ItemKind::MacroDef(def) => vis.visit_macro_def(def), + ItemKind::MacroDef(def) => vis.visit_macro_def(def, id), ItemKind::Delegation(box Delegation { id, qself, diff --git a/compiler/rustc_lint/src/early.rs b/compiler/rustc_lint/src/early.rs index 032418453a27c..a140d59210355 100644 --- a/compiler/rustc_lint/src/early.rs +++ b/compiler/rustc_lint/src/early.rs @@ -289,7 +289,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T> lint_callback!(self, check_attribute, attr); } - fn visit_mac_def(&mut self, mac: &'a ast::MacroDef, id: ast::NodeId) { + fn visit_macro_def(&mut self, mac: &'a ast::MacroDef, id: ast::NodeId) { lint_callback!(self, check_mac_def, mac); self.check_id(id); }