@@ -387,80 +387,69 @@ fn run_compiler(
387
387
return early_exit( ) ;
388
388
}
389
389
390
- let linker = compiler. enter( |queries| {
390
+ // Parse the crate root source code (doesn't parse submodules yet)
391
+ // Everything else is parsed during macro expansion.
392
+ let krate = passes:: parse( sess) ;
393
+
394
+ // If pretty printing is requested: Figure out the representation, print it and exit
395
+ if let Some ( pp_mode) = sess. opts. pretty {
396
+ if pp_mode. needs_ast_map( ) {
397
+ create_and_enter_global_ctxt( & compiler, krate, |tcx| {
398
+ tcx. ensure( ) . early_lint_checks( ( ) ) ;
399
+ pretty:: print( sess, pp_mode, pretty:: PrintExtra :: NeedsAstMap { tcx } ) ;
400
+ passes:: write_dep_info( tcx) ;
401
+ } ) ;
402
+ } else {
403
+ pretty:: print( sess, pp_mode, pretty:: PrintExtra :: AfterParsing { krate: & krate } ) ;
404
+ }
405
+ trace!( "finished pretty-printing" ) ;
406
+ return early_exit( ) ;
407
+ }
408
+
409
+ if callbacks. after_crate_root_parsing( compiler, & krate) == Compilation :: Stop {
410
+ return early_exit( ) ;
411
+ }
412
+
413
+ if sess. opts. unstable_opts. parse_crate_root_only {
414
+ return early_exit( ) ;
415
+ }
416
+
417
+ let linker = create_and_enter_global_ctxt( & compiler, krate, |tcx| {
391
418
let early_exit = || {
392
419
sess. dcx( ) . abort_if_errors( ) ;
393
420
None
394
421
} ;
395
422
396
- // Parse the crate root source code (doesn't parse submodules yet)
397
- // Everything else is parsed during macro expansion.
398
- queries. parse( ) ;
423
+ // Make sure name resolution and macro expansion is run.
424
+ let _ = tcx. resolver_for_lowering( ) ;
399
425
400
- // If pretty printing is requested: Figure out the representation, print it and exit
401
- if let Some ( pp_mode) = sess. opts. pretty {
402
- if pp_mode. needs_ast_map( ) {
403
- let krate = queries. parse( ) . steal( ) ;
426
+ if let Some ( metrics_dir) = & sess. opts. unstable_opts. metrics_dir {
427
+ dump_feature_usage_metrics( tcx, metrics_dir) ;
428
+ }
404
429
405
- create_and_enter_global_ctxt( & compiler, krate, |tcx| {
406
- tcx. ensure( ) . early_lint_checks( ( ) ) ;
407
- pretty:: print( sess, pp_mode, pretty:: PrintExtra :: NeedsAstMap { tcx } ) ;
408
- passes:: write_dep_info( tcx) ;
409
- } ) ;
410
- } else {
411
- let krate = queries. parse( ) ;
412
- pretty:: print( sess, pp_mode, pretty:: PrintExtra :: AfterParsing {
413
- krate: & * krate. borrow( ) ,
414
- } ) ;
415
- }
416
- trace!( "finished pretty-printing" ) ;
430
+ if callbacks. after_expansion( compiler, tcx) == Compilation :: Stop {
417
431
return early_exit( ) ;
418
432
}
419
433
420
- if callbacks. after_crate_root_parsing( compiler, & * queries. parse( ) . borrow( ) )
421
- == Compilation :: Stop
434
+ passes:: write_dep_info( tcx) ;
435
+
436
+ if sess. opts. output_types. contains_key( & OutputType :: DepInfo )
437
+ && sess. opts. output_types. len( ) == 1
422
438
{
423
439
return early_exit( ) ;
424
440
}
425
441
426
- if sess. opts. unstable_opts. parse_crate_root_only {
442
+ if sess. opts. unstable_opts. no_analysis {
427
443
return early_exit( ) ;
428
444
}
429
445
430
- let krate = queries . parse ( ) . steal ( ) ;
446
+ tcx . ensure ( ) . analysis ( ( ) ) ;
431
447
432
- create_and_enter_global_ctxt( & compiler, krate, |tcx| {
433
- // Make sure name resolution and macro expansion is run.
434
- let _ = tcx. resolver_for_lowering( ) ;
435
-
436
- if let Some ( metrics_dir) = & sess. opts. unstable_opts. metrics_dir {
437
- dump_feature_usage_metrics( tcx, metrics_dir) ;
438
- }
439
-
440
- if callbacks. after_expansion( compiler, tcx) == Compilation :: Stop {
441
- return early_exit( ) ;
442
- }
443
-
444
- passes:: write_dep_info( tcx) ;
445
-
446
- if sess. opts. output_types. contains_key( & OutputType :: DepInfo )
447
- && sess. opts. output_types. len( ) == 1
448
- {
449
- return early_exit( ) ;
450
- }
451
-
452
- if sess. opts. unstable_opts. no_analysis {
453
- return early_exit( ) ;
454
- }
455
-
456
- tcx. ensure( ) . analysis( ( ) ) ;
457
-
458
- if callbacks. after_analysis( compiler, tcx) == Compilation :: Stop {
459
- return early_exit( ) ;
460
- }
448
+ if callbacks. after_analysis( compiler, tcx) == Compilation :: Stop {
449
+ return early_exit( ) ;
450
+ }
461
451
462
- Some ( Linker :: codegen_and_build_linker( tcx, & * compiler. codegen_backend) )
463
- } )
452
+ Some ( Linker :: codegen_and_build_linker( tcx, & * compiler. codegen_backend) )
464
453
} ) ;
465
454
466
455
// Linking is done outside the `compiler.enter()` so that the
0 commit comments