@@ -144,6 +144,14 @@ pub fn compile_input(sess: Session,
144
144
"early lint checks" ,
145
145
|| lint:: check_ast_crate ( & sess, & expanded_crate) ) ;
146
146
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
+
147
155
phase_3_run_analysis_passes ( & sess,
148
156
& cstore,
149
157
hir_map,
@@ -157,7 +165,7 @@ pub fn compile_input(sess: Session,
157
165
CompileState :: state_after_analysis ( input,
158
166
& tcx. sess ,
159
167
outdir,
160
- & expanded_crate ,
168
+ opt_crate ,
161
169
tcx. map . krate ( ) ,
162
170
& analysis,
163
171
& mir_map,
@@ -360,7 +368,7 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
360
368
fn state_after_analysis ( input : & ' a Input ,
361
369
session : & ' a Session ,
362
370
out_dir : & ' a Option < PathBuf > ,
363
- krate : & ' a ast:: Crate ,
371
+ krate : Option < & ' a ast:: Crate > ,
364
372
hir_crate : & ' a hir:: Crate ,
365
373
analysis : & ' a ty:: CrateAnalysis ,
366
374
mir_map : & ' a MirMap < ' tcx > ,
@@ -372,7 +380,7 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
372
380
analysis : Some ( analysis) ,
373
381
mir_map : Some ( mir_map) ,
374
382
tcx : Some ( tcx) ,
375
- krate : Some ( krate) ,
383
+ krate : krate,
376
384
hir_crate : Some ( hir_crate) ,
377
385
lcx : Some ( lcx) ,
378
386
crate_name : Some ( crate_name) ,
0 commit comments