Skip to content

Commit

Permalink
improve tracking for structs and fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Noratrieb committed Jan 23, 2023
1 parent 9ce2c89 commit fa0b302
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/passes/privatize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ impl VisitMut for Visitor<'_> {
}
}

fn visit_field_mut(&mut self, field: &mut syn::Field) {
self.current_path.push(field.ident.to_string());
syn::visit_mut::visit_field_mut(self, method);
self.current_path.pop();
}

fn visit_item_struct_mut(&mut self, struct_: &mut syn::ItemStruct) {
self.current_path.push(struct_.ident.to_string());
syn::visit_mut::visit_item_struct_mut(self, method);
self.current_path.pop();
}

tracking!();
}

Expand Down
16 changes: 16 additions & 0 deletions src/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ macro_rules! tracking {
tracking!(visit_impl_item_method_mut);
tracking!(visit_item_impl_mut);
tracking!(visit_item_mod_mut);
tracking!(visit_field_mut);
tracking!(visit_item_struct_mut);
};
(visit_item_fn_mut) => {
fn visit_item_fn_mut(&mut self, func: &mut syn::ItemFn) {
Expand Down Expand Up @@ -248,5 +250,19 @@ macro_rules! tracking {
self.current_path.pop();
}
};
(visit_field_mut) => {
fn visit_field_mut(&mut self, field: &mut syn::Field) {
self.current_path.push(field.ident.to_string());
syn::visit_mut::visit_field_mut(self, method);
self.current_path.pop();
}
};
(visit_item_struct_mut) => {
fn visit_item_struct_mut(&mut self, struct_: &mut syn::ItemStruct) {
self.current_path.push(struct_.ident.to_string());
syn::visit_mut::visit_item_struct_mut(self, method);
self.current_path.pop();
}
};
}
pub(crate) use tracking;

0 comments on commit fa0b302

Please sign in to comment.