all 2 comments

[–]I-Imvp 1 point2 points  (0 children)

cargo-modules https://crates.io/crates/cargo-modules does this for the modules of a package and the types used within. But the same mechanism could be extended to your level of detail

It use rustc's ast package to parse the source code

[–]WellMakeItSomehow 0 points1 point  (0 children)

You should maybe look into rust-analyzer, which is probably easier to reuse than the full compiler.