@@ -370,132 +370,18 @@ impl Step for CodegenBackend {
370370 }
371371}
372372
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-
491373macro_rules! tool_check_step {
492374 (
493375 $name: ident {
494376 // The part of this path after the final '/' is also used as a display name.
495377 path: $path: literal
496378 $( , 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
498382 $( , allow_features: $allow_features: expr ) ?
383+ // Features that should be enabled when checking
384+ $( , enable_features: [ $( $enable_features: expr) ,* ] ) ?
499385 $( , default : $default: literal ) ?
500386 $( , ) ?
501387 }
@@ -518,10 +404,13 @@ macro_rules! tool_check_step {
518404
519405 fn make_run( run: RunConfig <' _>) {
520406 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) ;
522411
523412 // 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 {
525414 println!( "WARNING: not checking bootstrap tool {} for target {target} as it is a bootstrap (host-only) tool" , stringify!( $path) ) ;
526415 return ;
527416 } ;
@@ -536,7 +425,9 @@ macro_rules! tool_check_step {
536425 $( _value = $allow_features; ) ?
537426 _value
538427 } ;
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) ;
540431 }
541432
542433 fn metadata( & self ) -> Option <StepMetadata > {
@@ -554,9 +445,11 @@ fn run_tool_check_step(
554445 path : & str ,
555446 mode : Mode ,
556447 allow_features : & str ,
448+ extra_features : & [ & str ] ,
557449) {
558450 let display_name = path. rsplit ( '/' ) . next ( ) . unwrap ( ) ;
559451
452+ let extra_features = extra_features. iter ( ) . map ( |f| f. to_string ( ) ) . collect :: < Vec < String > > ( ) ;
560453 let mut cargo = prepare_tool_cargo (
561454 builder,
562455 build_compiler,
@@ -569,12 +462,19 @@ fn run_tool_check_step(
569462 // steps should probably be marked non-default so that the default
570463 // checks aren't affected by toolstate being broken.
571464 SourceType :: InTree ,
572- & [ ] ,
465+ & extra_features ,
573466 ) ;
574467 cargo. allow_features ( allow_features) ;
575468
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+ }
578478
579479 let stamp = BuildStamp :: new ( & builder. cargo_out ( build_compiler, mode, target) )
580480 . with_prefix ( & format ! ( "{display_name}-check" ) ) ;
@@ -593,43 +493,66 @@ fn run_tool_check_step(
593493tool_check_step ! ( Rustdoc {
594494 path: "src/tools/rustdoc" ,
595495 alt_path: "src/librustdoc" ,
596- mode: Mode :: ToolRustc
496+ mode: |_builder| Mode :: ToolRustc
597497} ) ;
598498// Clippy, miri and Rustfmt are hybrids. They are external tools, but use a git subtree instead
599499// of a submodule. Since the SourceType only drives the deny-warnings
600500// behavior, treat it as in-tree so that any new warnings in clippy will be
601501// 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+ } ) ;
606512tool_check_step ! ( MiroptTestTools {
607513 path: "src/tools/miropt-test-tools" ,
608- mode: Mode :: ToolBootstrap
514+ mode: |_builder| Mode :: ToolBootstrap
609515} ) ;
610516// We want to test the local std
611517tool_check_step ! ( TestFloatParse {
612518 path: "src/tools/test-float-parse" ,
613- mode: Mode :: ToolStd ,
519+ mode: |_builder| Mode :: ToolStd ,
614520 allow_features: tool:: TestFloatParse :: ALLOW_FEATURES
615521} ) ;
616522tool_check_step ! ( FeaturesStatusDump {
617523 path: "src/tools/features-status-dump" ,
618- mode: Mode :: ToolBootstrap
524+ mode: |_builder| Mode :: ToolBootstrap
619525} ) ;
620526
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+ } ) ;
622532
623533// `run-make-support` will be built as part of suitable run-make compiletest test steps, but support
624534// check to make it easier to work on.
625535tool_check_step ! ( RunMakeSupport {
626536 path: "src/tools/run-make-support" ,
627- mode: Mode :: ToolBootstrap ,
537+ mode: |_builder| Mode :: ToolBootstrap ,
628538 default : false
629539} ) ;
630540
631541tool_check_step ! ( CoverageDump {
632542 path: "src/tools/coverage-dump" ,
633- mode: Mode :: ToolBootstrap ,
543+ mode: |_builder| Mode :: ToolBootstrap ,
634544 default : false
635545} ) ;
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