@@ -91,17 +91,16 @@ fn main() {
91
91
cmd. args ( & args)
92
92
. env ( bootstrap:: util:: dylib_path_var ( ) ,
93
93
env:: join_paths ( & dylib_path) . unwrap ( ) ) ;
94
- let mut maybe_crate = None ;
95
94
96
95
// Get the name of the crate we're compiling, if any.
97
- let maybe_crate_name = args. windows ( 2 )
98
- . find ( |a| & * a [ 0 ] == "--crate-name" )
99
- . map ( |crate_name| & * crate_name [ 1 ] ) ;
96
+ let crate_name = args. windows ( 2 )
97
+ . find ( |args| args [ 0 ] == "--crate-name" )
98
+ . and_then ( |args| args [ 1 ] . to_str ( ) ) ;
100
99
101
- if let Some ( current_crate ) = maybe_crate_name {
100
+ if let Some ( crate_name ) = crate_name {
102
101
if let Some ( target) = env:: var_os ( "RUSTC_TIME" ) {
103
102
if target == "all" ||
104
- target. into_string ( ) . unwrap ( ) . split ( "," ) . any ( |c| c. trim ( ) == current_crate )
103
+ target. into_string ( ) . unwrap ( ) . split ( "," ) . any ( |c| c. trim ( ) == crate_name )
105
104
{
106
105
cmd. arg ( "-Ztime" ) ;
107
106
}
@@ -125,6 +124,17 @@ fn main() {
125
124
cmd. arg ( format ! ( "-Cdebuginfo={}" , debuginfo_level) ) ;
126
125
}
127
126
127
+ if env:: var_os ( "RUSTC_DENY_WARNINGS" ) . is_some ( ) &&
128
+ env:: var_os ( "RUSTC_EXTERNAL_TOOL" ) . is_none ( ) {
129
+ cmd. arg ( "-Dwarnings" ) ;
130
+ cmd. arg ( "-Drust_2018_idioms" ) ;
131
+ if stage != "0" && crate_name != Some ( "rustc_version" ) && // cfg(not(bootstrap))
132
+ use_internal_lints ( crate_name) {
133
+ cmd. arg ( "-Zunstable-options" ) ;
134
+ cmd. arg ( "-Drustc::internal" ) ;
135
+ }
136
+ }
137
+
128
138
if let Some ( target) = target {
129
139
// The stage0 compiler has a special sysroot distinct from what we
130
140
// actually downloaded, so we just always pass the `--sysroot` option.
@@ -167,9 +177,6 @@ fn main() {
167
177
cmd. arg ( format ! ( "-Clinker={}" , target_linker) ) ;
168
178
}
169
179
170
- let crate_name = maybe_crate_name. unwrap ( ) ;
171
- maybe_crate = Some ( crate_name) ;
172
-
173
180
// If we're compiling specifically the `panic_abort` crate then we pass
174
181
// the `-C panic=abort` option. Note that we do not do this for any
175
182
// other crate intentionally as this is the only crate for now that we
@@ -182,8 +189,8 @@ fn main() {
182
189
// `compiler_builtins` are unconditionally compiled with panic=abort to
183
190
// workaround undefined references to `rust_eh_unwind_resume` generated
184
191
// otherwise, see issue https://github.com/rust-lang/rust/issues/43095.
185
- if crate_name == "panic_abort" ||
186
- crate_name == "compiler_builtins" && stage != "0" {
192
+ if crate_name == Some ( "panic_abort" ) ||
193
+ crate_name == Some ( "compiler_builtins" ) && stage != "0" {
187
194
cmd. arg ( "-C" ) . arg ( "panic=abort" ) ;
188
195
}
189
196
@@ -196,7 +203,7 @@ fn main() {
196
203
197
204
// The compiler builtins are pretty sensitive to symbols referenced in
198
205
// libcore and such, so we never compile them with debug assertions.
199
- if crate_name == "compiler_builtins" {
206
+ if crate_name == Some ( "compiler_builtins" ) {
200
207
cmd. arg ( "-C" ) . arg ( "debug-assertions=no" ) ;
201
208
} else {
202
209
cmd. arg ( "-C" ) . arg ( format ! ( "debug-assertions={}" , debug_assertions) ) ;
@@ -305,22 +312,6 @@ fn main() {
305
312
}
306
313
}
307
314
308
- // This is required for internal lints.
309
- if let Some ( crate_name) = args. windows ( 2 ) . find ( |a| & * a[ 0 ] == "--crate-name" ) {
310
- let crate_name = crate_name[ 1 ] . to_string_lossy ( ) ;
311
- if crate_name != "rustc_version"
312
- && ( crate_name. starts_with ( "rustc" )
313
- || crate_name. starts_with ( "syntax" )
314
- || crate_name == "arena"
315
- || crate_name == "fmt_macros" )
316
- {
317
- cmd. arg ( "-Zunstable-options" ) ;
318
- if stage != "0" {
319
- cmd. arg ( "-Wrustc::internal" ) ;
320
- }
321
- }
322
- }
323
-
324
315
// Force all crates compiled by this compiler to (a) be unstable and (b)
325
316
// allow the `rustc_private` feature to link to other unstable crates
326
317
// also in the sysroot. We also do this for host crates, since those
@@ -333,13 +324,6 @@ fn main() {
333
324
cmd. arg ( "--cfg" ) . arg ( "parallel_compiler" ) ;
334
325
}
335
326
336
- if env:: var_os ( "RUSTC_DENY_WARNINGS" ) . is_some ( ) && env:: var_os ( "RUSTC_EXTERNAL_TOOL" ) . is_none ( )
337
- {
338
- cmd. arg ( "-Dwarnings" ) ;
339
- cmd. arg ( "-Dbare_trait_objects" ) ;
340
- cmd. arg ( "-Drust_2018_idioms" ) ;
341
- }
342
-
343
327
if verbose > 1 {
344
328
eprintln ! (
345
329
"rustc command: {:?}={:?} {:?}" ,
@@ -362,7 +346,7 @@ fn main() {
362
346
}
363
347
364
348
if env:: var_os ( "RUSTC_PRINT_STEP_TIMINGS" ) . is_some ( ) {
365
- if let Some ( krate ) = maybe_crate {
349
+ if let Some ( crate_name ) = crate_name {
366
350
let start = Instant :: now ( ) ;
367
351
let status = cmd
368
352
. status ( )
@@ -371,7 +355,7 @@ fn main() {
371
355
372
356
let is_test = args. iter ( ) . any ( |a| a == "--test" ) ;
373
357
eprintln ! ( "[RUSTC-TIMING] {} test:{} {}.{:03}" ,
374
- krate . to_string_lossy ( ) ,
358
+ crate_name ,
375
359
is_test,
376
360
dur. as_secs( ) ,
377
361
dur. subsec_nanos( ) / 1_000_000 ) ;
@@ -390,6 +374,14 @@ fn main() {
390
374
std:: process:: exit ( code) ;
391
375
}
392
376
377
+ // Rustc crates for which internal lints are in effect.
378
+ fn use_internal_lints ( crate_name : Option < & str > ) -> bool {
379
+ crate_name. map_or ( false , |crate_name| {
380
+ crate_name. starts_with ( "rustc" ) || crate_name. starts_with ( "syntax" ) ||
381
+ [ "arena" , "fmt_macros" ] . contains ( & crate_name)
382
+ } )
383
+ }
384
+
393
385
#[ cfg( unix) ]
394
386
fn exec_cmd ( cmd : & mut Command ) -> io:: Result < i32 > {
395
387
use std:: os:: unix:: process:: CommandExt ;
0 commit comments