@@ -361,6 +361,81 @@ impl Step for RustAnalyzer {
361
361
}
362
362
}
363
363
364
+ #[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
365
+ pub struct Tidy ;
366
+
367
+ impl Step for Tidy {
368
+ type Output = ( ) ;
369
+ const ONLY_HOSTS : bool = true ;
370
+ const DEFAULT : bool = true ;
371
+
372
+ fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
373
+ run. path ( "src/tools/tidy" )
374
+ }
375
+
376
+ fn make_run ( run : RunConfig < ' _ > ) {
377
+ run. builder . ensure ( Tidy ) ;
378
+ }
379
+
380
+ fn run ( self , builder : & Builder < ' _ > ) -> Self :: Output {
381
+ let compiler = builder. compiler ( builder. top_stage , builder. config . build ) ;
382
+ let host = builder. build . build ;
383
+
384
+ let mut cargo = prepare_tool_cargo (
385
+ builder,
386
+ compiler,
387
+ Mode :: ToolBootstrap ,
388
+ host,
389
+ cargo_subcommand ( builder. kind ) ,
390
+ "src/tools/tidy" ,
391
+ SourceType :: InTree ,
392
+ & [ ] ,
393
+ ) ;
394
+
395
+ // For ./x.py clippy, don't run with --all-targets because
396
+ // linting tests and benchmarks can produce very noisy results
397
+ if builder. kind != Kind :: Clippy {
398
+ cargo. arg ( "--all-targets" ) ;
399
+ }
400
+
401
+ cargo. args ( args ( builder) ) ;
402
+
403
+ // Enable internal lints for clippy and rustdoc
404
+ // NOTE: this doesn't enable lints for any other tools unless they explicitly add `#![warn(rustc::internal)]`
405
+ // See https://github.com/rust-lang/rust/pull/80573#issuecomment-754010776
406
+ cargo. rustflag ( "-Zunstable-options" ) ;
407
+
408
+ builder. info ( & format ! (
409
+ "Checking stage{} tidy artifacts ({} -> {})" ,
410
+ builder. top_stage,
411
+ & compiler. host. triple,
412
+ host. triple
413
+ ) ) ;
414
+ run_cargo (
415
+ builder,
416
+ cargo,
417
+ & tool_stamp ( builder, compiler, host, Mode :: ToolBootstrap , "tidy" ) ,
418
+ vec ! [ ] ,
419
+ true ,
420
+ false ,
421
+ ) ;
422
+ }
423
+ }
424
+
425
+ /// Cargo's output path in a given stage, compiled by a particular
426
+ /// compiler for the specified target.
427
+ fn tool_stamp (
428
+ builder : & Builder < ' _ > ,
429
+ compiler : Compiler ,
430
+ target : TargetSelection ,
431
+ mode : Mode ,
432
+ name : & str ,
433
+ ) -> PathBuf {
434
+ builder
435
+ . cargo_out ( compiler, mode, target)
436
+ . join ( format ! ( ".{name}-check.stamp" ) )
437
+ }
438
+
364
439
macro_rules! tool_check_step {
365
440
( $name: ident, $path: literal, $( $alias: literal, ) * $source_type: path $( , $default: literal ) ?) => {
366
441
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
@@ -422,23 +497,11 @@ macro_rules! tool_check_step {
422
497
run_cargo(
423
498
builder,
424
499
cargo,
425
- & stamp ( builder, compiler, target) ,
500
+ & tool_stamp ( builder, compiler, target, Mode :: ToolRustc , & stringify! ( $name ) . to_lowercase ( ) ) ,
426
501
vec![ ] ,
427
502
true ,
428
503
false ,
429
504
) ;
430
-
431
- /// Cargo's output path in a given stage, compiled by a particular
432
- /// compiler for the specified target.
433
- fn stamp(
434
- builder: & Builder <' _>,
435
- compiler: Compiler ,
436
- target: TargetSelection ,
437
- ) -> PathBuf {
438
- builder
439
- . cargo_out( compiler, Mode :: ToolRustc , target)
440
- . join( format!( ".{}-check.stamp" , stringify!( $name) . to_lowercase( ) ) )
441
- }
442
505
}
443
506
}
444
507
} ;
0 commit comments