How to use modern rust compiler internals

I need to write a tool, that uses rust compiler as a library.

I've already read about "stupid-stats", but it uses an outdated version of rust compiler. For example, in this code, there is a CompilerCalls trait (according to note in "Guide to Rustc Development", in the modern version it should use rustc_driver::Callbacks).

I've tried to find some minimal example of modern API usage.
I found that code.

But when I run it, I achieve this error from the run_compiler function:

error[E0463]: can't find crate for `std`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.

The test code (

fn main() {

It seems, that the compiler doesn't cover all code dependencies...
Is there some minimal example of such a tool (with the modern API usage), that will cover all code dependencies?

1 Like

This has been cross-posted to Stack Overflow.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.