@@ -144,6 +144,14 @@ pub fn compile_input(sess: Session,
144144 "early lint checks" ,
145145 || lint:: check_ast_crate ( & sess, & expanded_crate) ) ;
146146
147+ let opt_crate = if sess. opts . debugging_opts . keep_ast ||
148+ sess. opts . debugging_opts . save_analysis {
149+ Some ( & expanded_crate)
150+ } else {
151+ drop ( expanded_crate) ;
152+ None
153+ } ;
154+
147155 phase_3_run_analysis_passes ( & sess,
148156 & cstore,
149157 hir_map,
@@ -157,7 +165,7 @@ pub fn compile_input(sess: Session,
157165 CompileState :: state_after_analysis ( input,
158166 & tcx. sess ,
159167 outdir,
160- & expanded_crate ,
168+ opt_crate ,
161169 tcx. map . krate ( ) ,
162170 & analysis,
163171 & mir_map,
@@ -360,7 +368,7 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
360368 fn state_after_analysis ( input : & ' a Input ,
361369 session : & ' a Session ,
362370 out_dir : & ' a Option < PathBuf > ,
363- krate : & ' a ast:: Crate ,
371+ krate : Option < & ' a ast:: Crate > ,
364372 hir_crate : & ' a hir:: Crate ,
365373 analysis : & ' a ty:: CrateAnalysis ,
366374 mir_map : & ' a MirMap < ' tcx > ,
@@ -372,7 +380,7 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
372380 analysis : Some ( analysis) ,
373381 mir_map : Some ( mir_map) ,
374382 tcx : Some ( tcx) ,
375- krate : Some ( krate) ,
383+ krate : krate,
376384 hir_crate : Some ( hir_crate) ,
377385 lcx : Some ( lcx) ,
378386 crate_name : Some ( crate_name) ,
0 commit comments