driver: factor out a helper and make another helper public
This commit is contained in:
parent
65b0a0c2c7
commit
8d8876c0b7
1 changed files with 20 additions and 15 deletions
|
@ -518,7 +518,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
|
|||
-> 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 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
|
|||
}
|
||||
|
||||
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 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
|
|||
}
|
||||
}
|
||||
|
||||
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(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue