Skip to content
This repository was archived by the owner on Mar 1, 2019. It is now read-only.

Commit 037202a

Browse files
committed
Use new driver API
Closes #2 Closes #3
1 parent 488fbf8 commit 037202a

File tree

2 files changed

+6
-35
lines changed

2 files changed

+6
-35
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.rs

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,16 @@ extern crate rustc;
77
extern crate rustc_driver;
88
extern crate rustc_errors;
99
extern crate rustc_resolve;
10-
extern crate rustc_save_analysis;
1110
extern crate syntax;
1211

13-
use rustc_driver::{run, run_compiler, CompilerCalls, RustcDefaultCalls, Compilation};
12+
use rustc_driver::{run, run_compiler, CompilerCalls, RustcDefaultCalls, Compilation, enable_save_analysis, get_args};
1413
use rustc_driver::driver::CompileController;
15-
use rustc_save_analysis as save;
16-
use rustc_save_analysis::DumpHandler;
17-
use rustc::session::{early_error, Session};
14+
use rustc::session::Session;
1815
use rustc::session::config::{self, ErrorOutputType, Input};
19-
use rustc::util::common::time;
2016
use syntax::ast;
2117

2218
use std::path::PathBuf;
23-
use std::{env, process};
19+
use std::process;
2420

2521
struct ShimCalls;
2622

@@ -66,38 +62,13 @@ impl<'a> CompilerCalls<'a> for ShimCalls {
6662
fn build_controller(&mut self, a: &Session, b: &getopts::Matches) -> CompileController<'a> {
6763
let mut result = RustcDefaultCalls.build_controller(a, b);
6864

69-
// FIXME(#2) use enable_save_analysis
70-
result.keep_ast = true;
71-
// FIXME(#3) set continue_parse_after_error
72-
73-
result.after_analysis.callback = box |state| {
74-
time(state.session.time_passes(), "save analysis", || {
75-
save::process_crate(state.tcx.unwrap(),
76-
state.expanded_crate.unwrap(),
77-
state.analysis.unwrap(),
78-
state.crate_name.unwrap(),
79-
None,
80-
DumpHandler::new(state.out_dir,
81-
state.crate_name.unwrap()))
82-
});
83-
};
84-
result.after_analysis.run_callback_on_error = true;
85-
result.make_glob_map = ::rustc_resolve::MakeGlobMap::Yes;
65+
result.continue_parse_after_error = true;
66+
enable_save_analysis(&mut result);
8667

8768
result
8869
}
8970
}
9071

91-
// FIXME(#2) use exported version
92-
fn get_args() -> Vec<String> {
93-
env::args_os().enumerate()
94-
.map(|(i, arg)| arg.into_string().unwrap_or_else(|arg| {
95-
early_error(ErrorOutputType::default(),
96-
&format!("Argument {} is not valid Unicode: {:?}", i, arg))
97-
}))
98-
.collect()
99-
}
100-
10172
fn main() {
10273
env_logger::init().unwrap();
10374

0 commit comments

Comments
 (0)