@@ -370,69 +370,6 @@ 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
373
macro_rules! tool_check_step {
437
374
(
438
375
$name: ident {
@@ -441,7 +378,10 @@ macro_rules! tool_check_step {
441
378
$( , alt_path: $alt_path: literal ) *
442
379
// Closure that returns `Mode` based on the passed `&Builder<'_>`
443
380
, mode: $mode: expr
381
+ // Subset of nightly features that are allowed to be used when checking
444
382
$( , allow_features: $allow_features: expr ) ?
383
+ // Features that should be enabled when checking
384
+ $( , enable_features: [ $( $enable_features: expr) ,* ] ) ?
445
385
$( , default : $default: literal ) ?
446
386
$( , ) ?
447
387
}
@@ -485,8 +425,9 @@ macro_rules! tool_check_step {
485
425
$( _value = $allow_features; ) ?
486
426
_value
487
427
} ;
428
+ let extra_features: & [ & str ] = & [ $( $( $enable_features) ,* ) ?] ;
488
429
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 ) ;
490
431
}
491
432
492
433
fn metadata( & self ) -> Option <StepMetadata > {
@@ -504,9 +445,11 @@ fn run_tool_check_step(
504
445
path : & str ,
505
446
mode : Mode ,
506
447
allow_features : & str ,
448
+ extra_features : & [ & str ] ,
507
449
) {
508
450
let display_name = path. rsplit ( '/' ) . next ( ) . unwrap ( ) ;
509
451
452
+ let extra_features = extra_features. iter ( ) . map ( |f| f. to_string ( ) ) . collect :: < Vec < String > > ( ) ;
510
453
let mut cargo = prepare_tool_cargo (
511
454
builder,
512
455
build_compiler,
@@ -519,12 +462,19 @@ fn run_tool_check_step(
519
462
// steps should probably be marked non-default so that the default
520
463
// checks aren't affected by toolstate being broken.
521
464
SourceType :: InTree ,
522
- & [ ] ,
465
+ & extra_features ,
523
466
) ;
524
467
cargo. allow_features ( allow_features) ;
525
468
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
+ }
528
478
529
479
let stamp = BuildStamp :: new ( & builder. cargo_out ( build_compiler, mode, target) )
530
480
. with_prefix ( & format ! ( "{display_name}-check" ) ) ;
@@ -553,6 +503,12 @@ tool_check_step!(Clippy { path: "src/tools/clippy", mode: |_builder| Mode::ToolR
553
503
tool_check_step ! ( Miri { path: "src/tools/miri" , mode: |_builder| Mode :: ToolRustc } ) ;
554
504
tool_check_step ! ( CargoMiri { path: "src/tools/miri/cargo-miri" , mode: |_builder| Mode :: ToolRustc } ) ;
555
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
+ } ) ;
556
512
tool_check_step ! ( MiroptTestTools {
557
513
path: "src/tools/miropt-test-tools" ,
558
514
mode: |_builder| Mode :: ToolBootstrap
0 commit comments