diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2017-07-24 17:06:42 +1200 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2017-07-24 17:25:16 +1200 |
| commit | 587a35da680b09ebd466dbd75d146a74d372594c (patch) | |
| tree | 717aa01c4ec709939ff06b2a6b916f276cde8e0d | |
| parent | 81fd86e0680947aa346c2c1d5b213ab036b68710 (diff) | |
| download | rust-587a35da680b09ebd466dbd75d146a74d372594c.tar.gz rust-587a35da680b09ebd466dbd75d146a74d372594c.zip | |
Make keep_ast configurable by driver clients
| -rw-r--r-- | src/librustc_driver/driver.rs | 8 | ||||
| -rw-r--r-- | src/librustc_driver/lib.rs | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 7faf78ce638..c592882a1e4 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -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); @@ -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) @@ -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> { @@ -316,6 +315,7 @@ impl<'a> CompileController<'a> { after_llvm: PhaseController::basic(), compilation_done: PhaseController::basic(), make_glob_map: MakeGlobMap::No, + keep_ast: false, } } } diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index d0229187c2a..e139f81416e 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -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; |
