then putting the cursor over the c of c.b should jump us to the let c: Foo = ..., and over the b of c.b should jump us to b: ....
This is nothing special, IntelliJ has this already.
My question is: do any existing open source crates do this? I want this data for all identifiers in all *.rs files in all crates. [I want to dump this data, not query it at runtime.]
Is there a simple (and fast) way to acquire this? I want something fast enough I can auto run after every successful cargo build. (so perferably it should not take much longer than a cargo build itself)
Either spin up the server and interact with it like a normal language client or use the ra_ap_hir crate to interact with it like a library.
The ra_ap_hir approach will probably be the most fruitful (you'll probably start at ra_ap_hir::Crate), but it requires more effort and a bit of understanding around rust-analyzer's architecture. I think you should be able to start things by creating your own database type and calling ra_ap_base_db::SourceDatabase::set_crate_graph() to tell it where your crates are.
A nice thing about this approach is you can keep the database instance around between builds (e.g. by making a long-running server that you ping after every build or change) and rust-analyzer's query caching will mean it doesn't need to re-analyze your entire dependency tree.
I hope this does not come off as entitled: Do you have sample code ? It does not have to do what you describe above, it just needs to use ra_ap_hir and does something .
I googled around, and not only could I not find sample code, I could not even find the github repo of ra_ap_hir.
Does that perform type checking? I don't think the requirement to discover a type definition based on a field access can be achieved without type checking.
The ra_ap_hir crate is part of the rust-analyzer repo.
Rust-analyzer has a pretty comprehensive test suite and a lot of the tests will run the entire pipeline. You should be able to find some good examples in there.