Skip to content

Commit 4f606c5

Browse files
committed
---
yaml --- r: 277980 b: refs/heads/auto c: 52a2b33 h: refs/heads/master
1 parent a8a1fa2 commit 4f606c5

File tree

4 files changed

+331
-264
lines changed

4 files changed

+331
-264
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: 7ee02d9f4d94f6a826d10529419b64a4ccd2a405
11+
refs/heads/auto: 52a2b33a4b1c9f10e7034a758d4dff4f53129a49
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/librustc_driver/driver.rs

Lines changed: 61 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub fn compile_input(sess: &Session,
112112
let expanded_crate = phase_2_configure_and_expand(sess,
113113
&cstore,
114114
krate,
115-
&id[..],
115+
&id,
116116
addl_plugins)?;
117117

118118
(outputs, expanded_crate, id)
@@ -123,8 +123,10 @@ pub fn compile_input(sess: &Session,
123123
CompileState::state_after_expand(input,
124124
sess,
125125
outdir,
126+
output,
127+
&cstore,
126128
&expanded_crate,
127-
&id[..]),
129+
&id),
128130
Ok(()));
129131

130132
let expanded_crate = assign_node_ids(sess, expanded_crate);
@@ -169,10 +171,13 @@ pub fn compile_input(sess: &Session,
169171
CompileState::state_after_write_deps(input,
170172
sess,
171173
outdir,
174+
output,
175+
&arenas,
176+
&cstore,
172177
&hir_map,
173178
&expanded_crate,
174179
&hir_map.krate(),
175-
&id[..]),
180+
&id),
176181
Ok(()));
177182
}
178183

@@ -202,8 +207,9 @@ pub fn compile_input(sess: &Session,
202207
let _ignore = tcx.dep_graph.in_ignore();
203208

204209
let mut state = CompileState::state_after_analysis(input,
205-
&tcx.sess,
210+
sess,
206211
outdir,
212+
output,
207213
opt_crate,
208214
tcx.map.krate(),
209215
&analysis,
@@ -243,7 +249,7 @@ pub fn compile_input(sess: &Session,
243249

244250
controller_entry_point!(after_llvm,
245251
sess,
246-
CompileState::state_after_llvm(input, sess, outdir, &trans),
252+
CompileState::state_after_llvm(input, sess, outdir, output, &trans),
247253
phase5_result);
248254
phase5_result?;
249255

@@ -334,34 +340,36 @@ impl<'a> PhaseController<'a> {
334340
/// State that is passed to a callback. What state is available depends on when
335341
/// during compilation the callback is made. See the various constructor methods
336342
/// (`state_*`) in the impl to see which data is provided for any given entry point.
337-
pub struct CompileState<'a, 'ast: 'a, 'tcx: 'a> {
343+
pub struct CompileState<'a, 'b, 'ast: 'a, 'tcx: 'b> where 'ast: 'tcx {
338344
pub input: &'a Input,
339-
pub session: &'a Session,
345+
pub session: &'ast Session,
340346
pub krate: Option<ast::Crate>,
341347
pub cstore: Option<&'a CStore>,
342348
pub crate_name: Option<&'a str>,
343349
pub output_filenames: Option<&'a OutputFilenames>,
344350
pub out_dir: Option<&'a Path>,
345351
pub out_file: Option<&'a Path>,
352+
pub arenas: Option<&'ast ty::CtxtArenas<'ast>>,
346353
pub expanded_crate: Option<&'a ast::Crate>,
347354
pub hir_crate: Option<&'a hir::Crate>,
348355
pub ast_map: Option<&'a hir_map::Map<'ast>>,
349-
pub mir_map: Option<&'a MirMap<'tcx>>,
356+
pub mir_map: Option<&'b MirMap<'tcx>>,
350357
pub analysis: Option<&'a ty::CrateAnalysis<'a>>,
351-
pub tcx: Option<&'a TyCtxt<'tcx>>,
358+
pub tcx: Option<&'b TyCtxt<'tcx>>,
352359
pub trans: Option<&'a trans::CrateTranslation>,
353360
}
354361

355-
impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
362+
impl<'a, 'b, 'ast, 'tcx> CompileState<'a, 'b, 'ast, 'tcx> {
356363
fn empty(input: &'a Input,
357-
session: &'a Session,
364+
session: &'ast Session,
358365
out_dir: &'a Option<PathBuf>)
359-
-> CompileState<'a, 'ast, 'tcx> {
366+
-> CompileState<'a, 'b, 'ast, 'tcx> {
360367
CompileState {
361368
input: input,
362369
session: session,
363370
out_dir: out_dir.as_ref().map(|s| &**s),
364371
out_file: None,
372+
arenas: None,
365373
krate: None,
366374
cstore: None,
367375
crate_name: None,
@@ -377,12 +385,12 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
377385
}
378386

379387
fn state_after_parse(input: &'a Input,
380-
session: &'a Session,
388+
session: &'ast Session,
381389
out_dir: &'a Option<PathBuf>,
382390
out_file: &'a Option<PathBuf>,
383391
krate: ast::Crate,
384392
cstore: &'a CStore)
385-
-> CompileState<'a, 'ast, 'tcx> {
393+
-> CompileState<'a, 'b, 'ast, 'tcx> {
386394
CompileState {
387395
krate: Some(krate),
388396
cstore: Some(cstore),
@@ -392,63 +400,80 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
392400
}
393401

394402
fn state_after_expand(input: &'a Input,
395-
session: &'a Session,
403+
session: &'ast Session,
396404
out_dir: &'a Option<PathBuf>,
405+
out_file: &'a Option<PathBuf>,
406+
cstore: &'a CStore,
397407
expanded_crate: &'a ast::Crate,
398408
crate_name: &'a str)
399-
-> CompileState<'a, 'ast, 'tcx> {
409+
-> CompileState<'a, 'b, 'ast, 'tcx> {
400410
CompileState {
401411
crate_name: Some(crate_name),
412+
cstore: Some(cstore),
402413
expanded_crate: Some(expanded_crate),
414+
out_file: out_file.as_ref().map(|s| &**s),
403415
..CompileState::empty(input, session, out_dir)
404416
}
405417
}
406418

407419
fn state_after_write_deps(input: &'a Input,
408-
session: &'a Session,
420+
session: &'ast Session,
409421
out_dir: &'a Option<PathBuf>,
422+
out_file: &'a Option<PathBuf>,
423+
arenas: &'ast ty::CtxtArenas<'ast>,
424+
cstore: &'a CStore,
410425
hir_map: &'a hir_map::Map<'ast>,
411426
krate: &'a ast::Crate,
412427
hir_crate: &'a hir::Crate,
413428
crate_name: &'a str)
414-
-> CompileState<'a, 'ast, 'tcx> {
429+
-> CompileState<'a, 'b, 'ast, 'tcx> {
415430
CompileState {
416431
crate_name: Some(crate_name),
432+
arenas: Some(arenas),
433+
cstore: Some(cstore),
417434
ast_map: Some(hir_map),
418435
expanded_crate: Some(krate),
419436
hir_crate: Some(hir_crate),
437+
out_file: out_file.as_ref().map(|s| &**s),
420438
..CompileState::empty(input, session, out_dir)
421439
}
422440
}
423441

424442
fn state_after_analysis(input: &'a Input,
425-
session: &'a Session,
443+
session: &'ast Session,
426444
out_dir: &'a Option<PathBuf>,
445+
out_file: &'a Option<PathBuf>,
427446
krate: Option<&'a ast::Crate>,
428447
hir_crate: &'a hir::Crate,
429-
analysis: &'a ty::CrateAnalysis,
430-
mir_map: Option<&'a MirMap<'tcx>>,
431-
tcx: &'a TyCtxt<'tcx>,
448+
analysis: &'a ty::CrateAnalysis<'a>,
449+
mir_map: Option<&'b MirMap<'tcx>>,
450+
tcx: &'b TyCtxt<'tcx>,
432451
crate_name: &'a str)
433-
-> CompileState<'a, 'ast, 'tcx> {
452+
-> CompileState<'a, 'b, 'ast, 'tcx> {
434453
CompileState {
435454
analysis: Some(analysis),
436455
mir_map: mir_map,
437456
tcx: Some(tcx),
438457
expanded_crate: krate,
439458
hir_crate: Some(hir_crate),
440459
crate_name: Some(crate_name),
460+
out_file: out_file.as_ref().map(|s| &**s),
441461
..CompileState::empty(input, session, out_dir)
442462
}
443463
}
444464

445465

446466
fn state_after_llvm(input: &'a Input,
447-
session: &'a Session,
467+
session: &'ast Session,
448468
out_dir: &'a Option<PathBuf>,
469+
out_file: &'a Option<PathBuf>,
449470
trans: &'a trans::CrateTranslation)
450-
-> CompileState<'a, 'ast, 'tcx> {
451-
CompileState { trans: Some(trans), ..CompileState::empty(input, session, out_dir) }
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+
}
452477
}
453478
}
454479

@@ -814,16 +839,16 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
814839
let index = stability::Index::new(&hir_map);
815840

816841
TyCtxt::create_and_enter(sess,
817-
arenas,
818-
def_map,
819-
named_region_map,
820-
hir_map,
821-
freevars,
822-
region_map,
823-
lang_items,
824-
index,
825-
name,
826-
|tcx| {
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| {
827852
time(time_passes,
828853
"load_dep_graph",
829854
|| rustc_incremental::load_dep_graph(tcx));

branches/auto/src/librustc_driver/lib.rs

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -450,17 +450,39 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
450450
fn build_controller(&mut self, sess: &Session, matches: &getopts::Matches) -> CompileController<'a> {
451451
let mut control = CompileController::basic();
452452

453-
if let Some((ppm, opt_uii)) = parse_pretty(&sess, &matches) {
454-
control.after_parse.stop = Compilation::Stop;
455-
control.after_parse.callback = box move |state| {
456-
pretty::pretty_print_input(state.session,
457-
state.cstore.unwrap(),
458-
state.input,
459-
state.krate.take().unwrap(),
460-
ppm,
461-
opt_uii.clone(),
462-
state.out_file);
463-
};
453+
if let Some((ppm, opt_uii)) = parse_pretty(sess, matches) {
454+
if ppm.needs_ast_map(&opt_uii) {
455+
control.after_write_deps.stop = Compilation::Stop;
456+
457+
control.after_parse.callback = box move |state| {
458+
state.krate = Some(pretty::fold_crate(state.krate.take().unwrap(), ppm));
459+
};
460+
control.after_write_deps.callback = box move |state| {
461+
pretty::print_after_write_deps(state.session,
462+
state.cstore.unwrap(),
463+
state.ast_map.unwrap(),
464+
state.input,
465+
&state.expanded_crate.take().unwrap(),
466+
state.crate_name.unwrap(),
467+
ppm,
468+
state.arenas.unwrap(),
469+
opt_uii.clone(),
470+
state.out_file);
471+
};
472+
} else {
473+
control.after_parse.stop = Compilation::Stop;
474+
475+
control.after_parse.callback = box move |state| {
476+
let krate = pretty::fold_crate(state.krate.take().unwrap(), ppm);
477+
pretty::print_after_parsing(state.session,
478+
state.input,
479+
&krate,
480+
ppm,
481+
state.out_file);
482+
};
483+
}
484+
485+
return control;
464486
}
465487

466488
if sess.opts.parse_only || sess.opts.debugging_opts.show_span.is_some() ||

0 commit comments

Comments
 (0)