How to parse entire crate with proc macros?

Hi everyone,
I want to conduct inventory of my crate code using proc macros and build a dependency tree between structs. I learned that a cargo sub-command and a standalone binary are the same thing, so the only question is how to point it at a crate and make it parse the code?

I only found this analyzer that shows assembly code.

Proc macros are very different to cargo commands and binaries, in particular I don't think proc macros can process entire crates, only sub-module constructs. If you're just looking to parse Rust code, have a look at Syn — Rust proc macro helper // Lib.rs. If you need this to happen when your crate is build you can write a build.rs script.

1 Like

Thanks! I've actually came across syn earlier, it's in some proc macro recipies too, IIRC.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.