@@ -70,7 +70,7 @@ pub fn compile_input(sess: &Session,
70
70
control : & CompileController ) -> CompileResult {
71
71
macro_rules! controller_entry_point {
72
72
( $point: ident, $tsess: expr, $make_state: expr, $phase_result: expr) => { {
73
- let state = & mut $make_state;
73
+ let state = $make_state;
74
74
let phase_result: & CompileResult = & $phase_result;
75
75
if phase_result. is_ok( ) || control. $point. run_callback_on_error {
76
76
( control. $point. callback) ( state) ;
@@ -95,24 +95,17 @@ pub fn compile_input(sess: &Session,
95
95
}
96
96
} ;
97
97
98
- let mut compile_state = CompileState :: state_after_parse ( input,
99
- sess,
100
- outdir,
101
- output,
102
- krate,
103
- & cstore) ;
104
98
controller_entry_point ! ( after_parse,
105
99
sess,
106
- compile_state ,
100
+ CompileState :: state_after_parse ( input , sess , outdir , & krate ) ,
107
101
Ok ( ( ) ) ) ;
108
- let krate = compile_state. krate . unwrap ( ) ;
109
102
110
103
let outputs = build_output_filenames ( input, outdir, output, & krate. attrs , sess) ;
111
104
let id = link:: find_crate_name ( Some ( sess) , & krate. attrs , input) ;
112
105
let expanded_crate = phase_2_configure_and_expand ( sess,
113
106
& cstore,
114
107
krate,
115
- & id,
108
+ & id[ .. ] ,
116
109
addl_plugins) ?;
117
110
118
111
( outputs, expanded_crate, id)
@@ -123,10 +116,8 @@ pub fn compile_input(sess: &Session,
123
116
CompileState :: state_after_expand( input,
124
117
sess,
125
118
outdir,
126
- output,
127
- & cstore,
128
119
& expanded_crate,
129
- & id) ,
120
+ & id[ .. ] ) ,
130
121
Ok ( ( ) ) ) ;
131
122
132
123
let expanded_crate = assign_node_ids ( sess, expanded_crate) ;
@@ -171,13 +162,10 @@ pub fn compile_input(sess: &Session,
171
162
CompileState :: state_after_write_deps( input,
172
163
sess,
173
164
outdir,
174
- output,
175
- & arenas,
176
- & cstore,
177
165
& hir_map,
178
166
& expanded_crate,
179
167
& hir_map. krate( ) ,
180
- & id) ,
168
+ & id[ .. ] ) ,
181
169
Ok ( ( ) ) ) ;
182
170
}
183
171
@@ -206,17 +194,16 @@ pub fn compile_input(sess: &Session,
206
194
// Eventually, we will want to track plugins.
207
195
let _ignore = tcx. dep_graph . in_ignore ( ) ;
208
196
209
- let mut state = CompileState :: state_after_analysis ( input,
210
- sess,
211
- outdir,
212
- output,
213
- opt_crate,
214
- tcx. map . krate ( ) ,
215
- & analysis,
216
- mir_map. as_ref ( ) ,
217
- tcx,
218
- & id) ;
219
- ( control. after_analysis . callback ) ( & mut state) ;
197
+ let state = CompileState :: state_after_analysis ( input,
198
+ & tcx. sess ,
199
+ outdir,
200
+ opt_crate,
201
+ tcx. map . krate ( ) ,
202
+ & analysis,
203
+ mir_map. as_ref ( ) ,
204
+ tcx,
205
+ & id) ;
206
+ ( control. after_analysis . callback ) ( state) ;
220
207
221
208
if control. after_analysis . stop == Compilation :: Stop {
222
209
return result. and_then ( |_| Err ( 0usize ) ) ;
@@ -249,7 +236,7 @@ pub fn compile_input(sess: &Session,
249
236
250
237
controller_entry_point ! ( after_llvm,
251
238
sess,
252
- CompileState :: state_after_llvm( input, sess, outdir, output , & trans) ,
239
+ CompileState :: state_after_llvm( input, sess, outdir, & trans) ,
253
240
phase5_result) ;
254
241
phase5_result?;
255
242
@@ -324,7 +311,7 @@ pub struct PhaseController<'a> {
324
311
// If true then the compiler will try to run the callback even if the phase
325
312
// ends with an error. Note that this is not always possible.
326
313
pub run_callback_on_error : bool ,
327
- pub callback : Box < Fn ( & mut CompileState ) + ' a > ,
314
+ pub callback : Box < Fn ( CompileState ) -> ( ) + ' a > ,
328
315
}
329
316
330
317
impl < ' a > PhaseController < ' a > {
@@ -340,38 +327,34 @@ impl<'a> PhaseController<'a> {
340
327
/// State that is passed to a callback. What state is available depends on when
341
328
/// during compilation the callback is made. See the various constructor methods
342
329
/// (`state_*`) in the impl to see which data is provided for any given entry point.
343
- pub struct CompileState < ' a , ' b , ' ast : ' a , ' tcx : ' b > where ' ast : ' tcx {
330
+ pub struct CompileState < ' a , ' ast : ' a , ' tcx : ' a > {
344
331
pub input : & ' a Input ,
345
- pub session : & ' ast Session ,
346
- pub krate : Option < ast:: Crate > ,
347
- pub cstore : Option < & ' a CStore > ,
332
+ pub session : & ' a Session ,
333
+ pub cfg : Option < & ' a ast:: CrateConfig > ,
334
+ pub krate : Option < & ' a ast :: Crate > ,
348
335
pub crate_name : Option < & ' a str > ,
349
336
pub output_filenames : Option < & ' a OutputFilenames > ,
350
337
pub out_dir : Option < & ' a Path > ,
351
- pub out_file : Option < & ' a Path > ,
352
- pub arenas : Option < & ' ast ty:: CtxtArenas < ' ast > > ,
353
338
pub expanded_crate : Option < & ' a ast:: Crate > ,
354
339
pub hir_crate : Option < & ' a hir:: Crate > ,
355
340
pub ast_map : Option < & ' a hir_map:: Map < ' ast > > ,
356
- pub mir_map : Option < & ' b MirMap < ' tcx > > ,
341
+ pub mir_map : Option < & ' a MirMap < ' tcx > > ,
357
342
pub analysis : Option < & ' a ty:: CrateAnalysis < ' a > > ,
358
- pub tcx : Option < & ' b TyCtxt < ' tcx > > ,
343
+ pub tcx : Option < & ' a TyCtxt < ' tcx > > ,
359
344
pub trans : Option < & ' a trans:: CrateTranslation > ,
360
345
}
361
346
362
- impl < ' a , ' b , ' ast , ' tcx > CompileState < ' a , ' b , ' ast , ' tcx > {
347
+ impl < ' a , ' ast , ' tcx > CompileState < ' a , ' ast , ' tcx > {
363
348
fn empty ( input : & ' a Input ,
364
- session : & ' ast Session ,
349
+ session : & ' a Session ,
365
350
out_dir : & ' a Option < PathBuf > )
366
- -> CompileState < ' a , ' b , ' ast , ' tcx > {
351
+ -> CompileState < ' a , ' ast , ' tcx > {
367
352
CompileState {
368
353
input : input,
369
354
session : session,
370
355
out_dir : out_dir. as_ref ( ) . map ( |s| & * * s) ,
371
- out_file : None ,
372
- arenas : None ,
356
+ cfg : None ,
373
357
krate : None ,
374
- cstore : None ,
375
358
crate_name : None ,
376
359
output_filenames : None ,
377
360
expanded_crate : None ,
@@ -385,95 +368,71 @@ impl<'a, 'b, 'ast, 'tcx> CompileState<'a, 'b, 'ast, 'tcx> {
385
368
}
386
369
387
370
fn state_after_parse ( input : & ' a Input ,
388
- session : & ' ast Session ,
371
+ session : & ' a Session ,
389
372
out_dir : & ' a Option < PathBuf > ,
390
- out_file : & ' a Option < PathBuf > ,
391
- krate : ast:: Crate ,
392
- cstore : & ' a CStore )
393
- -> CompileState < ' a , ' b , ' ast , ' tcx > {
394
- CompileState {
395
- krate : Some ( krate) ,
396
- cstore : Some ( cstore) ,
397
- out_file : out_file. as_ref ( ) . map ( |s| & * * s) ,
398
- ..CompileState :: empty ( input, session, out_dir)
399
- }
373
+ krate : & ' a ast:: Crate )
374
+ -> CompileState < ' a , ' ast , ' tcx > {
375
+ CompileState { krate : Some ( krate) , ..CompileState :: empty ( input, session, out_dir) }
400
376
}
401
377
402
378
fn state_after_expand ( input : & ' a Input ,
403
- session : & ' ast Session ,
379
+ session : & ' a Session ,
404
380
out_dir : & ' a Option < PathBuf > ,
405
- out_file : & ' a Option < PathBuf > ,
406
- cstore : & ' a CStore ,
407
381
expanded_crate : & ' a ast:: Crate ,
408
382
crate_name : & ' a str )
409
- -> CompileState < ' a , ' b , ' ast , ' tcx > {
383
+ -> CompileState < ' a , ' ast , ' tcx > {
410
384
CompileState {
411
385
crate_name : Some ( crate_name) ,
412
- cstore : Some ( cstore) ,
413
386
expanded_crate : Some ( expanded_crate) ,
414
- out_file : out_file. as_ref ( ) . map ( |s| & * * s) ,
415
387
..CompileState :: empty ( input, session, out_dir)
416
388
}
417
389
}
418
390
419
391
fn state_after_write_deps ( input : & ' a Input ,
420
- session : & ' ast Session ,
392
+ session : & ' a Session ,
421
393
out_dir : & ' a Option < PathBuf > ,
422
- out_file : & ' a Option < PathBuf > ,
423
- arenas : & ' ast ty:: CtxtArenas < ' ast > ,
424
- cstore : & ' a CStore ,
425
394
hir_map : & ' a hir_map:: Map < ' ast > ,
426
395
krate : & ' a ast:: Crate ,
427
396
hir_crate : & ' a hir:: Crate ,
428
397
crate_name : & ' a str )
429
- -> CompileState < ' a , ' b , ' ast , ' tcx > {
398
+ -> CompileState < ' a , ' ast , ' tcx > {
430
399
CompileState {
431
400
crate_name : Some ( crate_name) ,
432
- arenas : Some ( arenas) ,
433
- cstore : Some ( cstore) ,
434
401
ast_map : Some ( hir_map) ,
435
- expanded_crate : Some ( krate) ,
402
+ krate : Some ( krate) ,
436
403
hir_crate : Some ( hir_crate) ,
437
- out_file : out_file. as_ref ( ) . map ( |s| & * * s) ,
438
404
..CompileState :: empty ( input, session, out_dir)
439
405
}
440
406
}
441
407
442
408
fn state_after_analysis ( input : & ' a Input ,
443
- session : & ' ast Session ,
409
+ session : & ' a Session ,
444
410
out_dir : & ' a Option < PathBuf > ,
445
- out_file : & ' a Option < PathBuf > ,
446
411
krate : Option < & ' a ast:: Crate > ,
447
412
hir_crate : & ' a hir:: Crate ,
448
- analysis : & ' a ty:: CrateAnalysis < ' a > ,
449
- mir_map : Option < & ' b MirMap < ' tcx > > ,
450
- tcx : & ' b TyCtxt < ' tcx > ,
413
+ analysis : & ' a ty:: CrateAnalysis ,
414
+ mir_map : Option < & ' a MirMap < ' tcx > > ,
415
+ tcx : & ' a TyCtxt < ' tcx > ,
451
416
crate_name : & ' a str )
452
- -> CompileState < ' a , ' b , ' ast , ' tcx > {
417
+ -> CompileState < ' a , ' ast , ' tcx > {
453
418
CompileState {
454
419
analysis : Some ( analysis) ,
455
420
mir_map : mir_map,
456
421
tcx : Some ( tcx) ,
457
- expanded_crate : krate,
422
+ krate : krate,
458
423
hir_crate : Some ( hir_crate) ,
459
424
crate_name : Some ( crate_name) ,
460
- out_file : out_file. as_ref ( ) . map ( |s| & * * s) ,
461
425
..CompileState :: empty ( input, session, out_dir)
462
426
}
463
427
}
464
428
465
429
466
430
fn state_after_llvm ( input : & ' a Input ,
467
- session : & ' ast Session ,
431
+ session : & ' a Session ,
468
432
out_dir : & ' a Option < PathBuf > ,
469
- out_file : & ' a Option < PathBuf > ,
470
433
trans : & ' a trans:: CrateTranslation )
471
- -> CompileState < ' a , ' b , ' ast , ' tcx > {
472
- CompileState {
473
- trans : Some ( trans) ,
474
- out_file : out_file. as_ref ( ) . map ( |s| & * * s) ,
475
- ..CompileState :: empty ( input, session, out_dir)
476
- }
434
+ -> CompileState < ' a , ' ast , ' tcx > {
435
+ CompileState { trans : Some ( trans) , ..CompileState :: empty ( input, session, out_dir) }
477
436
}
478
437
}
479
438
@@ -839,16 +798,16 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
839
798
let index = stability:: Index :: new ( & hir_map) ;
840
799
841
800
TyCtxt :: create_and_enter ( sess,
842
- arenas,
843
- def_map,
844
- named_region_map,
845
- hir_map,
846
- freevars,
847
- region_map,
848
- lang_items,
849
- index,
850
- name,
851
- |tcx| {
801
+ arenas,
802
+ def_map,
803
+ named_region_map,
804
+ hir_map,
805
+ freevars,
806
+ region_map,
807
+ lang_items,
808
+ index,
809
+ name,
810
+ |tcx| {
852
811
time ( time_passes,
853
812
"load_dep_graph" ,
854
813
|| rustc_incremental:: load_dep_graph ( tcx) ) ;
0 commit comments