@@ -359,11 +359,7 @@ fn run_compiler(
359
359
// printing some information without compiling, or exiting immediately
360
360
// after parsing, etc.
361
361
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 ( ( ) ) }
367
363
} ;
368
364
369
365
// This implements `-Whelp`. It should be handled very early, like
@@ -395,13 +391,16 @@ fn run_compiler(
395
391
396
392
let linker = compiler. enter( |queries| {
397
393
let early_exit = || early_exit( ) . map( |_| None ) ;
394
+
395
+ // Parse the crate root source code (doesn't parse submodules yet)
398
396
queries. parse( ) ?;
399
397
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( ) {
402
401
queries. global_ctxt( ) ?. enter( |tcx| {
403
402
tcx. ensure( ) . early_lint_checks( ( ) ) ;
404
- pretty:: print( sess, * ppm , pretty:: PrintExtra :: NeedsAstMap { tcx } ) ;
403
+ pretty:: print( sess, pp_mode , pretty:: PrintExtra :: NeedsAstMap { tcx } ) ;
405
404
Ok ( ( ) )
406
405
} ) ?;
407
406
@@ -412,7 +411,7 @@ fn run_compiler(
412
411
let krate = queries. parse( ) ?;
413
412
pretty:: print(
414
413
sess,
415
- * ppm ,
414
+ pp_mode ,
416
415
pretty:: PrintExtra :: AfterParsing { krate: & * krate. borrow( ) } ,
417
416
) ;
418
417
}
@@ -572,11 +571,7 @@ fn handle_explain(early_dcx: &EarlyDiagCtxt, registry: Registry, code: &str, col
572
571
fn show_md_content_with_pager( content: & str , color: ColorConfig ) {
573
572
let mut fallback_to_println = false ;
574
573
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" ) }
580
575
} ) ;
581
576
582
577
let mut cmd = Command :: new( & pager_name) ;
0 commit comments