@@ -183,7 +183,7 @@ pub fn run_compiler_with_file_loader<'a, L>(args: &[String],
183
183
None => return ( Ok ( ( ) ) , None ) ,
184
184
} ;
185
185
186
- let sopts = config:: build_session_options ( & matches) ;
186
+ let ( sopts, cfg ) = config:: build_session_options_and_crate_config ( & matches) ;
187
187
188
188
if sopts. debugging_opts . debug_llvm {
189
189
unsafe { llvm:: LLVMRustSetDebug ( 1 ) ; }
@@ -193,14 +193,15 @@ pub fn run_compiler_with_file_loader<'a, L>(args: &[String],
193
193
194
194
do_or_return ! ( callbacks. early_callback( & matches,
195
195
& sopts,
196
+ & cfg,
196
197
& descriptions,
197
198
sopts. error_format) ,
198
199
None ) ;
199
200
200
201
let ( odir, ofile) = make_output ( & matches) ;
201
202
let ( input, input_file_path) = match make_input ( & matches. free ) {
202
203
Some ( ( input, input_file_path) ) => callbacks. some_input ( input, input_file_path) ,
203
- None => match callbacks. no_input ( & matches, & sopts, & odir, & ofile, & descriptions) {
204
+ None => match callbacks. no_input ( & matches, & sopts, & cfg , & odir, & ofile, & descriptions) {
204
205
Some ( ( input, input_file_path) ) => ( input, input_file_path) ,
205
206
None => return ( Ok ( ( ) ) , None ) ,
206
207
} ,
@@ -216,10 +217,11 @@ pub fn run_compiler_with_file_loader<'a, L>(args: &[String],
216
217
cstore. clone ( ) ,
217
218
codemap) ;
218
219
rustc_lint:: register_builtins ( & mut sess. lint_store . borrow_mut ( ) , Some ( & sess) ) ;
219
- let mut cfg = config:: build_configuration ( & sess) ;
220
+ let mut cfg = config:: build_configuration ( & sess, cfg ) ;
220
221
target_features:: add_configuration ( & mut cfg, & sess) ;
221
222
222
- do_or_return ! ( callbacks. late_callback( & matches, & sess, & input, & odir, & ofile) , Some ( sess) ) ;
223
+ do_or_return ! ( callbacks. late_callback( & matches, & sess, & cfg, & input, & odir, & ofile) ,
224
+ Some ( sess) ) ;
223
225
224
226
let plugins = sess. opts . debugging_opts . extra_plugins . clone ( ) ;
225
227
let control = callbacks. build_controller ( & sess, & matches) ;
@@ -299,6 +301,7 @@ pub trait CompilerCalls<'a> {
299
301
fn early_callback ( & mut self ,
300
302
_: & getopts:: Matches ,
301
303
_: & config:: Options ,
304
+ _: & ast:: CrateConfig ,
302
305
_: & errors:: registry:: Registry ,
303
306
_: ErrorOutputType )
304
307
-> Compilation {
@@ -311,6 +314,7 @@ pub trait CompilerCalls<'a> {
311
314
fn late_callback ( & mut self ,
312
315
_: & getopts:: Matches ,
313
316
_: & Session ,
317
+ _: & ast:: CrateConfig ,
314
318
_: & Input ,
315
319
_: & Option < PathBuf > ,
316
320
_: & Option < PathBuf > )
@@ -336,6 +340,7 @@ pub trait CompilerCalls<'a> {
336
340
fn no_input ( & mut self ,
337
341
_: & getopts:: Matches ,
338
342
_: & config:: Options ,
343
+ _: & ast:: CrateConfig ,
339
344
_: & Option < PathBuf > ,
340
345
_: & Option < PathBuf > ,
341
346
_: & errors:: registry:: Registry )
@@ -377,7 +382,7 @@ fn handle_explain(code: &str,
377
382
}
378
383
}
379
384
380
- fn check_cfg ( sopts : & config :: Options ,
385
+ fn check_cfg ( cfg : & ast :: CrateConfig ,
381
386
output : ErrorOutputType ) {
382
387
let emitter: Box < Emitter > = match output {
383
388
config:: ErrorOutputType :: HumanReadable ( color_config) => {
@@ -391,7 +396,7 @@ fn check_cfg(sopts: &config::Options,
391
396
let handler = errors:: Handler :: with_emitter ( true , false , emitter) ;
392
397
393
398
let mut saw_invalid_predicate = false ;
394
- for item in sopts . cfg . iter ( ) {
399
+ for item in cfg. iter ( ) {
395
400
if item. is_meta_item_list ( ) {
396
401
saw_invalid_predicate = true ;
397
402
handler. emit ( & MultiSpan :: new ( ) ,
@@ -409,7 +414,8 @@ fn check_cfg(sopts: &config::Options,
409
414
impl < ' a > CompilerCalls < ' a > for RustcDefaultCalls {
410
415
fn early_callback ( & mut self ,
411
416
matches : & getopts:: Matches ,
412
- sopts : & config:: Options ,
417
+ _: & config:: Options ,
418
+ cfg : & ast:: CrateConfig ,
413
419
descriptions : & errors:: registry:: Registry ,
414
420
output : ErrorOutputType )
415
421
-> Compilation {
@@ -418,13 +424,14 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
418
424
return Compilation :: Stop ;
419
425
}
420
426
421
- check_cfg ( sopts , output) ;
427
+ check_cfg ( cfg , output) ;
422
428
Compilation :: Continue
423
429
}
424
430
425
431
fn no_input ( & mut self ,
426
432
matches : & getopts:: Matches ,
427
433
sopts : & config:: Options ,
434
+ cfg : & ast:: CrateConfig ,
428
435
odir : & Option < PathBuf > ,
429
436
ofile : & Option < PathBuf > ,
430
437
descriptions : & errors:: registry:: Registry )
@@ -445,7 +452,13 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
445
452
descriptions. clone ( ) ,
446
453
cstore. clone ( ) ) ;
447
454
rustc_lint:: register_builtins ( & mut sess. lint_store . borrow_mut ( ) , Some ( & sess) ) ;
448
- let should_stop = RustcDefaultCalls :: print_crate_info ( & sess, None , odir, ofile) ;
455
+ let mut cfg = config:: build_configuration ( & sess, cfg. clone ( ) ) ;
456
+ target_features:: add_configuration ( & mut cfg, & sess) ;
457
+ let should_stop = RustcDefaultCalls :: print_crate_info ( & sess,
458
+ & cfg,
459
+ None ,
460
+ odir,
461
+ ofile) ;
449
462
if should_stop == Compilation :: Stop {
450
463
return None ;
451
464
}
@@ -461,11 +474,12 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
461
474
fn late_callback ( & mut self ,
462
475
matches : & getopts:: Matches ,
463
476
sess : & Session ,
477
+ cfg : & ast:: CrateConfig ,
464
478
input : & Input ,
465
479
odir : & Option < PathBuf > ,
466
480
ofile : & Option < PathBuf > )
467
481
-> Compilation {
468
- RustcDefaultCalls :: print_crate_info ( sess, Some ( input) , odir, ofile)
482
+ RustcDefaultCalls :: print_crate_info ( sess, cfg , Some ( input) , odir, ofile)
469
483
. and_then ( || RustcDefaultCalls :: list_metadata ( sess, matches, input) )
470
484
}
471
485
@@ -584,6 +598,7 @@ impl RustcDefaultCalls {
584
598
585
599
586
600
fn print_crate_info ( sess : & Session ,
601
+ cfg : & ast:: CrateConfig ,
587
602
input : Option < & Input > ,
588
603
odir : & Option < PathBuf > ,
589
604
ofile : & Option < PathBuf > )
@@ -636,9 +651,6 @@ impl RustcDefaultCalls {
636
651
}
637
652
}
638
653
PrintRequest :: Cfg => {
639
- let mut cfg = config:: build_configuration ( & sess) ;
640
- target_features:: add_configuration ( & mut cfg, & sess) ;
641
-
642
654
let allow_unstable_cfg = match get_unstable_features_setting ( ) {
643
655
UnstableFeatures :: Disallow => false ,
644
656
_ => true ,
0 commit comments