Skip to content

Commit

Permalink
In the rustc driver, we pass the expanded, not the pre-expansion, AST…
Browse files Browse the repository at this point in the history
… to the post-analysis callback. We can also pass this to post-write-deps callback.
  • Loading branch information
nrc committed Feb 21, 2015
1 parent 522d09d commit 712a687
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/librustc_driver/driver.rs
Expand Up @@ -112,6 +112,7 @@ pub fn compile_input(sess: Session,
&sess,
outdir,
&ast_map,
&ast_map.krate(),
&id[..]));

let analysis = phase_3_run_analysis_passes(sess,
Expand Down Expand Up @@ -287,26 +288,28 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> {
session: &'a Session,
out_dir: &'a Option<Path>,
ast_map: &'a ast_map::Map<'ast>,
expanded_crate: &'a ast::Crate,
crate_name: &'a str)
-> CompileState<'a, 'ast, 'tcx> {
CompileState {
crate_name: Some(crate_name),
ast_map: Some(ast_map),
expanded_crate: Some(expanded_crate),
.. CompileState::empty(input, session, out_dir)
}
}

fn state_after_analysis(input: &'a Input,
session: &'a Session,
out_dir: &'a Option<Path>,
krate: &'a ast::Crate,
expanded_crate: &'a ast::Crate,
analysis: &'a ty::CrateAnalysis<'tcx>,
tcx: &'a ty::ctxt<'tcx>)
-> CompileState<'a, 'ast, 'tcx> {
CompileState {
analysis: Some(analysis),
tcx: Some(tcx),
krate: Some(krate),
expanded_crate: Some(expanded_crate),
.. CompileState::empty(input, session, out_dir)
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/librustc_driver/lib.rs
Expand Up @@ -373,11 +373,13 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {

if sess.opts.debugging_opts.save_analysis {
control.after_analysis.callback = box |state| {
time(state.session.time_passes(), "save analysis", state.krate.unwrap(), |krate|
save::process_crate(state.session,
krate,
state.analysis.unwrap(),
state.out_dir));
time(state.session.time_passes(),
"save analysis",
state.expanded_crate.unwrap(),
|krate| save::process_crate(state.session,
krate,
state.analysis.unwrap(),
state.out_dir));
};
control.make_glob_map = resolve::MakeGlobMap::Yes;
}
Expand Down

0 comments on commit 712a687

Please sign in to comment.