10
10
11
11
use rustc:: dep_graph:: DepGraph ;
12
12
use rustc:: hir;
13
- use rustc:: hir:: { map as hir_map, FreevarMap , TraitMap } ;
14
- use rustc:: hir:: def:: DefMap ;
13
+ use rustc:: hir:: map as hir_map;
15
14
use rustc_mir as mir;
16
15
use rustc:: mir:: mir_map:: MirMap ;
17
16
use rustc:: session:: { Session , CompileResult , compile_result_from_err_count} ;
@@ -61,14 +60,6 @@ use syntax::visit;
61
60
use syntax;
62
61
use syntax_ext;
63
62
64
- #[ derive( Clone ) ]
65
- pub struct Resolutions {
66
- pub def_map : RefCell < DefMap > ,
67
- pub freevars : FreevarMap ,
68
- pub trait_map : TraitMap ,
69
- pub maybe_unused_trait_imports : NodeSet ,
70
- }
71
-
72
63
pub fn compile_input ( sess : & Session ,
73
64
cstore : & CStore ,
74
65
cfg : ast:: CrateConfig ,
@@ -148,17 +139,15 @@ pub fn compile_input(sess: &Session,
148
139
149
140
time ( sess. time_passes ( ) ,
150
141
"external crate/lib resolution" ,
151
- || LocalCrateReader :: new ( sess, & cstore, defs, & expanded_crate, & id)
142
+ || LocalCrateReader :: new ( sess, & cstore, & defs, & expanded_crate, & id)
152
143
. read_crates ( & dep_graph) ) ;
153
144
154
- time ( sess. time_passes ( ) ,
155
- "early lint checks" ,
156
- || lint:: check_ast_crate ( sess, & expanded_crate) ) ;
157
-
158
- let ( analysis, resolutions, mut hir_forest) = {
159
- let defs = & mut * defs. borrow_mut ( ) ;
160
- lower_and_resolve ( sess, & id, defs, & expanded_crate, dep_graph, control. make_glob_map )
161
- } ;
145
+ // Lower ast -> hir.
146
+ let lcx = LoweringContext :: new ( sess, Some ( & expanded_crate) , defs) ;
147
+ let hir_forest = & mut time ( sess. time_passes ( ) ,
148
+ "lowering ast -> hir" ,
149
+ || hir_map:: Forest :: new ( lower_crate ( & lcx, & expanded_crate) ,
150
+ dep_graph) ) ;
162
151
163
152
// Discard MTWT tables that aren't required past lowering to HIR.
164
153
if !keep_mtwt_tables ( sess) {
@@ -168,7 +157,6 @@ pub fn compile_input(sess: &Session,
168
157
let arenas = ty:: CtxtArenas :: new ( ) ;
169
158
170
159
// Construct the HIR map
171
- let hir_forest = & mut hir_forest;
172
160
let hir_map = time ( sess. time_passes ( ) ,
173
161
"indexing hir" ,
174
162
move || hir_map:: map_crate ( hir_forest, defs) ) ;
@@ -187,8 +175,6 @@ pub fn compile_input(sess: &Session,
187
175
& arenas,
188
176
& cstore,
189
177
& hir_map,
190
- & analysis,
191
- & resolutions,
192
178
& expanded_crate,
193
179
& hir_map. krate( ) ,
194
180
& id) ,
@@ -199,6 +185,10 @@ pub fn compile_input(sess: &Session,
199
185
hir:: check_attr:: check_crate ( sess, & expanded_crate) ;
200
186
} ) ;
201
187
188
+ time ( sess. time_passes ( ) ,
189
+ "early lint checks" ,
190
+ || lint:: check_ast_crate ( sess, & expanded_crate) ) ;
191
+
202
192
let opt_crate = if keep_ast ( sess) {
203
193
Some ( & expanded_crate)
204
194
} else {
@@ -208,10 +198,9 @@ pub fn compile_input(sess: &Session,
208
198
209
199
phase_3_run_analysis_passes ( sess,
210
200
hir_map,
211
- analysis,
212
- resolutions,
213
201
& arenas,
214
202
& id,
203
+ control. make_glob_map ,
215
204
|tcx, mir_map, analysis, result| {
216
205
{
217
206
// Eventually, we will want to track plugins.
@@ -364,7 +353,6 @@ pub struct CompileState<'a, 'b, 'ast: 'a, 'tcx: 'b> where 'ast: 'tcx {
364
353
pub expanded_crate : Option < & ' a ast:: Crate > ,
365
354
pub hir_crate : Option < & ' a hir:: Crate > ,
366
355
pub ast_map : Option < & ' a hir_map:: Map < ' ast > > ,
367
- pub resolutions : Option < & ' a Resolutions > ,
368
356
pub mir_map : Option < & ' b MirMap < ' tcx > > ,
369
357
pub analysis : Option < & ' a ty:: CrateAnalysis < ' a > > ,
370
358
pub tcx : Option < & ' b TyCtxt < ' tcx > > ,
@@ -389,7 +377,6 @@ impl<'a, 'b, 'ast, 'tcx> CompileState<'a, 'b, 'ast, 'tcx> {
389
377
expanded_crate : None ,
390
378
hir_crate : None ,
391
379
ast_map : None ,
392
- resolutions : None ,
393
380
analysis : None ,
394
381
mir_map : None ,
395
382
tcx : None ,
@@ -436,8 +423,6 @@ impl<'a, 'b, 'ast, 'tcx> CompileState<'a, 'b, 'ast, 'tcx> {
436
423
arenas : & ' ast ty:: CtxtArenas < ' ast > ,
437
424
cstore : & ' a CStore ,
438
425
hir_map : & ' a hir_map:: Map < ' ast > ,
439
- analysis : & ' a ty:: CrateAnalysis ,
440
- resolutions : & ' a Resolutions ,
441
426
krate : & ' a ast:: Crate ,
442
427
hir_crate : & ' a hir:: Crate ,
443
428
crate_name : & ' a str )
@@ -447,8 +432,6 @@ impl<'a, 'b, 'ast, 'tcx> CompileState<'a, 'b, 'ast, 'tcx> {
447
432
arenas : Some ( arenas) ,
448
433
cstore : Some ( cstore) ,
449
434
ast_map : Some ( hir_map) ,
450
- analysis : Some ( analysis) ,
451
- resolutions : Some ( resolutions) ,
452
435
expanded_crate : Some ( krate) ,
453
436
hir_crate : Some ( hir_crate) ,
454
437
out_file : out_file. as_ref ( ) . map ( |s| & * * s) ,
@@ -773,48 +756,14 @@ pub fn assign_node_ids(sess: &Session, krate: ast::Crate) -> ast::Crate {
773
756
krate
774
757
}
775
758
776
- pub fn lower_and_resolve < ' a > ( sess : & Session ,
777
- id : & ' a str ,
778
- defs : & mut hir_map:: Definitions ,
779
- krate : & ast:: Crate ,
780
- dep_graph : DepGraph ,
781
- make_glob_map : resolve:: MakeGlobMap )
782
- -> ( ty:: CrateAnalysis < ' a > , Resolutions , hir_map:: Forest ) {
783
- resolve:: with_resolver ( sess, defs, make_glob_map, |mut resolver| {
784
- time ( sess. time_passes ( ) , "name resolution" , || {
785
- resolve:: resolve_crate ( & mut resolver, krate) ;
786
- } ) ;
787
-
788
- // Lower ast -> hir.
789
- let hir_forest = time ( sess. time_passes ( ) , "lowering ast -> hir" , || {
790
- let lcx = LoweringContext :: new ( sess, Some ( krate) , & mut resolver) ;
791
- hir_map:: Forest :: new ( lower_crate ( & lcx, krate) , dep_graph)
792
- } ) ;
793
-
794
- ( ty:: CrateAnalysis {
795
- export_map : resolver. export_map ,
796
- access_levels : AccessLevels :: default ( ) ,
797
- reachable : NodeSet ( ) ,
798
- name : & id,
799
- glob_map : if resolver. make_glob_map { Some ( resolver. glob_map ) } else { None } ,
800
- } , Resolutions {
801
- def_map : RefCell :: new ( resolver. def_map ) ,
802
- freevars : resolver. freevars ,
803
- trait_map : resolver. trait_map ,
804
- maybe_unused_trait_imports : resolver. maybe_unused_trait_imports ,
805
- } , hir_forest)
806
- } )
807
- }
808
-
809
759
/// Run the resolution, typechecking, region checking and other
810
760
/// miscellaneous analysis passes on the crate. Return various
811
761
/// structures carrying the results of the analysis.
812
762
pub fn phase_3_run_analysis_passes < ' tcx , F , R > ( sess : & ' tcx Session ,
813
763
hir_map : hir_map:: Map < ' tcx > ,
814
- mut analysis : ty:: CrateAnalysis ,
815
- resolutions : Resolutions ,
816
764
arenas : & ' tcx ty:: CtxtArenas < ' tcx > ,
817
765
name : & str ,
766
+ make_glob_map : resolve:: MakeGlobMap ,
818
767
f : F )
819
768
-> Result < R , usize >
820
769
where F : FnOnce ( & TyCtxt < ' tcx > , Option < MirMap < ' tcx > > , ty:: CrateAnalysis , CompileResult ) -> R
@@ -839,11 +788,30 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
839
788
} )
840
789
} ) ?;
841
790
791
+ let resolve:: CrateMap {
792
+ def_map,
793
+ freevars,
794
+ maybe_unused_trait_imports,
795
+ export_map,
796
+ trait_map,
797
+ glob_map,
798
+ } = time ( sess. time_passes ( ) ,
799
+ "name resolution" ,
800
+ || resolve:: resolve_crate ( sess, & hir_map, make_glob_map) ) ;
801
+
802
+ let mut analysis = ty:: CrateAnalysis {
803
+ export_map : export_map,
804
+ access_levels : AccessLevels :: default ( ) ,
805
+ reachable : NodeSet ( ) ,
806
+ name : name,
807
+ glob_map : glob_map,
808
+ } ;
809
+
842
810
let named_region_map = time ( time_passes,
843
811
"lifetime resolution" ,
844
812
|| middle:: resolve_lifetime:: krate ( sess,
845
813
& hir_map,
846
- & resolutions . def_map . borrow ( ) ) ) ?;
814
+ & def_map. borrow ( ) ) ) ?;
847
815
848
816
time ( time_passes,
849
817
"looking for entry point" ,
@@ -863,18 +831,17 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
863
831
864
832
time ( time_passes,
865
833
"static item recursion checking" ,
866
- || static_recursion:: check_crate ( sess, & resolutions . def_map . borrow ( ) , & hir_map) ) ?;
834
+ || static_recursion:: check_crate ( sess, & def_map. borrow ( ) , & hir_map) ) ?;
867
835
868
836
let index = stability:: Index :: new ( & hir_map) ;
869
837
870
- let trait_map = resolutions. trait_map ;
871
838
TyCtxt :: create_and_enter ( sess,
872
839
arenas,
873
- resolutions . def_map ,
840
+ def_map,
874
841
named_region_map,
875
842
hir_map,
876
- resolutions . freevars ,
877
- resolutions . maybe_unused_trait_imports ,
843
+ freevars,
844
+ maybe_unused_trait_imports,
878
845
region_map,
879
846
lang_items,
880
847
index,
0 commit comments