Skip to content

Commit df0610f

Browse files
committed
Unimpl mut WalkItemKind for AssocItemKind
1 parent 3d40732 commit df0610f

File tree

4 files changed

+88
-80
lines changed

4 files changed

+88
-80
lines changed

compiler/rustc_ast/src/visitors.rs

Lines changed: 83 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ macro_rules! mutability_dependent {
7777
fn flat_map_assoc_item(
7878
&mut self,
7979
i: P<AssocItem>,
80-
_ctxt: AssocCtxt,
80+
ctxt: AssocCtxt,
8181
) -> SmallVec<[P<AssocItem>; 1]> {
82-
walk_flat_map_item(self, i)
82+
walk_flat_map_assoc_item(self, i, ctxt)
8383
}
8484

8585
fn visit_coroutine_kind(&mut self, a: &mut CoroutineKind) {
@@ -2409,79 +2409,6 @@ pub mod mut_visit {
24092409
}
24102410
}
24112411

2412-
impl WalkItemKind for AssocItemKind {
2413-
fn walk(item: &mut Item<Self>, visitor: &mut impl MutVisitor) {
2414-
let Item { attrs, id, span, vis, ident, kind, tokens } = item;
2415-
visitor.visit_id(id);
2416-
visit_attrs(visitor, attrs);
2417-
visitor.visit_vis(vis);
2418-
visitor.visit_ident(ident);
2419-
match kind {
2420-
AssocItemKind::Const(item) => {
2421-
visit_const_item(item, visitor);
2422-
}
2423-
AssocItemKind::Fn(box Fn { defaultness, generics, sig, body }) => {
2424-
visit_defaultness(visitor, defaultness);
2425-
visitor.visit_fn(FnKind::Fn(sig, generics, body), *span, *id);
2426-
}
2427-
AssocItemKind::Type(box TyAlias {
2428-
defaultness,
2429-
generics,
2430-
where_clauses,
2431-
bounds,
2432-
ty,
2433-
}) => {
2434-
visit_defaultness(visitor, defaultness);
2435-
visitor.visit_generics(generics);
2436-
visit_bounds(visitor, bounds, BoundKind::Bound);
2437-
visit_opt(ty, |ty| visitor.visit_ty(ty));
2438-
walk_ty_alias_where_clauses(visitor, where_clauses);
2439-
}
2440-
AssocItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
2441-
AssocItemKind::Delegation(box Delegation {
2442-
id,
2443-
qself,
2444-
path,
2445-
rename,
2446-
body,
2447-
from_glob: _,
2448-
}) => {
2449-
visitor.visit_id(id);
2450-
visitor.visit_qself(qself);
2451-
visitor.visit_path(path, *id);
2452-
if let Some(rename) = rename {
2453-
visitor.visit_ident(rename);
2454-
}
2455-
if let Some(body) = body {
2456-
visitor.visit_block(body);
2457-
}
2458-
}
2459-
AssocItemKind::DelegationMac(box DelegationMac {
2460-
qself,
2461-
prefix,
2462-
suffixes,
2463-
body,
2464-
}) => {
2465-
visitor.visit_qself(qself);
2466-
visitor.visit_path(prefix, *id);
2467-
if let Some(suffixes) = suffixes {
2468-
for (ident, rename) in suffixes {
2469-
visitor.visit_ident(ident);
2470-
if let Some(rename) = rename {
2471-
visitor.visit_ident(rename);
2472-
}
2473-
}
2474-
}
2475-
if let Some(body) = body {
2476-
visitor.visit_block(body);
2477-
}
2478-
}
2479-
}
2480-
visit_lazy_tts(visitor, tokens);
2481-
visitor.visit_span(span);
2482-
}
2483-
}
2484-
24852412
fn visit_const_item<T: MutVisitor>(
24862413
ConstItem { defaultness, generics, ty, expr }: &mut ConstItem,
24872414
visitor: &mut T,
@@ -2511,6 +2438,87 @@ pub mod mut_visit {
25112438
smallvec![item]
25122439
}
25132440

2441+
pub fn walk_assoc_item(visitor: &mut impl MutVisitor, item: &mut Item<AssocItemKind>, _ctxt: AssocCtxt) {
2442+
let Item { attrs, id, span, vis, ident, kind, tokens } = item;
2443+
visitor.visit_id(id);
2444+
visit_attrs(visitor, attrs);
2445+
visitor.visit_vis(vis);
2446+
visitor.visit_ident(ident);
2447+
match kind {
2448+
AssocItemKind::Const(item) => {
2449+
visit_const_item(item, visitor);
2450+
}
2451+
AssocItemKind::Fn(box Fn { defaultness, generics, sig, body }) => {
2452+
visit_defaultness(visitor, defaultness);
2453+
visitor.visit_fn(FnKind::Fn(sig, generics, body), *span, *id);
2454+
}
2455+
AssocItemKind::Type(box TyAlias {
2456+
defaultness,
2457+
generics,
2458+
where_clauses,
2459+
bounds,
2460+
ty,
2461+
}) => {
2462+
visit_defaultness(visitor, defaultness);
2463+
visitor.visit_generics(generics);
2464+
visit_bounds(visitor, bounds, BoundKind::Bound);
2465+
visit_opt(ty, |ty| visitor.visit_ty(ty));
2466+
walk_ty_alias_where_clauses(visitor, where_clauses);
2467+
}
2468+
AssocItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
2469+
AssocItemKind::Delegation(box Delegation {
2470+
id,
2471+
qself,
2472+
path,
2473+
rename,
2474+
body,
2475+
from_glob: _,
2476+
}) => {
2477+
visitor.visit_id(id);
2478+
visitor.visit_qself(qself);
2479+
visitor.visit_path(path, *id);
2480+
if let Some(rename) = rename {
2481+
visitor.visit_ident(rename);
2482+
}
2483+
if let Some(body) = body {
2484+
visitor.visit_block(body);
2485+
}
2486+
}
2487+
AssocItemKind::DelegationMac(box DelegationMac {
2488+
qself,
2489+
prefix,
2490+
suffixes,
2491+
body,
2492+
}) => {
2493+
visitor.visit_qself(qself);
2494+
visitor.visit_path(prefix, *id);
2495+
if let Some(suffixes) = suffixes {
2496+
for (ident, rename) in suffixes {
2497+
visitor.visit_ident(ident);
2498+
if let Some(rename) = rename {
2499+
visitor.visit_ident(rename);
2500+
}
2501+
}
2502+
}
2503+
if let Some(body) = body {
2504+
visitor.visit_block(body);
2505+
}
2506+
}
2507+
}
2508+
visit_lazy_tts(visitor, tokens);
2509+
visitor.visit_span(span);
2510+
}
2511+
2512+
pub fn walk_flat_map_assoc_item(
2513+
visitor: &mut impl MutVisitor,
2514+
mut item: P<Item<AssocItemKind>>,
2515+
ctxt: AssocCtxt
2516+
) -> SmallVec<[P<Item<AssocItemKind>>; 1]> {
2517+
walk_assoc_item(visitor, item.deref_mut(), ctxt);
2518+
smallvec![item]
2519+
}
2520+
2521+
25142522
impl WalkItemKind for ForeignItemKind {
25152523
fn walk(item: &mut Item<Self>, visitor: &mut impl MutVisitor) {
25162524
let Item { attrs, id, span, vis, ident, kind, tokens } = item;

compiler/rustc_builtin_macros/src/cfg_eval.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,10 @@ impl MutVisitor for CfgEval<'_> {
247247
fn flat_map_assoc_item(
248248
&mut self,
249249
item: P<ast::AssocItem>,
250-
_ctxt: AssocCtxt,
250+
ctxt: AssocCtxt,
251251
) -> SmallVec<[P<ast::AssocItem>; 1]> {
252252
let item = configure!(self, item);
253-
mut_visit::walk_flat_map_item(self, item)
253+
mut_visit::walk_flat_map_assoc_item(self, item, ctxt)
254254
}
255255

256256
fn flat_map_foreign_item(

compiler/rustc_expand/src/expand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, TraitItemTag>
12941294
fragment.make_trait_items()
12951295
}
12961296
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1297-
walk_flat_map_item(visitor, self.wrapped)
1297+
walk_flat_map_assoc_item(visitor, self.wrapped, AssocCtxt::Trait)
12981298
}
12991299
fn is_mac_call(&self) -> bool {
13001300
matches!(self.wrapped.kind, AssocItemKind::MacCall(..))
@@ -1335,7 +1335,7 @@ impl InvocationCollectorNode for AstNodeWrapper<P<ast::AssocItem>, ImplItemTag>
13351335
fragment.make_impl_items()
13361336
}
13371337
fn walk_flat_map<V: MutVisitor>(self, visitor: &mut V) -> Self::OutputTy {
1338-
walk_flat_map_item(visitor, self.wrapped)
1338+
walk_flat_map_assoc_item(visitor, self.wrapped, AssocCtxt::Impl)
13391339
}
13401340
fn is_mac_call(&self) -> bool {
13411341
matches!(self.wrapped.kind, AssocItemKind::MacCall(..))

compiler/rustc_expand/src/placeholders.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl MutVisitor for PlaceholderExpander {
286286
AssocCtxt::Impl => it.make_impl_items(),
287287
}
288288
}
289-
_ => walk_flat_map_item(self, item),
289+
_ => walk_flat_map_assoc_item(self, item, ctxt),
290290
}
291291
}
292292

0 commit comments

Comments
 (0)