Skip to content

Commit

Permalink
Make keep_ast configurable by driver clients
Browse files Browse the repository at this point in the history
  • Loading branch information
nrc committed Jul 24, 2017
1 parent 81fd86e commit 587a35d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/librustc_driver/driver.rs
Expand Up @@ -167,7 +167,7 @@ pub fn compile_input(sess: &Session,
hir::check_attr::check_crate(sess, &expanded_crate);
});

let opt_crate = if keep_ast(sess) {
let opt_crate = if control.keep_ast {
Some(&expanded_crate)
} else {
drop(expanded_crate);
Expand Down Expand Up @@ -263,9 +263,6 @@ fn keep_hygiene_data(sess: &Session) -> bool {
sess.opts.debugging_opts.keep_hygiene_data
}

fn keep_ast(sess: &Session) -> bool {
sess.opts.debugging_opts.keep_ast || ::save_analysis(sess)
}

/// The name used for source code that doesn't originate in a file
/// (e.g. source from stdin or a string)
Expand Down Expand Up @@ -304,6 +301,8 @@ pub struct CompileController<'a> {
pub compilation_done: PhaseController<'a>,

pub make_glob_map: MakeGlobMap,
// Whether the compiler should keep the ast beyond parsing.
pub keep_ast: bool,
}

impl<'a> CompileController<'a> {
Expand All @@ -316,6 +315,7 @@ impl<'a> CompileController<'a> {
after_llvm: PhaseController::basic(),
compilation_done: PhaseController::basic(),
make_glob_map: MakeGlobMap::No,
keep_ast: false,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_driver/lib.rs
Expand Up @@ -518,6 +518,8 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
-> CompileController<'a> {
let mut control = CompileController::basic();

control.keep_ast = sess.opts.debugging_opts.keep_ast || save_analysis(sess);

if let Some((ppm, opt_uii)) = parse_pretty(sess, matches) {
if ppm.needs_ast_map(&opt_uii) {
control.after_hir_lowering.stop = Compilation::Stop;
Expand Down

0 comments on commit 587a35d

Please sign in to comment.