@@ -348,6 +348,50 @@ impl Step for Miri {
348348 }
349349}
350350
351+ #[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
352+ pub struct Clippy {
353+ host : Interned < String > ,
354+ }
355+
356+ impl Step for Clippy {
357+ type Output = ( ) ;
358+ const ONLY_HOSTS : bool = true ;
359+ const DEFAULT : bool = false ;
360+
361+ fn should_run ( run : ShouldRun ) -> ShouldRun {
362+ run. path ( "src/tools/clippy" )
363+ }
364+
365+ fn make_run ( run : RunConfig ) {
366+ run. builder . ensure ( Clippy {
367+ host : run. target ,
368+ } ) ;
369+ }
370+
371+ /// Runs `cargo test` for clippy.
372+ fn run ( self , builder : & Builder ) {
373+ let build = builder. build ;
374+ let host = self . host ;
375+ let compiler = builder. compiler ( 1 , host) ;
376+
377+ let _clippy = builder. ensure ( tool:: Clippy { compiler, target : self . host } ) ;
378+ let mut cargo = builder. cargo ( compiler, Mode :: Tool , host, "test" ) ;
379+ cargo. arg ( "--manifest-path" ) . arg ( build. src . join ( "src/tools/clippy/Cargo.toml" ) ) ;
380+
381+ // Don't build tests dynamically, just a pain to work with
382+ cargo. env ( "RUSTC_NO_PREFER_DYNAMIC" , "1" ) ;
383+ // clippy tests need to know about the stage sysroot
384+ cargo. env ( "SYSROOT" , builder. sysroot ( compiler) ) ;
385+
386+ builder. add_rustc_lib_path ( compiler, & mut cargo) ;
387+
388+ try_run_expecting (
389+ build,
390+ & mut cargo,
391+ builder. build . config . toolstate . clippy . passes ( ToolState :: Testing ) ,
392+ ) ;
393+ }
394+ }
351395
352396fn path_for_cargo ( builder : & Builder , compiler : Compiler ) -> OsString {
353397 // Configure PATH to find the right rustc. NB. we have to use PATH
0 commit comments