Skip to content

Commit 587a35d

Browse files
committed
Make keep_ast configurable by driver clients
1 parent 81fd86e commit 587a35d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/librustc_driver/driver.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub fn compile_input(sess: &Session,
167167
hir::check_attr::check_crate(sess, &expanded_crate);
168168
});
169169

170-
let opt_crate = if keep_ast(sess) {
170+
let opt_crate = if control.keep_ast {
171171
Some(&expanded_crate)
172172
} else {
173173
drop(expanded_crate);
@@ -263,9 +263,6 @@ fn keep_hygiene_data(sess: &Session) -> bool {
263263
sess.opts.debugging_opts.keep_hygiene_data
264264
}
265265

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

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

306303
pub make_glob_map: MakeGlobMap,
304+
// Whether the compiler should keep the ast beyond parsing.
305+
pub keep_ast: bool,
307306
}
308307

309308
impl<'a> CompileController<'a> {
@@ -316,6 +315,7 @@ impl<'a> CompileController<'a> {
316315
after_llvm: PhaseController::basic(),
317316
compilation_done: PhaseController::basic(),
318317
make_glob_map: MakeGlobMap::No,
318+
keep_ast: false,
319319
}
320320
}
321321
}

src/librustc_driver/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,8 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
518518
-> CompileController<'a> {
519519
let mut control = CompileController::basic();
520520

521+
control.keep_ast = sess.opts.debugging_opts.keep_ast || save_analysis(sess);
522+
521523
if let Some((ppm, opt_uii)) = parse_pretty(sess, matches) {
522524
if ppm.needs_ast_map(&opt_uii) {
523525
control.after_hir_lowering.stop = Compilation::Stop;

0 commit comments

Comments
 (0)