@@ -28,8 +28,6 @@ use std::{env, fs, io, str};
28
28
use build_helper:: ci:: gha;
29
29
use build_helper:: exit;
30
30
use termcolor:: { ColorChoice , StandardStream , WriteColor } ;
31
- #[ cfg( feature = "tracing" ) ]
32
- use tracing:: { debug, instrument, span, trace} ;
33
31
use utils:: build_stamp:: BuildStamp ;
34
32
use utils:: channel:: GitInfo ;
35
33
@@ -46,6 +44,8 @@ pub use core::builder::PathSet;
46
44
pub use core:: config:: Config ;
47
45
pub use core:: config:: flags:: { Flags , Subcommand } ;
48
46
47
+ #[ cfg( feature = "tracing" ) ]
48
+ use tracing:: { instrument, span} ;
49
49
pub use utils:: change_tracker:: {
50
50
CONFIG_CHANGE_HISTORY , find_recent_config_change_ids, human_readable_changes,
51
51
} ;
@@ -541,72 +541,71 @@ impl Build {
541
541
/// Executes the entire build, as configured by the flags and configuration.
542
542
#[ cfg_attr( feature = "tracing" , instrument( level = "debug" , name = "Build::build" , skip_all) ) ]
543
543
pub fn build ( & mut self ) {
544
- #[ cfg( feature = "tracing" ) ]
545
544
trace ! ( "setting up job management" ) ;
546
545
unsafe {
547
546
crate :: utils:: job:: setup ( self ) ;
548
547
}
549
548
550
- #[ cfg( feature = "tracing" ) ]
551
- trace ! ( "downloading rustfmt early" ) ;
552
-
553
549
// Download rustfmt early so that it can be used in rust-analyzer configs.
550
+ trace ! ( "downloading rustfmt early" ) ;
554
551
let _ = & builder:: Builder :: new ( self ) . initial_rustfmt ( ) ;
555
552
556
- #[ cfg( feature = "tracing" ) ]
557
- let hardcoded_span =
558
- span ! ( tracing:: Level :: DEBUG , "handling hardcoded subcommands (Format, Suggest, Perf)" )
559
- . entered ( ) ;
560
-
561
- // hardcoded subcommands
562
- match & self . config . cmd {
563
- Subcommand :: Format { check, all } => {
564
- return core:: build_steps:: format:: format (
565
- & builder:: Builder :: new ( self ) ,
566
- * check,
567
- * all,
568
- & self . config . paths ,
569
- ) ;
570
- }
571
- Subcommand :: Suggest { run } => {
572
- return core:: build_steps:: suggest:: suggest ( & builder:: Builder :: new ( self ) , * run) ;
573
- }
574
- Subcommand :: Perf { .. } => {
575
- return core:: build_steps:: perf:: perf ( & builder:: Builder :: new ( self ) ) ;
576
- }
577
- _cmd => {
578
- #[ cfg( feature = "tracing" ) ]
579
- debug ! ( cmd = ?_cmd, "not a hardcoded subcommand; returning to normal handling" ) ;
553
+ // Handle hard-coded subcommands.
554
+ {
555
+ #[ cfg( feature = "tracing" ) ]
556
+ let _hardcoded_span = span ! (
557
+ tracing:: Level :: DEBUG ,
558
+ "handling hardcoded subcommands (Format, Suggest, Perf)"
559
+ )
560
+ . entered ( ) ;
561
+
562
+ match & self . config . cmd {
563
+ Subcommand :: Format { check, all } => {
564
+ return core:: build_steps:: format:: format (
565
+ & builder:: Builder :: new ( self ) ,
566
+ * check,
567
+ * all,
568
+ & self . config . paths ,
569
+ ) ;
570
+ }
571
+ Subcommand :: Suggest { run } => {
572
+ return core:: build_steps:: suggest:: suggest ( & builder:: Builder :: new ( self ) , * run) ;
573
+ }
574
+ Subcommand :: Perf { .. } => {
575
+ return core:: build_steps:: perf:: perf ( & builder:: Builder :: new ( self ) ) ;
576
+ }
577
+ _cmd => {
578
+ debug ! ( cmd = ?_cmd, "not a hardcoded subcommand; returning to normal handling" ) ;
579
+ }
580
580
}
581
- }
582
581
583
- #[ cfg( feature = "tracing" ) ]
584
- drop ( hardcoded_span) ;
585
- #[ cfg( feature = "tracing" ) ]
586
- debug ! ( "handling subcommand normally" ) ;
582
+ debug ! ( "handling subcommand normally" ) ;
583
+ }
587
584
588
585
if !self . config . dry_run ( ) {
589
586
#[ cfg( feature = "tracing" ) ]
590
587
let _real_run_span = span ! ( tracing:: Level :: DEBUG , "executing real run" ) . entered ( ) ;
591
588
589
+ // We first do a dry-run. This is a sanity-check to ensure that
590
+ // steps don't do anything expensive in the dry-run.
592
591
{
593
592
#[ cfg( feature = "tracing" ) ]
594
593
let _sanity_check_span =
595
594
span ! ( tracing:: Level :: DEBUG , "(1) executing dry-run sanity-check" ) . entered ( ) ;
596
-
597
- // We first do a dry-run. This is a sanity-check to ensure that
598
- // steps don't do anything expensive in the dry-run.
599
595
self . config . dry_run = DryRun :: SelfCheck ;
600
596
let builder = builder:: Builder :: new ( self ) ;
601
597
builder. execute_cli ( ) ;
602
598
}
603
599
604
- #[ cfg( feature = "tracing" ) ]
605
- let _actual_run_span =
606
- span ! ( tracing:: Level :: DEBUG , "(2) executing actual run" ) . entered ( ) ;
607
- self . config . dry_run = DryRun :: Disabled ;
608
- let builder = builder:: Builder :: new ( self ) ;
609
- builder. execute_cli ( ) ;
600
+ // Actual run.
601
+ {
602
+ #[ cfg( feature = "tracing" ) ]
603
+ let _actual_run_span =
604
+ span ! ( tracing:: Level :: DEBUG , "(2) executing actual run" ) . entered ( ) ;
605
+ self . config . dry_run = DryRun :: Disabled ;
606
+ let builder = builder:: Builder :: new ( self ) ;
607
+ builder. execute_cli ( ) ;
608
+ }
610
609
} else {
611
610
#[ cfg( feature = "tracing" ) ]
612
611
let _dry_run_span = span ! ( tracing:: Level :: DEBUG , "executing dry run" ) . entered ( ) ;
0 commit comments