[rust-dev] Invoking rustc as crate?

Christoph Husse thesaint1987 at googlemail.com
Sun Jul 13 00:10:34 PDT 2014


I successfully managed to hook into the compiler so far. Or well it's
not that successful, because it doesn't work, but at least the code is
there ;).

Now I am trying to compile an empty file, and it gives me the weird error:

"error: can't find crate for `std`"

Any chance there could be more insight? Normally a C++ compiler is
able to also tell you the library search paths at least, and in this
case it would be helpful to print the assumed hash code suffix that
was expected (I assume the fact that it runs in my executable instead
of the real compiler makes it somehow look for and STD with a
different hash suffix).

To zero out the chance that I did something wrong with externalizing
parts of the compiler driver into my own application, I wrote a simple
main method with the following "fallback":


It will simply do what rustc does... Invoke the rustc compiler with
the arguments provided. This call will land inside of the compiler
that was used to compile the very same statement (I hope). Its using
the "rustc" crate after all.

Still the same error message ;)

So how could that be resolved? This is also an issue for custom Lint
plugins I guess, because you will definitely not want to invoke rustc
as external command and then have your plugin run in a different
process. I basically need the AST after analysis in its pure form,
like no JSON or something. Just want to continue where the compiler
left off... Instead of generating LLVM & stuff, which is not needed in
my case.


More information about the Rust-dev mailing list