1- //! Implementation of compiling the compiler and standard library, in "check" mode .
1+ //! Implementation of compiling the compiler and standard library, in "check"-based modes .
22
33use crate :: compile:: { run_cargo, std_cargo, test_cargo, rustc_cargo, rustc_cargo_env,
44 add_to_sysroot} ;
5- use crate :: builder:: { RunConfig , Builder , ShouldRun , Step } ;
5+ use crate :: builder:: { RunConfig , Builder , Kind , ShouldRun , Step } ;
66use crate :: tool:: { prepare_tool_cargo, SourceType } ;
77use crate :: { Compiler , Mode } ;
88use crate :: cache:: { INTERNER , Interned } ;
@@ -13,6 +13,22 @@ pub struct Std {
1313 pub target : Interned < String > ,
1414}
1515
16+ fn args ( kind : Kind ) -> Vec < String > {
17+ match kind {
18+ Kind :: Clippy => vec ! [ "--" . to_owned( ) , "--cap-lints" . to_owned( ) , "warn" . to_owned( ) ] ,
19+ _ => Vec :: new ( )
20+ }
21+ }
22+
23+ fn cargo_subcommand ( kind : Kind ) -> & ' static str {
24+ match kind {
25+ Kind :: Check => "check" ,
26+ Kind :: Clippy => "clippy" ,
27+ Kind :: Fix => "fix" ,
28+ _ => unreachable ! ( )
29+ }
30+ }
31+
1632impl Step for Std {
1733 type Output = ( ) ;
1834 const DEFAULT : bool = true ;
@@ -31,13 +47,14 @@ impl Step for Std {
3147 let target = self . target ;
3248 let compiler = builder. compiler ( 0 , builder. config . build ) ;
3349
34- let mut cargo = builder. cargo ( compiler, Mode :: Std , target, "check" ) ;
50+ let mut cargo = builder. cargo ( compiler, Mode :: Std , target, cargo_subcommand ( builder . kind ) ) ;
3551 std_cargo ( builder, & compiler, target, & mut cargo) ;
3652
3753 let _folder = builder. fold_output ( || format ! ( "stage{}-std" , compiler. stage) ) ;
3854 builder. info ( & format ! ( "Checking std artifacts ({} -> {})" , & compiler. host, target) ) ;
3955 run_cargo ( builder,
4056 & mut cargo,
57+ args ( builder. kind ) ,
4158 & libstd_stamp ( builder, compiler, target) ,
4259 true ) ;
4360
@@ -78,13 +95,15 @@ impl Step for Rustc {
7895
7996 builder. ensure ( Test { target } ) ;
8097
81- let mut cargo = builder. cargo ( compiler, Mode :: Rustc , target, "check" ) ;
98+ let mut cargo = builder. cargo ( compiler, Mode :: Rustc , target,
99+ cargo_subcommand ( builder. kind ) ) ;
82100 rustc_cargo ( builder, & mut cargo) ;
83101
84102 let _folder = builder. fold_output ( || format ! ( "stage{}-rustc" , compiler. stage) ) ;
85103 builder. info ( & format ! ( "Checking compiler artifacts ({} -> {})" , & compiler. host, target) ) ;
86104 run_cargo ( builder,
87105 & mut cargo,
106+ args ( builder. kind ) ,
88107 & librustc_stamp ( builder, compiler, target) ,
89108 true ) ;
90109
@@ -127,7 +146,8 @@ impl Step for CodegenBackend {
127146
128147 builder. ensure ( Rustc { target } ) ;
129148
130- let mut cargo = builder. cargo ( compiler, Mode :: Codegen , target, "check" ) ;
149+ let mut cargo = builder. cargo ( compiler, Mode :: Codegen , target,
150+ cargo_subcommand ( builder. kind ) ) ;
131151 cargo. arg ( "--manifest-path" ) . arg ( builder. src . join ( "src/librustc_codegen_llvm/Cargo.toml" ) ) ;
132152 rustc_cargo_env ( builder, & mut cargo) ;
133153
@@ -136,6 +156,7 @@ impl Step for CodegenBackend {
136156 let _folder = builder. fold_output ( || format ! ( "stage{}-rustc_codegen_llvm" , compiler. stage) ) ;
137157 run_cargo ( builder,
138158 & mut cargo,
159+ args ( builder. kind ) ,
139160 & codegen_backend_stamp ( builder, compiler, target, backend) ,
140161 true ) ;
141162 }
@@ -166,13 +187,14 @@ impl Step for Test {
166187
167188 builder. ensure ( Std { target } ) ;
168189
169- let mut cargo = builder. cargo ( compiler, Mode :: Test , target, "check" ) ;
190+ let mut cargo = builder. cargo ( compiler, Mode :: Test , target, cargo_subcommand ( builder . kind ) ) ;
170191 test_cargo ( builder, & compiler, target, & mut cargo) ;
171192
172193 let _folder = builder. fold_output ( || format ! ( "stage{}-test" , compiler. stage) ) ;
173194 builder. info ( & format ! ( "Checking test artifacts ({} -> {})" , & compiler. host, target) ) ;
174195 run_cargo ( builder,
175196 & mut cargo,
197+ args ( builder. kind ) ,
176198 & libtest_stamp ( builder, compiler, target) ,
177199 true ) ;
178200
@@ -212,7 +234,7 @@ impl Step for Rustdoc {
212234 compiler,
213235 Mode :: ToolRustc ,
214236 target,
215- "check" ,
237+ cargo_subcommand ( builder . kind ) ,
216238 "src/tools/rustdoc" ,
217239 SourceType :: InTree ,
218240 & [ ] ) ;
@@ -221,6 +243,7 @@ impl Step for Rustdoc {
221243 println ! ( "Checking rustdoc artifacts ({} -> {})" , & compiler. host, target) ;
222244 run_cargo ( builder,
223245 & mut cargo,
246+ args ( builder. kind ) ,
224247 & rustdoc_stamp ( builder, compiler, target) ,
225248 true ) ;
226249
0 commit comments