clarify a few things

This commit is contained in:
Orion Gonzalez 2024-08-27 20:04:47 +02:00
parent b218623ea0
commit a007d349a1
2 changed files with 9 additions and 4 deletions

View File

@ -391,13 +391,17 @@ fn run_compiler(
let linker = compiler.enter(|queries| { let linker = compiler.enter(|queries| {
let early_exit = || early_exit().map(|_| None); let early_exit = || early_exit().map(|_| None);
// Parse the crate root source code (doesn't parse submodules yet)
// Everything else is parsed during macro expansion.
queries.parse()?; queries.parse()?;
if let Some(ppm) = &sess.opts.pretty { // If pretty printing is requested: Figure out the representation, print it and exit
if ppm.needs_ast_map() { if let Some(pp_mode) = sess.opts.pretty {
if pp_mode.needs_ast_map() {
queries.global_ctxt()?.enter(|tcx| { queries.global_ctxt()?.enter(|tcx| {
tcx.ensure().early_lint_checks(()); tcx.ensure().early_lint_checks(());
pretty::print(sess, *ppm, pretty::PrintExtra::NeedsAstMap { tcx }); pretty::print(sess, pp_mode, pretty::PrintExtra::NeedsAstMap { tcx });
Ok(()) Ok(())
})?; })?;
@ -408,7 +412,7 @@ fn run_compiler(
let krate = queries.parse()?; let krate = queries.parse()?;
pretty::print( pretty::print(
sess, sess,
*ppm, pp_mode,
pretty::PrintExtra::AfterParsing { krate: &*krate.borrow() }, pretty::PrintExtra::AfterParsing { krate: &*krate.borrow() },
); );
} }

View File

@ -2893,6 +2893,7 @@ pub enum PpHirMode {
} }
#[derive(Copy, Clone, PartialEq, Debug)] #[derive(Copy, Clone, PartialEq, Debug)]
/// Pretty print mode
pub enum PpMode { pub enum PpMode {
/// Options that print the source code, i.e. /// Options that print the source code, i.e.
/// `-Zunpretty=normal` and `-Zunpretty=expanded` /// `-Zunpretty=normal` and `-Zunpretty=expanded`