@@ -370,69 +370,6 @@ 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-
436373macro_rules! tool_check_step {
437374 (
438375 $name: ident {
@@ -441,7 +378,10 @@ macro_rules! tool_check_step {
441378 $( , alt_path: $alt_path: literal ) *
442379 // Closure that returns `Mode` based on the passed `&Builder<'_>`
443380 , mode: $mode: expr
381+ // Subset of nightly features that are allowed to be used when checking
444382 $( , allow_features: $allow_features: expr ) ?
383+ // Features that should be enabled when checking
384+ $( , enable_features: [ $( $enable_features: expr) ,* ] ) ?
445385 $( , default : $default: literal ) ?
446386 $( , ) ?
447387 }
@@ -485,8 +425,9 @@ macro_rules! tool_check_step {
485425 $( _value = $allow_features; ) ?
486426 _value
487427 } ;
428+ let extra_features: & [ & str ] = & [ $( $( $enable_features) ,* ) ?] ;
488429 let mode = $mode( builder) ;
489- run_tool_check_step( builder, build_compiler, target, $path, mode, allow_features) ;
430+ run_tool_check_step( builder, build_compiler, target, $path, mode, allow_features, extra_features ) ;
490431 }
491432
492433 fn metadata( & self ) -> Option <StepMetadata > {
@@ -504,9 +445,11 @@ fn run_tool_check_step(
504445 path : & str ,
505446 mode : Mode ,
506447 allow_features : & str ,
448+ extra_features : & [ & str ] ,
507449) {
508450 let display_name = path. rsplit ( '/' ) . next ( ) . unwrap ( ) ;
509451
452+ let extra_features = extra_features. iter ( ) . map ( |f| f. to_string ( ) ) . collect :: < Vec < String > > ( ) ;
510453 let mut cargo = prepare_tool_cargo (
511454 builder,
512455 build_compiler,
@@ -519,12 +462,19 @@ fn run_tool_check_step(
519462 // steps should probably be marked non-default so that the default
520463 // checks aren't affected by toolstate being broken.
521464 SourceType :: InTree ,
522- & [ ] ,
465+ & extra_features ,
523466 ) ;
524467 cargo. allow_features ( allow_features) ;
525468
526- // FIXME: check bootstrap doesn't currently work with --all-targets
527- 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+ }
528478
529479 let stamp = BuildStamp :: new ( & builder. cargo_out ( build_compiler, mode, target) )
530480 . with_prefix ( & format ! ( "{display_name}-check" ) ) ;
@@ -553,6 +503,12 @@ tool_check_step!(Clippy { path: "src/tools/clippy", mode: |_builder| Mode::ToolR
553503tool_check_step ! ( Miri { path: "src/tools/miri" , mode: |_builder| Mode :: ToolRustc } ) ;
554504tool_check_step ! ( CargoMiri { path: "src/tools/miri/cargo-miri" , mode: |_builder| Mode :: ToolRustc } ) ;
555505tool_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+ } ) ;
556512tool_check_step ! ( MiroptTestTools {
557513 path: "src/tools/miropt-test-tools" ,
558514 mode: |_builder| Mode :: ToolBootstrap
0 commit comments