@@ -114,29 +114,38 @@ impl Compiler {
114114 let crate_name = self . crate_name ( ) ?. peek ( ) . clone ( ) ;
115115 let krate = self . parse ( ) ?. take ( ) ;
116116
117- passes:: register_plugins (
118- self ,
117+ let result = passes:: register_plugins (
119118 self . session ( ) ,
120119 self . cstore ( ) ,
121120 krate,
122121 & crate_name,
123- )
122+ ) ;
123+
124+ // Compute the dependency graph (in the background). We want to do
125+ // this as early as possible, to give the DepGraph maximum time to
126+ // load before dep_graph() is called, but it also can't happen
127+ // until after rustc_incremental::prepare_session_directory() is
128+ // called, which happens within passes::register_plugins().
129+ self . dep_graph_future ( ) . ok ( ) ;
130+
131+ result
124132 } )
125133 }
126134
127135 pub fn crate_name ( & self ) -> Result < & Query < String > > {
128136 self . queries . crate_name . compute ( || {
129- let parse_result = self . parse ( ) ?;
130- let krate = parse_result. peek ( ) ;
131- let result = match self . crate_name {
137+ Ok ( match self . crate_name {
132138 Some ( ref crate_name) => crate_name. clone ( ) ,
133- None => rustc_codegen_utils:: link:: find_crate_name (
134- Some ( self . session ( ) ) ,
135- & krate. attrs ,
136- & self . input
137- ) ,
138- } ;
139- Ok ( result)
139+ None => {
140+ let parse_result = self . parse ( ) ?;
141+ let krate = parse_result. peek ( ) ;
142+ rustc_codegen_utils:: link:: find_crate_name (
143+ Some ( self . session ( ) ) ,
144+ & krate. attrs ,
145+ & self . input
146+ )
147+ }
148+ } )
140149 } )
141150 }
142151
@@ -194,7 +203,6 @@ impl Compiler {
194203
195204 pub fn prepare_outputs ( & self ) -> Result < & Query < OutputFilenames > > {
196205 self . queries . prepare_outputs . compute ( || {
197- self . lower_to_hir ( ) ?;
198206 let krate = self . expansion ( ) ?;
199207 let krate = krate. peek ( ) ;
200208 let crate_name = self . crate_name ( ) ?;
@@ -267,6 +275,11 @@ impl Compiler {
267275 } )
268276 }
269277
278+ // This method is different to all the other methods in `Compiler` because
279+ // it lacks a `Queries` entry. It's also not currently used. It does serve
280+ // as an example of how `Compiler` can be used, with additional steps added
281+ // between some passes. And see `rustc_driver::run_compiler` for a more
282+ // complex example.
270283 pub fn compile ( & self ) -> Result < ( ) > {
271284 self . prepare_outputs ( ) ?;
272285
@@ -278,12 +291,12 @@ impl Compiler {
278291
279292 self . global_ctxt ( ) ?;
280293
281- // Drop AST after creating GlobalCtxt to free memory
294+ // Drop AST after creating GlobalCtxt to free memory.
282295 mem:: drop ( self . expansion ( ) ?. take ( ) ) ;
283296
284297 self . ongoing_codegen ( ) ?;
285298
286- // Drop GlobalCtxt after starting codegen to free memory
299+ // Drop GlobalCtxt after starting codegen to free memory.
287300 mem:: drop ( self . global_ctxt ( ) ?. take ( ) ) ;
288301
289302 self . link ( ) . map ( |_| ( ) )
0 commit comments