Sample code for using rust-analyzer to parse + type check crate?

Is there sample code for how to use GitHub - rust-lang/rust-analyzer: A Rust compiler front-end for IDEs to parse + type check Rust code ? (a println! of the typed ast tree would suffice).

The manual (understandably) focuses on the problem of "how do I use rust-analyzer from an IDE" User Manual

I have a different problem. I want to use rust-analyzer from a Rust PROGRAM, where I can pass it a crate and get back a typed AST of the crate.


Have you looked at the API that is linked on the github page?

The one labeled ide ? I don't see sample code there. I feel like this is the type of thing where iterating on a minimal working example is far far far faster than trying to assemble it from scratch.

There is also the issue much of this API is designed for incremental changes, whereas all I need is a single snapshot.

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.