提交 8d8876c0 编写于 作者: N Nick Cameron

driver: factor out a helper and make another helper public

上级 65b0a0c2
......@@ -518,7 +518,7 @@ fn build_controller(&mut self,
-> CompileController<'a> {
let mut control = CompileController::basic();
control.keep_ast = sess.opts.debugging_opts.keep_ast || save_analysis(sess);
control.keep_ast = sess.opts.debugging_opts.keep_ast;
if let Some((ppm, opt_uii)) = parse_pretty(sess, matches) {
if ppm.needs_ast_map(&opt_uii) {
......@@ -574,19 +574,7 @@ fn build_controller(&mut self,
}
if save_analysis(sess) {
control.after_analysis.callback = box |state| {
time(state.session.time_passes(), "save analysis", || {
save::process_crate(state.tcx.unwrap(),
state.expanded_crate.unwrap(),
state.analysis.unwrap(),
state.crate_name.unwrap(),
None,
DumpHandler::new(state.out_dir,
state.crate_name.unwrap()))
});
};
control.after_analysis.run_callback_on_error = true;
control.make_glob_map = resolve::MakeGlobMap::Yes;
enable_save_analysis(&mut control);
}
if sess.print_fuel_crate.is_some() {
......@@ -603,6 +591,23 @@ fn build_controller(&mut self,
}
}
pub fn enable_save_analysis(control: &mut CompileController) {
control.keep_ast = true;
control.after_analysis.callback = box |state| {
time(state.session.time_passes(), "save analysis", || {
save::process_crate(state.tcx.unwrap(),
state.expanded_crate.unwrap(),
state.analysis.unwrap(),
state.crate_name.unwrap(),
None,
DumpHandler::new(state.out_dir,
state.crate_name.unwrap()))
});
};
control.after_analysis.run_callback_on_error = true;
control.make_glob_map = resolve::MakeGlobMap::Yes;
}
fn save_analysis(sess: &Session) -> bool {
sess.opts.debugging_opts.save_analysis
}
......@@ -1215,7 +1220,7 @@ pub fn diagnostics_registry() -> errors::registry::Registry {
Registry::new(&all_errors)
}
fn get_args() -> Vec<String> {
pub fn get_args() -> Vec<String> {
env::args_os().enumerate()
.map(|(i, arg)| arg.into_string().unwrap_or_else(|arg| {
early_error(ErrorOutputType::default(),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册