Skip to content

Commit fed840b

Browse files
committed
Unimpl WalkItemKind for AssocItemKind and remove AssocCtxt from walk
1 parent 59729b4 commit fed840b

File tree

2 files changed

+66
-77
lines changed

2 files changed

+66
-77
lines changed

compiler/rustc_ast/src/visitors.rs

Lines changed: 65 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,6 @@ pub mod visit {
11641164
fn walk<'a, V: Visitor<'a>>(
11651165
&'a self,
11661166
item: &'a Item<Self>,
1167-
ctxt: AssocCtxt,
11681167
visitor: &mut V,
11691168
) -> V::Result;
11701169
}
@@ -1175,7 +1174,6 @@ pub mod visit {
11751174
fn walk<'a, V: Visitor<'a>>(
11761175
&'a self,
11771176
item: &'a Item<Self>,
1178-
_ctxt: AssocCtxt,
11791177
visitor: &mut V,
11801178
) -> V::Result {
11811179
let Item { id, span, vis, ident, .. } = item;
@@ -1287,7 +1285,12 @@ pub mod visit {
12871285
visitor: &mut V,
12881286
item: &'a Item<impl WalkItemKind>,
12891287
) -> V::Result {
1290-
walk_assoc_item(visitor, item, AssocCtxt::Trait /*ignored*/)
1288+
let &Item { id: _, span: _, ident, ref vis, ref attrs, ref kind, tokens: _ } = item;
1289+
walk_list!(visitor, visit_attribute, attrs);
1290+
try_visit!(visitor.visit_vis(vis));
1291+
try_visit!(visitor.visit_ident(ident));
1292+
try_visit!(kind.walk(item, visitor));
1293+
V::Result::output()
12911294
}
12921295

12931296
pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) -> V::Result {
@@ -1361,7 +1364,6 @@ pub mod visit {
13611364
fn walk<'a, V: Visitor<'a>>(
13621365
&'a self,
13631366
item: &'a Item<Self>,
1364-
_ctxt: AssocCtxt,
13651367
visitor: &mut V,
13661368
) -> V::Result {
13671369
let &Item { id, span, ident, ref vis, .. } = item;
@@ -1459,85 +1461,72 @@ pub mod visit {
14591461
V::Result::output()
14601462
}
14611463

1462-
impl WalkItemKind for AssocItemKind {
1463-
fn walk<'a, V: Visitor<'a>>(
1464-
&'a self,
1465-
item: &'a Item<Self>,
1466-
ctxt: AssocCtxt,
1467-
visitor: &mut V,
1468-
) -> V::Result {
1469-
let &Item { id, span, ident, ref vis, .. } = item;
1470-
match self {
1471-
AssocItemKind::Const(box ConstItem { defaultness: _, generics, ty, expr }) => {
1472-
try_visit!(visitor.visit_generics(generics));
1473-
try_visit!(visitor.visit_ty(ty));
1474-
visit_opt!(visitor, visit_expr, expr);
1475-
}
1476-
AssocItemKind::Fn(box Fn { defaultness: _, generics, sig, body }) => {
1477-
let kind =
1478-
FnKind::Fn(FnCtxt::Assoc(ctxt), ident, sig, vis, generics, body.as_deref());
1479-
try_visit!(visitor.visit_fn(kind, span, id));
1480-
}
1481-
AssocItemKind::Type(box TyAlias {
1482-
generics,
1483-
bounds,
1484-
ty,
1485-
defaultness: _,
1486-
where_clauses: _,
1487-
}) => {
1488-
try_visit!(visitor.visit_generics(generics));
1489-
walk_list!(visitor, visit_param_bound, bounds, BoundKind::Bound);
1490-
visit_opt!(visitor, visit_ty, ty);
1491-
}
1492-
AssocItemKind::MacCall(mac) => {
1493-
try_visit!(visitor.visit_mac_call(mac));
1494-
}
1495-
AssocItemKind::Delegation(box Delegation {
1496-
id,
1497-
qself,
1498-
path,
1499-
rename,
1500-
body,
1501-
from_glob: _,
1502-
}) => {
1503-
try_visit!(visitor.visit_qself(qself));
1504-
try_visit!(visitor.visit_path(path, *id));
1505-
visit_opt!(visitor, visit_ident, *rename);
1506-
visit_opt!(visitor, visit_block, body);
1507-
}
1508-
AssocItemKind::DelegationMac(box DelegationMac {
1509-
qself,
1510-
prefix,
1511-
suffixes,
1512-
body,
1513-
}) => {
1514-
try_visit!(visitor.visit_qself(qself));
1515-
try_visit!(visitor.visit_path(prefix, id));
1516-
if let Some(suffixes) = suffixes {
1517-
for (ident, rename) in suffixes {
1518-
visitor.visit_ident(*ident);
1519-
if let Some(rename) = rename {
1520-
visitor.visit_ident(*rename);
1521-
}
1522-
}
1523-
}
1524-
visit_opt!(visitor, visit_block, body);
1525-
}
1526-
}
1527-
V::Result::output()
1528-
}
1529-
}
1530-
15311464
pub fn walk_assoc_item<'a, V: Visitor<'a>>(
15321465
visitor: &mut V,
1533-
item: &'a Item<impl WalkItemKind>,
1466+
item: &'a Item<AssocItemKind>,
15341467
ctxt: AssocCtxt,
15351468
) -> V::Result {
1536-
let &Item { id: _, span: _, ident, ref vis, ref attrs, ref kind, tokens: _ } = item;
1469+
let &Item { id, span, ident, ref vis, ref attrs, ref kind, tokens: _ } = item;
15371470
walk_list!(visitor, visit_attribute, attrs);
15381471
try_visit!(visitor.visit_vis(vis));
15391472
try_visit!(visitor.visit_ident(ident));
1540-
try_visit!(kind.walk(item, ctxt, visitor));
1473+
match kind {
1474+
AssocItemKind::Const(box ConstItem { defaultness: _, generics, ty, expr }) => {
1475+
try_visit!(visitor.visit_generics(generics));
1476+
try_visit!(visitor.visit_ty(ty));
1477+
visit_opt!(visitor, visit_expr, expr);
1478+
}
1479+
AssocItemKind::Fn(box Fn { defaultness: _, generics, sig, body }) => {
1480+
let kind =
1481+
FnKind::Fn(FnCtxt::Assoc(ctxt), ident, sig, vis, generics, body.as_deref());
1482+
try_visit!(visitor.visit_fn(kind, span, id));
1483+
}
1484+
AssocItemKind::Type(box TyAlias {
1485+
generics,
1486+
bounds,
1487+
ty,
1488+
defaultness: _,
1489+
where_clauses: _,
1490+
}) => {
1491+
try_visit!(visitor.visit_generics(generics));
1492+
walk_list!(visitor, visit_param_bound, bounds, BoundKind::Bound);
1493+
visit_opt!(visitor, visit_ty, ty);
1494+
}
1495+
AssocItemKind::MacCall(mac) => {
1496+
try_visit!(visitor.visit_mac_call(mac));
1497+
}
1498+
AssocItemKind::Delegation(box Delegation {
1499+
id,
1500+
qself,
1501+
path,
1502+
rename,
1503+
body,
1504+
from_glob: _,
1505+
}) => {
1506+
try_visit!(visitor.visit_qself(qself));
1507+
try_visit!(visitor.visit_path(path, *id));
1508+
visit_opt!(visitor, visit_ident, *rename);
1509+
visit_opt!(visitor, visit_block, body);
1510+
}
1511+
AssocItemKind::DelegationMac(box DelegationMac {
1512+
qself,
1513+
prefix,
1514+
suffixes,
1515+
body,
1516+
}) => {
1517+
try_visit!(visitor.visit_qself(qself));
1518+
try_visit!(visitor.visit_path(prefix, id));
1519+
if let Some(suffixes) = suffixes {
1520+
for (ident, rename) in suffixes {
1521+
visitor.visit_ident(*ident);
1522+
if let Some(rename) = rename {
1523+
visitor.visit_ident(*rename);
1524+
}
1525+
}
1526+
}
1527+
visit_opt!(visitor, visit_block, body);
1528+
}
1529+
}
15411530
V::Result::output()
15421531
}
15431532

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> {
13291329
// This way they can use `macro_rules` defined later.
13301330
self.visit_vis(&item.vis);
13311331
self.visit_ident(item.ident);
1332-
item.kind.walk(item, AssocCtxt::Trait, self);
1332+
item.kind.walk(item, self);
13331333
visit::walk_list!(self, visit_attribute, &item.attrs);
13341334
}
13351335
_ => visit::walk_item(self, item),

0 commit comments

Comments
 (0)