@@ -116,34 +116,20 @@ pub fn compile_input(sess: &Session,
116116 let outputs = build_output_filenames ( input, outdir, output, & krate. attrs , sess) ;
117117 let id = link:: find_crate_name ( Some ( sess) , & krate. attrs , input) ;
118118 let ExpansionResult { expanded_crate, defs, analysis, resolutions, mut hir_forest } = {
119- let make_glob_map = control. make_glob_map ;
120- phase_2_configure_and_expand ( sess, & cstore, krate, & id, addl_plugins, make_glob_map) ?
119+ phase_2_configure_and_expand (
120+ sess, & cstore, krate, & id, addl_plugins, control. make_glob_map ,
121+ |expanded_crate| {
122+ let mut state = CompileState :: state_after_expand (
123+ input, sess, outdir, output, & cstore, expanded_crate, & id,
124+ ) ;
125+ controller_entry_point ! ( after_expand, sess, state, Ok ( ( ) ) ) ;
126+ Ok ( ( ) )
127+ }
128+ ) ?
121129 } ;
122130
123- controller_entry_point ! ( after_expand,
124- sess,
125- CompileState :: state_after_expand( input,
126- sess,
127- outdir,
128- output,
129- & cstore,
130- & expanded_crate,
131- & id) ,
132- Ok ( ( ) ) ) ;
133-
134131 write_out_deps ( sess, & outputs, & id) ;
135132
136- controller_entry_point ! ( after_write_deps,
137- sess,
138- CompileState :: state_after_write_deps( input,
139- sess,
140- outdir,
141- output,
142- & cstore,
143- & expanded_crate,
144- & id) ,
145- Ok ( ( ) ) ) ;
146-
147133 let arenas = ty:: CtxtArenas :: new ( ) ;
148134
149135 // Construct the HIR map
@@ -285,7 +271,6 @@ pub fn source_name(input: &Input) -> String {
285271pub struct CompileController < ' a > {
286272 pub after_parse : PhaseController < ' a > ,
287273 pub after_expand : PhaseController < ' a > ,
288- pub after_write_deps : PhaseController < ' a > ,
289274 pub after_hir_lowering : PhaseController < ' a > ,
290275 pub after_analysis : PhaseController < ' a > ,
291276 pub after_llvm : PhaseController < ' a > ,
@@ -298,7 +283,6 @@ impl<'a> CompileController<'a> {
298283 CompileController {
299284 after_parse : PhaseController :: basic ( ) ,
300285 after_expand : PhaseController :: basic ( ) ,
301- after_write_deps : PhaseController :: basic ( ) ,
302286 after_hir_lowering : PhaseController :: basic ( ) ,
303287 after_analysis : PhaseController :: basic ( ) ,
304288 after_llvm : PhaseController :: basic ( ) ,
@@ -406,23 +390,6 @@ impl<'a, 'b, 'ast, 'tcx> CompileState<'a, 'b, 'ast, 'tcx> {
406390 }
407391 }
408392
409- fn state_after_write_deps ( input : & ' a Input ,
410- session : & ' ast Session ,
411- out_dir : & ' a Option < PathBuf > ,
412- out_file : & ' a Option < PathBuf > ,
413- cstore : & ' a CStore ,
414- krate : & ' a ast:: Crate ,
415- crate_name : & ' a str )
416- -> CompileState < ' a , ' b , ' ast , ' tcx > {
417- CompileState {
418- crate_name : Some ( crate_name) ,
419- cstore : Some ( cstore) ,
420- expanded_crate : Some ( krate) ,
421- out_file : out_file. as_ref ( ) . map ( |s| & * * s) ,
422- ..CompileState :: empty ( input, session, out_dir)
423- }
424- }
425-
426393 fn state_after_hir_lowering ( input : & ' a Input ,
427394 session : & ' ast Session ,
428395 out_dir : & ' a Option < PathBuf > ,
@@ -556,13 +523,16 @@ pub struct ExpansionResult<'a> {
556523/// standard library and prelude, and name resolution.
557524///
558525/// Returns `None` if we're aborting after handling -W help.
559- pub fn phase_2_configure_and_expand < ' a > ( sess : & Session ,
560- cstore : & CStore ,
561- mut krate : ast:: Crate ,
562- crate_name : & ' a str ,
563- addl_plugins : Option < Vec < String > > ,
564- make_glob_map : MakeGlobMap )
565- -> Result < ExpansionResult < ' a > , usize > {
526+ pub fn phase_2_configure_and_expand < ' a , F > ( sess : & Session ,
527+ cstore : & CStore ,
528+ mut krate : ast:: Crate ,
529+ crate_name : & ' a str ,
530+ addl_plugins : Option < Vec < String > > ,
531+ make_glob_map : MakeGlobMap ,
532+ after_expand : F )
533+ -> Result < ExpansionResult < ' a > , usize >
534+ where F : FnOnce ( & ast:: Crate ) -> CompileResult ,
535+ {
566536 let time_passes = sess. time_passes ( ) ;
567537
568538 // strip before anything else because crate metadata may use #[cfg_attr]
@@ -745,9 +715,23 @@ pub fn phase_2_configure_and_expand<'a>(sess: &Session,
745715 "AST validation" ,
746716 || ast_validation:: check_crate ( sess, & krate) ) ;
747717
748- time ( sess. time_passes ( ) , "name resolution" , || {
718+ time ( sess. time_passes ( ) , "name resolution" , || -> CompileResult {
719+ // Currently, we ignore the name resolution data structures for the purposes of dependency
720+ // tracking. Instead we will run name resolution and include its output in the hash of each
721+ // item, much like we do for macro expansion. In other words, the hash reflects not just
722+ // its contents but the results of name resolution on those contents. Hopefully we'll push
723+ // this back at some point.
724+ let _ignore = sess. dep_graph . in_ignore ( ) ;
725+ resolver. build_reduced_graph ( & krate) ;
726+ resolver. resolve_imports ( ) ;
727+
728+ // Since import resolution will eventually happen in expansion,
729+ // don't perform `after_expand` until after import resolution.
730+ after_expand ( & krate) ?;
731+
749732 resolver. resolve_crate ( & krate) ;
750- } ) ;
733+ Ok ( ( ) )
734+ } ) ?;
751735
752736 // Lower ast -> hir.
753737 let hir_forest = time ( sess. time_passes ( ) , "lowering ast -> hir" , || {
0 commit comments