Skip to content

Commit 3876eaf

Browse files
author
Orion Gonzalez
committed
clarify a few things
1 parent 9459806 commit 3876eaf

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

compiler/rustc_driver_impl/src/lib.rs

+9-14
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,7 @@ fn run_compiler(
359359
// printing some information without compiling, or exiting immediately
360360
// after parsing, etc.
361361
let early_exit = || {
362-
if let Some(guar) = sess.dcx().has_errors() {
363-
Err(guar)
364-
} else {
365-
Ok(())
366-
}
362+
if let Some(guar) = sess.dcx().has_errors() { Err(guar) } else { Ok(()) }
367363
};
368364

369365
// This implements `-Whelp`. It should be handled very early, like
@@ -395,13 +391,16 @@ fn run_compiler(
395391

396392
let linker = compiler.enter(|queries| {
397393
let early_exit = || early_exit().map(|_| None);
394+
395+
// Parse the crate root source code (doesn't parse submodules yet)
398396
queries.parse()?;
399397

400-
if let Some(ppm) = &sess.opts.pretty {
401-
if ppm.needs_ast_map() {
398+
// If pretty printing is requested: Figure out the representation, print it and exit
399+
if let Some(pp_mode) = sess.opts.pretty {
400+
if pp_mode.needs_ast_map() {
402401
queries.global_ctxt()?.enter(|tcx| {
403402
tcx.ensure().early_lint_checks(());
404-
pretty::print(sess, *ppm, pretty::PrintExtra::NeedsAstMap { tcx });
403+
pretty::print(sess, pp_mode, pretty::PrintExtra::NeedsAstMap { tcx });
405404
Ok(())
406405
})?;
407406

@@ -412,7 +411,7 @@ fn run_compiler(
412411
let krate = queries.parse()?;
413412
pretty::print(
414413
sess,
415-
*ppm,
414+
pp_mode,
416415
pretty::PrintExtra::AfterParsing { krate: &*krate.borrow() },
417416
);
418417
}
@@ -572,11 +571,7 @@ fn handle_explain(early_dcx: &EarlyDiagCtxt, registry: Registry, code: &str, col
572571
fn show_md_content_with_pager(content: &str, color: ColorConfig) {
573572
let mut fallback_to_println = false;
574573
let pager_name = env::var_os("PAGER").unwrap_or_else(|| {
575-
if cfg!(windows) {
576-
OsString::from("more.com")
577-
} else {
578-
OsString::from("less")
579-
}
574+
if cfg!(windows) { OsString::from("more.com") } else { OsString::from("less") }
580575
});
581576

582577
let mut cmd = Command::new(&pager_name);

compiler/rustc_session/src/config.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2893,6 +2893,7 @@ pub enum PpHirMode {
28932893
}
28942894

28952895
#[derive(Copy, Clone, PartialEq, Debug)]
2896+
/// Pretty print mode
28962897
pub enum PpMode {
28972898
/// Options that print the source code, i.e.
28982899
/// `-Zunpretty=normal` and `-Zunpretty=expanded`

0 commit comments

Comments
 (0)