@@ -301,6 +301,65 @@ impl Step for CodegenBackend {
301
301
}
302
302
}
303
303
304
+ #[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
305
+ pub struct RustAnalyzer {
306
+ pub target : TargetSelection ,
307
+ }
308
+
309
+ impl Step for RustAnalyzer {
310
+ type Output = ( ) ;
311
+ const ONLY_HOSTS : bool = true ;
312
+ const DEFAULT : bool = true ;
313
+
314
+ fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
315
+ run. paths ( & [ "src/tools/rust-analyzer" ] )
316
+ }
317
+
318
+ fn make_run ( run : RunConfig < ' _ > ) {
319
+ run. builder . ensure ( RustAnalyzer { target : run. target } ) ;
320
+ }
321
+
322
+ fn run ( self , builder : & Builder < ' _ > ) {
323
+ let compiler = builder. compiler ( builder. top_stage , builder. config . build ) ;
324
+ let target = self . target ;
325
+
326
+ builder. ensure ( Std { target } ) ;
327
+
328
+ let mut cargo = prepare_tool_cargo (
329
+ builder,
330
+ compiler,
331
+ Mode :: ToolStd ,
332
+ target,
333
+ cargo_subcommand ( builder. kind ) ,
334
+ "src/tools/rust-analyzer" ,
335
+ SourceType :: InTree ,
336
+ & [ "rust-analyzer/in-rust-tree" . to_owned ( ) ] ,
337
+ ) ;
338
+
339
+ cargo. rustflag (
340
+ "-Zallow-features=proc_macro_internals,proc_macro_diagnostic,proc_macro_span" ,
341
+ ) ;
342
+
343
+ // For ./x.py clippy, don't run with --all-targets because
344
+ // linting tests and benchmarks can produce very noisy results
345
+ if builder. kind != Kind :: Clippy {
346
+ cargo. arg ( "--all-targets" ) ;
347
+ }
348
+
349
+ builder. info ( & format ! (
350
+ "Checking stage{} {} artifacts ({} -> {})" ,
351
+ builder. top_stage, "rust-analyzer" , & compiler. host. triple, target. triple
352
+ ) ) ;
353
+ run_cargo ( builder, cargo, args ( builder) , & stamp ( builder, compiler, target) , vec ! [ ] , true ) ;
354
+
355
+ /// Cargo's output path in a given stage, compiled by a particular
356
+ /// compiler for the specified target.
357
+ fn stamp ( builder : & Builder < ' _ > , compiler : Compiler , target : TargetSelection ) -> PathBuf {
358
+ builder. cargo_out ( compiler, Mode :: ToolStd , target) . join ( ".rust-analyzer-check.stamp" )
359
+ }
360
+ }
361
+ }
362
+
304
363
macro_rules! tool_check_step {
305
364
( $name: ident, $path: literal, $( $alias: literal, ) * $source_type: path $( , $default: literal ) ?) => {
306
365
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
0 commit comments