Help with librustc


#1

Hello!

I’m trying to get a librustc to compile some source to the point where I can get type information out.
gist here: https://gist.github.com/phildawes/cdc4fcfce18f5bb52dc0 (I used the code in librustc/test.rs as a starting point)

Unfortunately it only gets to the resolve::resolve_crate stage with the error:

'unresolved import `std::prelude::v1::*`'. Maybe a missing `extern crate std`?'

I’m not sure why it can’t resolve the prelude, I’ve set the options.maybe_sysroot to “/usr/local” to match my rustc install. Not setting the maybe_sysroot results in another error: "can’t find crate for std"

Any help would be much appreciated!

Thanks,

Phil


#2

Stumbled upon this myself. The following call is missing:

CrateReader::new(&sess).read_crates(krate);

It’s described in phase_3_run_analysis_passes of librustc_driver/driver.rs.