@@ -358,69 +358,6 @@ impl Step for CodegenBackend {
358358 }
359359}
360360
361- /// Checks Rust analyzer that links to .rmetas from a checked rustc.
362- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
363- pub struct RustAnalyzer {
364- pub build_compiler : Compiler ,
365- pub target : TargetSelection ,
366- }
367-
368- impl Step for RustAnalyzer {
369- type Output = ( ) ;
370- const ONLY_HOSTS : bool = true ;
371- const DEFAULT : bool = true ;
372-
373- fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
374- let builder = run. builder ;
375- run. path ( "src/tools/rust-analyzer" ) . default_condition (
376- builder
377- . config
378- . tools
379- . as_ref ( )
380- . is_none_or ( |tools| tools. iter ( ) . any ( |tool| tool == "rust-analyzer" ) ) ,
381- )
382- }
383-
384- fn make_run ( run : RunConfig < ' _ > ) {
385- let build_compiler = prepare_compiler_for_check ( run. builder , run. target , Mode :: ToolRustc ) ;
386- run. builder . ensure ( RustAnalyzer { build_compiler, target : run. target } ) ;
387- }
388-
389- fn run ( self , builder : & Builder < ' _ > ) {
390- let build_compiler = self . build_compiler ;
391- let target = self . target ;
392-
393- let mut cargo = prepare_tool_cargo (
394- builder,
395- build_compiler,
396- Mode :: ToolRustc ,
397- target,
398- builder. kind ,
399- "src/tools/rust-analyzer" ,
400- SourceType :: InTree ,
401- & [ "in-rust-tree" . to_owned ( ) ] ,
402- ) ;
403-
404- cargo. allow_features ( crate :: core:: build_steps:: tool:: RustAnalyzer :: ALLOW_FEATURES ) ;
405-
406- cargo. arg ( "--bins" ) ;
407- cargo. arg ( "--tests" ) ;
408- cargo. arg ( "--benches" ) ;
409-
410- // Cargo's output path in a given stage, compiled by a particular
411- // compiler for the specified target.
412- let stamp = BuildStamp :: new ( & builder. cargo_out ( build_compiler, Mode :: ToolRustc , target) )
413- . with_prefix ( "rust-analyzer-check" ) ;
414-
415- let _guard = builder. msg_check ( "rust-analyzer artifacts" , target, None ) ;
416- run_cargo ( builder, cargo, builder. config . free_args . clone ( ) , & stamp, vec ! [ ] , true , false ) ;
417- }
418-
419- fn metadata ( & self ) -> Option < StepMetadata > {
420- Some ( StepMetadata :: check ( "rust-analyzer" , self . target ) . built_by ( self . build_compiler ) )
421- }
422- }
423-
424361macro_rules! tool_check_step {
425362 (
426363 $name: ident {
@@ -429,7 +366,10 @@ macro_rules! tool_check_step {
429366 $( , alt_path: $alt_path: literal ) *
430367 // Closure that returns `Mode` based on the passed `&Builder<'_>`
431368 , mode: $mode: expr
369+ // Subset of nightly features that are allowed to be used when checking
432370 $( , allow_features: $allow_features: expr ) ?
371+ // Features that should be enabled when checking
372+ $( , enable_features: [ $( $enable_features: expr) ,* ] ) ?
433373 $( , default : $default: literal ) ?
434374 $( , ) ?
435375 }
@@ -473,8 +413,9 @@ macro_rules! tool_check_step {
473413 $( _value = $allow_features; ) ?
474414 _value
475415 } ;
416+ let extra_features: & [ & str ] = & [ $( $( $enable_features) ,* ) ?] ;
476417 let mode = $mode( builder) ;
477- run_tool_check_step( builder, build_compiler, target, $path, mode, allow_features) ;
418+ run_tool_check_step( builder, build_compiler, target, $path, mode, allow_features, extra_features ) ;
478419 }
479420
480421 fn metadata( & self ) -> Option <StepMetadata > {
@@ -492,9 +433,11 @@ fn run_tool_check_step(
492433 path : & str ,
493434 mode : Mode ,
494435 allow_features : & str ,
436+ extra_features : & [ & str ] ,
495437) {
496438 let display_name = path. rsplit ( '/' ) . next ( ) . unwrap ( ) ;
497439
440+ let extra_features = extra_features. iter ( ) . map ( |f| f. to_string ( ) ) . collect :: < Vec < String > > ( ) ;
498441 let mut cargo = prepare_tool_cargo (
499442 builder,
500443 build_compiler,
@@ -507,12 +450,19 @@ fn run_tool_check_step(
507450 // steps should probably be marked non-default so that the default
508451 // checks aren't affected by toolstate being broken.
509452 SourceType :: InTree ,
510- & [ ] ,
453+ & extra_features ,
511454 ) ;
512455 cargo. allow_features ( allow_features) ;
513456
514- // FIXME: check bootstrap doesn't currently work with --all-targets
515- cargo. arg ( "--all-targets" ) ;
457+ // FIXME: check bootstrap doesn't currently work when multiple targets are checked
458+ // FIXME: rust-analyzer does not work with --all-targets
459+ if display_name == "rust-analyzer" {
460+ cargo. arg ( "--bins" ) ;
461+ cargo. arg ( "--tests" ) ;
462+ cargo. arg ( "--benches" ) ;
463+ } else {
464+ cargo. arg ( "--all-targets" ) ;
465+ }
516466
517467 let stamp = BuildStamp :: new ( & builder. cargo_out ( build_compiler, mode, target) )
518468 . with_prefix ( & format ! ( "{display_name}-check" ) ) ;
@@ -541,6 +491,12 @@ tool_check_step!(Clippy { path: "src/tools/clippy", mode: |_builder| Mode::ToolR
541491tool_check_step ! ( Miri { path: "src/tools/miri" , mode: |_builder| Mode :: ToolRustc } ) ;
542492tool_check_step ! ( CargoMiri { path: "src/tools/miri/cargo-miri" , mode: |_builder| Mode :: ToolRustc } ) ;
543493tool_check_step ! ( Rustfmt { path: "src/tools/rustfmt" , mode: |_builder| Mode :: ToolRustc } ) ;
494+ tool_check_step ! ( RustAnalyzer {
495+ path: "src/tools/rust-analyzer" ,
496+ mode: |_builder| Mode :: ToolRustc ,
497+ allow_features: tool:: RustAnalyzer :: ALLOW_FEATURES ,
498+ enable_features: [ "in-rust-tree" ] ,
499+ } ) ;
544500tool_check_step ! ( MiroptTestTools {
545501 path: "src/tools/miropt-test-tools" ,
546502 mode: |_builder| Mode :: ToolBootstrap
0 commit comments