@@ -370,132 +370,18 @@ impl Step for CodegenBackend {
370
370
}
371
371
}
372
372
373
- /// Checks Rust analyzer that links to .rmetas from a checked rustc.
374
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
375
- pub struct RustAnalyzer {
376
- pub build_compiler : Compiler ,
377
- pub target : TargetSelection ,
378
- }
379
-
380
- impl Step for RustAnalyzer {
381
- type Output = ( ) ;
382
- const ONLY_HOSTS : bool = true ;
383
- const DEFAULT : bool = true ;
384
-
385
- fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
386
- let builder = run. builder ;
387
- run. path ( "src/tools/rust-analyzer" ) . default_condition (
388
- builder
389
- . config
390
- . tools
391
- . as_ref ( )
392
- . is_none_or ( |tools| tools. iter ( ) . any ( |tool| tool == "rust-analyzer" ) ) ,
393
- )
394
- }
395
-
396
- fn make_run ( run : RunConfig < ' _ > ) {
397
- let build_compiler = prepare_compiler_for_check ( run. builder , run. target , Mode :: ToolRustc ) ;
398
- run. builder . ensure ( RustAnalyzer { build_compiler, target : run. target } ) ;
399
- }
400
-
401
- fn run ( self , builder : & Builder < ' _ > ) {
402
- let build_compiler = self . build_compiler ;
403
- let target = self . target ;
404
-
405
- let mut cargo = prepare_tool_cargo (
406
- builder,
407
- build_compiler,
408
- Mode :: ToolRustc ,
409
- target,
410
- builder. kind ,
411
- "src/tools/rust-analyzer" ,
412
- SourceType :: InTree ,
413
- & [ "in-rust-tree" . to_owned ( ) ] ,
414
- ) ;
415
-
416
- cargo. allow_features ( crate :: core:: build_steps:: tool:: RustAnalyzer :: ALLOW_FEATURES ) ;
417
-
418
- cargo. arg ( "--bins" ) ;
419
- cargo. arg ( "--tests" ) ;
420
- cargo. arg ( "--benches" ) ;
421
-
422
- // Cargo's output path in a given stage, compiled by a particular
423
- // compiler for the specified target.
424
- let stamp = BuildStamp :: new ( & builder. cargo_out ( build_compiler, Mode :: ToolRustc , target) )
425
- . with_prefix ( "rust-analyzer-check" ) ;
426
-
427
- let _guard = builder. msg_check ( "rust-analyzer artifacts" , target, None ) ;
428
- run_cargo ( builder, cargo, builder. config . free_args . clone ( ) , & stamp, vec ! [ ] , true , false ) ;
429
- }
430
-
431
- fn metadata ( & self ) -> Option < StepMetadata > {
432
- Some ( StepMetadata :: check ( "rust-analyzer" , self . target ) . built_by ( self . build_compiler ) )
433
- }
434
- }
435
-
436
- /// Compiletest is implicitly "checked" when it gets built in order to run tests,
437
- /// so this is mainly for people working on compiletest to run locally.
438
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
439
- pub struct Compiletest {
440
- pub target : TargetSelection ,
441
- }
442
-
443
- impl Step for Compiletest {
444
- type Output = ( ) ;
445
- const ONLY_HOSTS : bool = true ;
446
- const DEFAULT : bool = false ;
447
-
448
- fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
449
- run. path ( "src/tools/compiletest" )
450
- }
451
-
452
- fn make_run ( run : RunConfig < ' _ > ) {
453
- run. builder . ensure ( Compiletest { target : run. target } ) ;
454
- }
455
-
456
- fn run ( self , builder : & Builder < ' _ > ) {
457
- let mode = if builder. config . compiletest_use_stage0_libtest {
458
- Mode :: ToolBootstrap
459
- } else {
460
- Mode :: ToolStd
461
- } ;
462
- let build_compiler = prepare_compiler_for_check ( builder, self . target , mode) ;
463
-
464
- let mut cargo = prepare_tool_cargo (
465
- builder,
466
- build_compiler,
467
- mode,
468
- self . target ,
469
- builder. kind ,
470
- "src/tools/compiletest" ,
471
- SourceType :: InTree ,
472
- & [ ] ,
473
- ) ;
474
-
475
- cargo. allow_features ( COMPILETEST_ALLOW_FEATURES ) ;
476
-
477
- cargo. arg ( "--all-targets" ) ;
478
-
479
- let stamp = BuildStamp :: new ( & builder. cargo_out ( build_compiler, mode, self . target ) )
480
- . with_prefix ( "compiletest-check" ) ;
481
-
482
- let _guard = builder. msg_check ( "compiletest artifacts" , self . target , None ) ;
483
- run_cargo ( builder, cargo, builder. config . free_args . clone ( ) , & stamp, vec ! [ ] , true , false ) ;
484
- }
485
-
486
- fn metadata ( & self ) -> Option < StepMetadata > {
487
- Some ( StepMetadata :: check ( "compiletest" , self . target ) )
488
- }
489
- }
490
-
491
373
macro_rules! tool_check_step {
492
374
(
493
375
$name: ident {
494
376
// The part of this path after the final '/' is also used as a display name.
495
377
path: $path: literal
496
378
$( , alt_path: $alt_path: literal ) *
497
- , mode: $mode: path
379
+ // Closure that returns `Mode` based on the passed `&Builder<'_>`
380
+ , mode: $mode: expr
381
+ // Subset of nightly features that are allowed to be used when checking
498
382
$( , allow_features: $allow_features: expr ) ?
383
+ // Features that should be enabled when checking
384
+ $( , enable_features: [ $( $enable_features: expr) ,* ] ) ?
499
385
$( , default : $default: literal ) ?
500
386
$( , ) ?
501
387
}
@@ -518,10 +404,13 @@ macro_rules! tool_check_step {
518
404
519
405
fn make_run( run: RunConfig <' _>) {
520
406
let target = run. target;
521
- let build_compiler = prepare_compiler_for_check( run. builder, target, $mode) ;
407
+ let builder = run. builder;
408
+ let mode = $mode( builder) ;
409
+
410
+ let build_compiler = prepare_compiler_for_check( run. builder, target, mode) ;
522
411
523
412
// It doesn't make sense to cross-check bootstrap tools
524
- if $ mode == Mode :: ToolBootstrap && target != run. builder. host_target {
413
+ if mode == Mode :: ToolBootstrap && target != run. builder. host_target {
525
414
println!( "WARNING: not checking bootstrap tool {} for target {target} as it is a bootstrap (host-only) tool" , stringify!( $path) ) ;
526
415
return ;
527
416
} ;
@@ -536,7 +425,9 @@ macro_rules! tool_check_step {
536
425
$( _value = $allow_features; ) ?
537
426
_value
538
427
} ;
539
- run_tool_check_step( builder, build_compiler, target, $path, $mode, allow_features) ;
428
+ let extra_features: & [ & str ] = & [ $( $( $enable_features) ,* ) ?] ;
429
+ let mode = $mode( builder) ;
430
+ run_tool_check_step( builder, build_compiler, target, $path, mode, allow_features, extra_features) ;
540
431
}
541
432
542
433
fn metadata( & self ) -> Option <StepMetadata > {
@@ -554,9 +445,11 @@ fn run_tool_check_step(
554
445
path : & str ,
555
446
mode : Mode ,
556
447
allow_features : & str ,
448
+ extra_features : & [ & str ] ,
557
449
) {
558
450
let display_name = path. rsplit ( '/' ) . next ( ) . unwrap ( ) ;
559
451
452
+ let extra_features = extra_features. iter ( ) . map ( |f| f. to_string ( ) ) . collect :: < Vec < String > > ( ) ;
560
453
let mut cargo = prepare_tool_cargo (
561
454
builder,
562
455
build_compiler,
@@ -569,12 +462,19 @@ fn run_tool_check_step(
569
462
// steps should probably be marked non-default so that the default
570
463
// checks aren't affected by toolstate being broken.
571
464
SourceType :: InTree ,
572
- & [ ] ,
465
+ & extra_features ,
573
466
) ;
574
467
cargo. allow_features ( allow_features) ;
575
468
576
- // FIXME: check bootstrap doesn't currently work with --all-targets
577
- cargo. arg ( "--all-targets" ) ;
469
+ // FIXME: check bootstrap doesn't currently work when multiple targets are checked
470
+ // FIXME: rust-analyzer does not work with --all-targets
471
+ if display_name == "rust-analyzer" {
472
+ cargo. arg ( "--bins" ) ;
473
+ cargo. arg ( "--tests" ) ;
474
+ cargo. arg ( "--benches" ) ;
475
+ } else {
476
+ cargo. arg ( "--all-targets" ) ;
477
+ }
578
478
579
479
let stamp = BuildStamp :: new ( & builder. cargo_out ( build_compiler, mode, target) )
580
480
. with_prefix ( & format ! ( "{display_name}-check" ) ) ;
@@ -593,43 +493,66 @@ fn run_tool_check_step(
593
493
tool_check_step ! ( Rustdoc {
594
494
path: "src/tools/rustdoc" ,
595
495
alt_path: "src/librustdoc" ,
596
- mode: Mode :: ToolRustc
496
+ mode: |_builder| Mode :: ToolRustc
597
497
} ) ;
598
498
// Clippy, miri and Rustfmt are hybrids. They are external tools, but use a git subtree instead
599
499
// of a submodule. Since the SourceType only drives the deny-warnings
600
500
// behavior, treat it as in-tree so that any new warnings in clippy will be
601
501
// rejected.
602
- tool_check_step ! ( Clippy { path: "src/tools/clippy" , mode: Mode :: ToolRustc } ) ;
603
- tool_check_step ! ( Miri { path: "src/tools/miri" , mode: Mode :: ToolRustc } ) ;
604
- tool_check_step ! ( CargoMiri { path: "src/tools/miri/cargo-miri" , mode: Mode :: ToolRustc } ) ;
605
- tool_check_step ! ( Rustfmt { path: "src/tools/rustfmt" , mode: Mode :: ToolRustc } ) ;
502
+ tool_check_step ! ( Clippy { path: "src/tools/clippy" , mode: |_builder| Mode :: ToolRustc } ) ;
503
+ tool_check_step ! ( Miri { path: "src/tools/miri" , mode: |_builder| Mode :: ToolRustc } ) ;
504
+ tool_check_step ! ( CargoMiri { path: "src/tools/miri/cargo-miri" , mode: |_builder| Mode :: ToolRustc } ) ;
505
+ tool_check_step ! ( Rustfmt { path: "src/tools/rustfmt" , mode: |_builder| Mode :: ToolRustc } ) ;
506
+ tool_check_step ! ( RustAnalyzer {
507
+ path: "src/tools/rust-analyzer" ,
508
+ mode: |_builder| Mode :: ToolRustc ,
509
+ allow_features: tool:: RustAnalyzer :: ALLOW_FEATURES ,
510
+ enable_features: [ "in-rust-tree" ] ,
511
+ } ) ;
606
512
tool_check_step ! ( MiroptTestTools {
607
513
path: "src/tools/miropt-test-tools" ,
608
- mode: Mode :: ToolBootstrap
514
+ mode: |_builder| Mode :: ToolBootstrap
609
515
} ) ;
610
516
// We want to test the local std
611
517
tool_check_step ! ( TestFloatParse {
612
518
path: "src/tools/test-float-parse" ,
613
- mode: Mode :: ToolStd ,
519
+ mode: |_builder| Mode :: ToolStd ,
614
520
allow_features: tool:: TestFloatParse :: ALLOW_FEATURES
615
521
} ) ;
616
522
tool_check_step ! ( FeaturesStatusDump {
617
523
path: "src/tools/features-status-dump" ,
618
- mode: Mode :: ToolBootstrap
524
+ mode: |_builder| Mode :: ToolBootstrap
619
525
} ) ;
620
526
621
- tool_check_step ! ( Bootstrap { path: "src/bootstrap" , mode: Mode :: ToolBootstrap , default : false } ) ;
527
+ tool_check_step ! ( Bootstrap {
528
+ path: "src/bootstrap" ,
529
+ mode: |_builder| Mode :: ToolBootstrap ,
530
+ default : false
531
+ } ) ;
622
532
623
533
// `run-make-support` will be built as part of suitable run-make compiletest test steps, but support
624
534
// check to make it easier to work on.
625
535
tool_check_step ! ( RunMakeSupport {
626
536
path: "src/tools/run-make-support" ,
627
- mode: Mode :: ToolBootstrap ,
537
+ mode: |_builder| Mode :: ToolBootstrap ,
628
538
default : false
629
539
} ) ;
630
540
631
541
tool_check_step ! ( CoverageDump {
632
542
path: "src/tools/coverage-dump" ,
633
- mode: Mode :: ToolBootstrap ,
543
+ mode: |_builder| Mode :: ToolBootstrap ,
634
544
default : false
635
545
} ) ;
546
+
547
+ // Compiletest is implicitly "checked" when it gets built in order to run tests,
548
+ // so this is mainly for people working on compiletest to run locally.
549
+ tool_check_step ! ( Compiletest {
550
+ path: "src/tools/compiletest" ,
551
+ mode: |builder: & Builder <' _>| if builder. config. compiletest_use_stage0_libtest {
552
+ Mode :: ToolBootstrap
553
+ } else {
554
+ Mode :: ToolStd
555
+ } ,
556
+ allow_features: COMPILETEST_ALLOW_FEATURES ,
557
+ default : false ,
558
+ } ) ;
0 commit comments