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 (foo.rs):
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?