@@ -358,69 +358,6 @@ impl Step for CodegenBackend {
358
358
}
359
359
}
360
360
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
-
424
361
macro_rules! tool_check_step {
425
362
(
426
363
$name: ident {
@@ -429,7 +366,10 @@ macro_rules! tool_check_step {
429
366
$( , alt_path: $alt_path: literal ) *
430
367
// Closure that returns `Mode` based on the passed `&Builder<'_>`
431
368
, mode: $mode: expr
369
+ // Subset of nightly features that are allowed to be used when checking
432
370
$( , allow_features: $allow_features: expr ) ?
371
+ // Features that should be enabled when checking
372
+ $( , enable_features: [ $( $enable_features: expr) ,* ] ) ?
433
373
$( , default : $default: literal ) ?
434
374
$( , ) ?
435
375
}
@@ -473,8 +413,9 @@ macro_rules! tool_check_step {
473
413
$( _value = $allow_features; ) ?
474
414
_value
475
415
} ;
416
+ let extra_features: & [ & str ] = & [ $( $( $enable_features) ,* ) ?] ;
476
417
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 ) ;
478
419
}
479
420
480
421
fn metadata( & self ) -> Option <StepMetadata > {
@@ -492,9 +433,11 @@ fn run_tool_check_step(
492
433
path : & str ,
493
434
mode : Mode ,
494
435
allow_features : & str ,
436
+ extra_features : & [ & str ] ,
495
437
) {
496
438
let display_name = path. rsplit ( '/' ) . next ( ) . unwrap ( ) ;
497
439
440
+ let extra_features = extra_features. iter ( ) . map ( |f| f. to_string ( ) ) . collect :: < Vec < String > > ( ) ;
498
441
let mut cargo = prepare_tool_cargo (
499
442
builder,
500
443
build_compiler,
@@ -507,12 +450,19 @@ fn run_tool_check_step(
507
450
// steps should probably be marked non-default so that the default
508
451
// checks aren't affected by toolstate being broken.
509
452
SourceType :: InTree ,
510
- & [ ] ,
453
+ & extra_features ,
511
454
) ;
512
455
cargo. allow_features ( allow_features) ;
513
456
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
+ }
516
466
517
467
let stamp = BuildStamp :: new ( & builder. cargo_out ( build_compiler, mode, target) )
518
468
. with_prefix ( & format ! ( "{display_name}-check" ) ) ;
@@ -541,6 +491,12 @@ tool_check_step!(Clippy { path: "src/tools/clippy", mode: |_builder| Mode::ToolR
541
491
tool_check_step ! ( Miri { path: "src/tools/miri" , mode: |_builder| Mode :: ToolRustc } ) ;
542
492
tool_check_step ! ( CargoMiri { path: "src/tools/miri/cargo-miri" , mode: |_builder| Mode :: ToolRustc } ) ;
543
493
tool_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
+ } ) ;
544
500
tool_check_step ! ( MiroptTestTools {
545
501
path: "src/tools/miropt-test-tools" ,
546
502
mode: |_builder| Mode :: ToolBootstrap
0 commit comments