]>
git.proxmox.com Git - rustc.git/blob - src/librustc_ast_passes/node_count.rs
1 // Simply gives a rought count of the number of nodes in an AST.
4 use rustc_ast
::visit
::*;
7 pub struct NodeCounter
{
12 pub fn new() -> NodeCounter
{
13 NodeCounter { count: 0 }
17 impl<'ast
> Visitor
<'ast
> for NodeCounter
{
18 fn visit_ident(&mut self, ident
: Ident
) {
20 walk_ident(self, ident
);
22 fn visit_mod(&mut self, m
: &Mod
, _s
: Span
, _a
: &[Attribute
], _n
: NodeId
) {
26 fn visit_foreign_item(&mut self, i
: &ForeignItem
) {
28 walk_foreign_item(self, i
)
30 fn visit_item(&mut self, i
: &Item
) {
34 fn visit_local(&mut self, l
: &Local
) {
38 fn visit_block(&mut self, b
: &Block
) {
42 fn visit_stmt(&mut self, s
: &Stmt
) {
46 fn visit_arm(&mut self, a
: &Arm
) {
50 fn visit_pat(&mut self, p
: &Pat
) {
54 fn visit_expr(&mut self, ex
: &Expr
) {
58 fn visit_ty(&mut self, t
: &Ty
) {
62 fn visit_generic_param(&mut self, param
: &GenericParam
) {
64 walk_generic_param(self, param
)
66 fn visit_generics(&mut self, g
: &Generics
) {
68 walk_generics(self, g
)
70 fn visit_fn(&mut self, fk
: FnKind
<'_
>, s
: Span
, _
: NodeId
) {
74 fn visit_assoc_item(&mut self, ti
: &AssocItem
, ctxt
: AssocCtxt
) {
76 walk_assoc_item(self, ti
, ctxt
);
78 fn visit_trait_ref(&mut self, t
: &TraitRef
) {
80 walk_trait_ref(self, t
)
82 fn visit_param_bound(&mut self, bounds
: &GenericBound
) {
84 walk_param_bound(self, bounds
)
86 fn visit_poly_trait_ref(&mut self, t
: &PolyTraitRef
, m
: &TraitBoundModifier
) {
88 walk_poly_trait_ref(self, t
, m
)
90 fn visit_variant_data(&mut self, s
: &VariantData
) {
92 walk_struct_def(self, s
)
94 fn visit_struct_field(&mut self, s
: &StructField
) {
96 walk_struct_field(self, s
)
100 enum_definition
: &EnumDef
,
106 walk_enum_def(self, enum_definition
, generics
, item_id
)
108 fn visit_variant(&mut self, v
: &Variant
) {
110 walk_variant(self, v
)
112 fn visit_lifetime(&mut self, lifetime
: &Lifetime
) {
114 walk_lifetime(self, lifetime
)
116 fn visit_mac(&mut self, _mac
: &MacCall
) {
120 fn visit_path(&mut self, path
: &Path
, _id
: NodeId
) {
122 walk_path(self, path
)
124 fn visit_use_tree(&mut self, use_tree
: &UseTree
, id
: NodeId
, _nested
: bool
) {
126 walk_use_tree(self, use_tree
, id
)
128 fn visit_generic_args(&mut self, path_span
: Span
, generic_args
: &GenericArgs
) {
130 walk_generic_args(self, path_span
, generic_args
)
132 fn visit_assoc_ty_constraint(&mut self, constraint
: &AssocTyConstraint
) {
134 walk_assoc_ty_constraint(self, constraint
)
136 fn visit_attribute(&mut self, _attr
: &Attribute
) {