@@ -121,7 +121,7 @@ pub fn compile_input(sess: Session,
121
121
}
122
122
123
123
let arenas = ty:: CtxtArenas :: new ( ) ;
124
- let ast_map = make_map ( & sess, & mut hir_forest) ;
124
+ let hir_map = make_map ( & sess, & mut hir_forest) ;
125
125
126
126
write_out_deps ( & sess, & outputs, & id) ;
127
127
@@ -130,9 +130,9 @@ pub fn compile_input(sess: Session,
130
130
CompileState :: state_after_write_deps( input,
131
131
& sess,
132
132
outdir,
133
- & ast_map ,
133
+ & hir_map ,
134
134
& expanded_crate,
135
- & ast_map . krate( ) ,
135
+ & hir_map . krate( ) ,
136
136
& id[ ..] ,
137
137
& lcx) ) ;
138
138
@@ -144,9 +144,17 @@ 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
- ast_map ,
157
+ hir_map ,
150
158
& arenas,
151
159
& id,
152
160
control. make_glob_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,
@@ -341,15 +349,15 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
341
349
fn state_after_write_deps ( input : & ' a Input ,
342
350
session : & ' a Session ,
343
351
out_dir : & ' a Option < PathBuf > ,
344
- ast_map : & ' a hir_map:: Map < ' ast > ,
352
+ hir_map : & ' a hir_map:: Map < ' ast > ,
345
353
krate : & ' a ast:: Crate ,
346
354
hir_crate : & ' a hir:: Crate ,
347
355
crate_name : & ' a str ,
348
356
lcx : & ' a LoweringContext < ' a > )
349
357
-> CompileState < ' a , ' ast , ' tcx > {
350
358
CompileState {
351
359
crate_name : Some ( crate_name) ,
352
- ast_map : Some ( ast_map ) ,
360
+ ast_map : Some ( hir_map ) ,
353
361
krate : Some ( krate) ,
354
362
hir_crate : Some ( hir_crate) ,
355
363
lcx : Some ( lcx) ,
@@ -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) ,
@@ -670,22 +678,20 @@ pub fn assign_node_ids(sess: &Session, krate: ast::Crate) -> ast::Crate {
670
678
}
671
679
672
680
pub fn make_map < ' ast > ( sess : & Session ,
673
- forest : & ' ast mut front:: map:: Forest )
674
- -> front:: map:: Map < ' ast > {
675
- // Construct the 'ast'-map
676
- let map = time ( sess. time_passes ( ) ,
677
- "indexing hir" ,
678
- move || front:: map:: map_crate ( forest) ) ;
679
-
680
- map
681
+ forest : & ' ast mut hir_map:: Forest )
682
+ -> hir_map:: Map < ' ast > {
683
+ // Construct the HIR map
684
+ time ( sess. time_passes ( ) ,
685
+ "indexing hir" ,
686
+ move || hir_map:: map_crate ( forest) )
681
687
}
682
688
683
689
/// Run the resolution, typechecking, region checking and other
684
690
/// miscellaneous analysis passes on the crate. Return various
685
691
/// structures carrying the results of the analysis.
686
692
pub fn phase_3_run_analysis_passes < ' tcx , F , R > ( sess : & ' tcx Session ,
687
693
cstore : & CStore ,
688
- ast_map : front :: map :: Map < ' tcx > ,
694
+ hir_map : hir_map :: Map < ' tcx > ,
689
695
arenas : & ' tcx ty:: CtxtArenas < ' tcx > ,
690
696
name : & str ,
691
697
make_glob_map : resolve:: MakeGlobMap ,
@@ -694,15 +700,15 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
694
700
where F : for < ' a > FnOnce ( & ' a ty:: ctxt < ' tcx > , MirMap < ' tcx > , ty:: CrateAnalysis ) -> R
695
701
{
696
702
let time_passes = sess. time_passes ( ) ;
697
- let krate = ast_map . krate ( ) ;
703
+ let krate = hir_map . krate ( ) ;
698
704
699
705
time ( time_passes,
700
706
"external crate/lib resolution" ,
701
- || LocalCrateReader :: new ( sess, cstore, & ast_map ) . read_crates ( krate) ) ;
707
+ || LocalCrateReader :: new ( sess, cstore, & hir_map ) . read_crates ( krate) ) ;
702
708
703
709
let lang_items = time ( time_passes,
704
710
"language item collection" ,
705
- || middle:: lang_items:: collect_language_items ( & sess, & ast_map ) ) ;
711
+ || middle:: lang_items:: collect_language_items ( & sess, & hir_map ) ) ;
706
712
707
713
let resolve:: CrateMap {
708
714
def_map,
@@ -713,15 +719,15 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
713
719
glob_map,
714
720
} = time ( time_passes,
715
721
"resolution" ,
716
- || resolve:: resolve_crate ( sess, & ast_map , make_glob_map) ) ;
722
+ || resolve:: resolve_crate ( sess, & hir_map , make_glob_map) ) ;
717
723
718
724
let named_region_map = time ( time_passes,
719
725
"lifetime resolution" ,
720
726
|| middle:: resolve_lifetime:: krate ( sess, krate, & def_map. borrow ( ) ) ) ;
721
727
722
728
time ( time_passes,
723
729
"looking for entry point" ,
724
- || middle:: entry:: find_entry_point ( sess, & ast_map ) ) ;
730
+ || middle:: entry:: find_entry_point ( sess, & hir_map ) ) ;
725
731
726
732
sess. plugin_registrar_fn . set ( time ( time_passes, "looking for plugin registrar" , || {
727
733
plugin:: build:: find_plugin_registrar ( sess. diagnostic ( ) , krate)
@@ -737,13 +743,13 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
737
743
738
744
time ( time_passes,
739
745
"static item recursion checking" ,
740
- || middle:: check_static_recursion:: check_crate ( sess, krate, & def_map. borrow ( ) , & ast_map ) ) ;
746
+ || middle:: check_static_recursion:: check_crate ( sess, krate, & def_map. borrow ( ) , & hir_map ) ) ;
741
747
742
748
ty:: ctxt:: create_and_enter ( sess,
743
749
arenas,
744
750
def_map,
745
751
named_region_map,
746
- ast_map ,
752
+ hir_map ,
747
753
freevars,
748
754
region_map,
749
755
lang_items,
0 commit comments