@@ -114,29 +114,38 @@ impl Compiler {
114
114
let crate_name = self . crate_name ( ) ?. peek ( ) . clone ( ) ;
115
115
let krate = self . parse ( ) ?. take ( ) ;
116
116
117
- passes:: register_plugins (
118
- self ,
117
+ let result = passes:: register_plugins (
119
118
self . session ( ) ,
120
119
self . cstore ( ) ,
121
120
krate,
122
121
& 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
124
132
} )
125
133
}
126
134
127
135
pub fn crate_name ( & self ) -> Result < & Query < String > > {
128
136
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 {
132
138
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
+ } )
140
149
} )
141
150
}
142
151
@@ -194,7 +203,6 @@ impl Compiler {
194
203
195
204
pub fn prepare_outputs ( & self ) -> Result < & Query < OutputFilenames > > {
196
205
self . queries . prepare_outputs . compute ( || {
197
- self . lower_to_hir ( ) ?;
198
206
let krate = self . expansion ( ) ?;
199
207
let krate = krate. peek ( ) ;
200
208
let crate_name = self . crate_name ( ) ?;
@@ -267,6 +275,11 @@ impl Compiler {
267
275
} )
268
276
}
269
277
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.
270
283
pub fn compile ( & self ) -> Result < ( ) > {
271
284
self . prepare_outputs ( ) ?;
272
285
@@ -278,12 +291,12 @@ impl Compiler {
278
291
279
292
self . global_ctxt ( ) ?;
280
293
281
- // Drop AST after creating GlobalCtxt to free memory
294
+ // Drop AST after creating GlobalCtxt to free memory.
282
295
mem:: drop ( self . expansion ( ) ?. take ( ) ) ;
283
296
284
297
self . ongoing_codegen ( ) ?;
285
298
286
- // Drop GlobalCtxt after starting codegen to free memory
299
+ // Drop GlobalCtxt after starting codegen to free memory.
287
300
mem:: drop ( self . global_ctxt ( ) ?. take ( ) ) ;
288
301
289
302
self . link ( ) . map ( |_| ( ) )
0 commit comments