Closed
Description
The following is the parse, expand & analyse steps of the compiler (cribbed from rustdoc). Running on any non-#[no_std]
file causes the following error:
rustc_lib_example.rs:1:1: 1:1 error: can't find crate for `std`
rustc_lib_example.rs:1 #[feature(managed_boxes)];
^
#[feature(managed_boxes)];
extern mod rustc;
extern mod syntax;
use std::os;
use rustc::driver::{driver, session};
use rustc::metadata::creader::Loader;
use syntax::diagnostic;
/// Extract the expanded ast of a crate, along with the codemap which
/// connects source code locations to the actual code.
fn main() {
let path = Path::new(os::args()[1]);
let parsesess = syntax::parse::new_parse_sess(None);
let input = driver::FileInput(path);
let sessopts = @session::Options {
binary: ~"example",
.. (*session::basic_options()).clone()
};
let diagnostic_handler = diagnostic::mk_handler(None);
let span_diagnostic_handler =
diagnostic::mk_span_handler(diagnostic_handler, parsesess.cm);
let sess = driver::build_session_(sessopts, parsesess.cm,
@diagnostic::DefaultEmitter as @diagnostic::Emitter,
span_diagnostic_handler);
let cfg = driver::build_configuration(sess);
let crate = driver::phase_1_parse_input(sess, cfg.clone(), &input);
let loader = &mut Loader::new(sess);
let (crate, ast_map) = driver::phase_2_configure_and_expand(sess, cfg, loader, crate);
driver::phase_3_run_analysis_passes(sess, &crate, ast_map);
}
This makes rustc
completely unusable as a library for out-of-source-tree tools.
Metadata
Metadata
Assignees
Labels
No labels