@@ -518,7 +518,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
518518 -> CompileController < ' a > {
519519 let mut control = CompileController :: basic ( ) ;
520520
521- control. keep_ast = sess. opts . debugging_opts . keep_ast || save_analysis ( sess ) ;
521+ control. keep_ast = sess. opts . debugging_opts . keep_ast ;
522522
523523 if let Some ( ( ppm, opt_uii) ) = parse_pretty ( sess, matches) {
524524 if ppm. needs_ast_map ( & opt_uii) {
@@ -574,19 +574,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
574574 }
575575
576576 if save_analysis ( sess) {
577- control. after_analysis . callback = box |state| {
578- time ( state. session . time_passes ( ) , "save analysis" , || {
579- save:: process_crate ( state. tcx . unwrap ( ) ,
580- state. expanded_crate . unwrap ( ) ,
581- state. analysis . unwrap ( ) ,
582- state. crate_name . unwrap ( ) ,
583- None ,
584- DumpHandler :: new ( state. out_dir ,
585- state. crate_name . unwrap ( ) ) )
586- } ) ;
587- } ;
588- control. after_analysis . run_callback_on_error = true ;
589- control. make_glob_map = resolve:: MakeGlobMap :: Yes ;
577+ enable_save_analysis ( & mut control) ;
590578 }
591579
592580 if sess. print_fuel_crate . is_some ( ) {
@@ -603,6 +591,23 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
603591 }
604592}
605593
594+ pub fn enable_save_analysis ( control : & mut CompileController ) {
595+ control. keep_ast = true ;
596+ control. after_analysis . callback = box |state| {
597+ time ( state. session . time_passes ( ) , "save analysis" , || {
598+ save:: process_crate ( state. tcx . unwrap ( ) ,
599+ state. expanded_crate . unwrap ( ) ,
600+ state. analysis . unwrap ( ) ,
601+ state. crate_name . unwrap ( ) ,
602+ None ,
603+ DumpHandler :: new ( state. out_dir ,
604+ state. crate_name . unwrap ( ) ) )
605+ } ) ;
606+ } ;
607+ control. after_analysis . run_callback_on_error = true ;
608+ control. make_glob_map = resolve:: MakeGlobMap :: Yes ;
609+ }
610+
606611fn save_analysis ( sess : & Session ) -> bool {
607612 sess. opts . debugging_opts . save_analysis
608613}
@@ -1215,7 +1220,7 @@ pub fn diagnostics_registry() -> errors::registry::Registry {
12151220 Registry :: new ( & all_errors)
12161221}
12171222
1218- fn get_args ( ) -> Vec < String > {
1223+ pub fn get_args ( ) -> Vec < String > {
12191224 env:: args_os ( ) . enumerate ( )
12201225 . map ( |( i, arg) | arg. into_string ( ) . unwrap_or_else ( |arg| {
12211226 early_error ( ErrorOutputType :: default ( ) ,
0 commit comments