@@ -352,6 +352,55 @@ impl Step for Rls {
352352 }
353353}
354354
355+ #[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
356+ pub struct RustAnalyzer {
357+ stage : u32 ,
358+ host : TargetSelection ,
359+ }
360+
361+ impl Step for RustAnalyzer {
362+ type Output = ( ) ;
363+ const ONLY_HOSTS : bool = true ;
364+ const DEFAULT : bool = true ;
365+
366+ fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
367+ run. path ( "src/tools/rust-analyzer" )
368+ }
369+
370+ fn make_run ( run : RunConfig < ' _ > ) {
371+ run. builder . ensure ( Self { stage : run. builder . top_stage , host : run. target } ) ;
372+ }
373+
374+ /// Runs `cargo test` for rust-analyzer
375+ fn run ( self , builder : & Builder < ' _ > ) {
376+ let stage = self . stage ;
377+ let host = self . host ;
378+ let compiler = builder. compiler ( stage, host) ;
379+
380+ builder. ensure ( tool:: RustAnalyzer { compiler, target : self . host } ) . expect ( "in-tree tool" ) ;
381+
382+ let path = "src/tools/rust-analyzer" ;
383+ let mut cargo = tool:: prepare_tool_cargo (
384+ builder,
385+ compiler,
386+ Mode :: ToolStd ,
387+ host,
388+ "test" ,
389+ path,
390+ SourceType :: InTree ,
391+ & [ "rust-analyzer/in-rust-tree" . to_owned ( ) ] ,
392+ ) ;
393+
394+ let dir = builder. src . join ( path) ;
395+ cargo. env ( "CARGO_WORKSPACE_DIR" , & dir) ;
396+
397+ cargo. add_rustc_lib_path ( builder, compiler) ;
398+ cargo. arg ( "--" ) . args ( builder. config . cmd . test_args ( ) ) ;
399+
400+ builder. run ( & mut cargo. into ( ) ) ;
401+ }
402+ }
403+
355404#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
356405pub struct Rustfmt {
357406 stage : u32 ,
0 commit comments