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 .
2
2
3
3
use crate :: compile:: { run_cargo, std_cargo, test_cargo, rustc_cargo, rustc_cargo_env,
4
4
add_to_sysroot} ;
5
- use crate :: builder:: { RunConfig , Builder , ShouldRun , Step } ;
5
+ use crate :: builder:: { RunConfig , Builder , Kind , ShouldRun , Step } ;
6
6
use crate :: tool:: { prepare_tool_cargo, SourceType } ;
7
7
use crate :: { Compiler , Mode } ;
8
8
use crate :: cache:: { INTERNER , Interned } ;
@@ -13,6 +13,22 @@ pub struct Std {
13
13
pub target : Interned < String > ,
14
14
}
15
15
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
+
16
32
impl Step for Std {
17
33
type Output = ( ) ;
18
34
const DEFAULT : bool = true ;
@@ -31,13 +47,14 @@ impl Step for Std {
31
47
let target = self . target ;
32
48
let compiler = builder. compiler ( 0 , builder. config . build ) ;
33
49
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 ) ) ;
35
51
std_cargo ( builder, & compiler, target, & mut cargo) ;
36
52
37
53
let _folder = builder. fold_output ( || format ! ( "stage{}-std" , compiler. stage) ) ;
38
54
builder. info ( & format ! ( "Checking std artifacts ({} -> {})" , & compiler. host, target) ) ;
39
55
run_cargo ( builder,
40
56
& mut cargo,
57
+ args ( builder. kind ) ,
41
58
& libstd_stamp ( builder, compiler, target) ,
42
59
true ) ;
43
60
@@ -78,13 +95,15 @@ impl Step for Rustc {
78
95
79
96
builder. ensure ( Test { target } ) ;
80
97
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 ) ) ;
82
100
rustc_cargo ( builder, & mut cargo) ;
83
101
84
102
let _folder = builder. fold_output ( || format ! ( "stage{}-rustc" , compiler. stage) ) ;
85
103
builder. info ( & format ! ( "Checking compiler artifacts ({} -> {})" , & compiler. host, target) ) ;
86
104
run_cargo ( builder,
87
105
& mut cargo,
106
+ args ( builder. kind ) ,
88
107
& librustc_stamp ( builder, compiler, target) ,
89
108
true ) ;
90
109
@@ -127,7 +146,8 @@ impl Step for CodegenBackend {
127
146
128
147
builder. ensure ( Rustc { target } ) ;
129
148
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 ) ) ;
131
151
cargo. arg ( "--manifest-path" ) . arg ( builder. src . join ( "src/librustc_codegen_llvm/Cargo.toml" ) ) ;
132
152
rustc_cargo_env ( builder, & mut cargo) ;
133
153
@@ -136,6 +156,7 @@ impl Step for CodegenBackend {
136
156
let _folder = builder. fold_output ( || format ! ( "stage{}-rustc_codegen_llvm" , compiler. stage) ) ;
137
157
run_cargo ( builder,
138
158
& mut cargo,
159
+ args ( builder. kind ) ,
139
160
& codegen_backend_stamp ( builder, compiler, target, backend) ,
140
161
true ) ;
141
162
}
@@ -166,13 +187,14 @@ impl Step for Test {
166
187
167
188
builder. ensure ( Std { target } ) ;
168
189
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 ) ) ;
170
191
test_cargo ( builder, & compiler, target, & mut cargo) ;
171
192
172
193
let _folder = builder. fold_output ( || format ! ( "stage{}-test" , compiler. stage) ) ;
173
194
builder. info ( & format ! ( "Checking test artifacts ({} -> {})" , & compiler. host, target) ) ;
174
195
run_cargo ( builder,
175
196
& mut cargo,
197
+ args ( builder. kind ) ,
176
198
& libtest_stamp ( builder, compiler, target) ,
177
199
true ) ;
178
200
@@ -212,7 +234,7 @@ impl Step for Rustdoc {
212
234
compiler,
213
235
Mode :: ToolRustc ,
214
236
target,
215
- "check" ,
237
+ cargo_subcommand ( builder . kind ) ,
216
238
"src/tools/rustdoc" ,
217
239
SourceType :: InTree ,
218
240
& [ ] ) ;
@@ -221,6 +243,7 @@ impl Step for Rustdoc {
221
243
println ! ( "Checking rustdoc artifacts ({} -> {})" , & compiler. host, target) ;
222
244
run_cargo ( builder,
223
245
& mut cargo,
246
+ args ( builder. kind ) ,
224
247
& rustdoc_stamp ( builder, compiler, target) ,
225
248
true ) ;
226
249
0 commit comments