File tree 3 files changed +94
-2
lines changed 3 files changed +94
-2
lines changed Original file line number Diff line number Diff line change @@ -803,7 +803,7 @@ impl BuildOutput {
803
803
if extra_check_cfg {
804
804
check_cfgs. push ( value. to_string ( ) ) ;
805
805
} else {
806
- warnings. push ( format ! ( "cargo:{} requires -Zcheck-cfg=output flag" , key) ) ;
806
+ warnings. push ( format ! ( "cargo:{} requires -Zcheck-cfg flag" , key) ) ;
807
807
}
808
808
}
809
809
"rustc-env" => {
Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ fn parse_links_overrides(
208
208
output. check_cfgs . extend ( list. iter ( ) . map ( |v| v. 0 . clone ( ) ) ) ;
209
209
} else {
210
210
config. shell ( ) . warn ( format ! (
211
- "target config `{}.{}` requires -Zcheck-cfg=output flag" ,
211
+ "target config `{}.{}` requires -Zcheck-cfg flag" ,
212
212
target_key, key
213
213
) ) ?;
214
214
}
Original file line number Diff line number Diff line change @@ -354,6 +354,41 @@ fn build_script_override() {
354
354
. run ( ) ;
355
355
}
356
356
357
+ #[ cargo_test]
358
+ fn build_script_override_feature_gate ( ) {
359
+ let target = cargo_test_support:: rustc_host ( ) ;
360
+
361
+ let p = project ( )
362
+ . file (
363
+ "Cargo.toml" ,
364
+ r#"
365
+ [package]
366
+ name = "foo"
367
+ version = "0.1.0"
368
+ links = "a"
369
+ "# ,
370
+ )
371
+ . file ( "src/main.rs" , "fn main() {}" )
372
+ . file ( "build.rs" , "fn main() {}" )
373
+ . file (
374
+ ".cargo/config" ,
375
+ & format ! (
376
+ r#"
377
+ [target.{}.a]
378
+ rustc-check-cfg = ["cfg(foo)"]
379
+ "# ,
380
+ target
381
+ ) ,
382
+ )
383
+ . build ( ) ;
384
+
385
+ p. cargo ( "check" )
386
+ . with_stderr_contains (
387
+ "warning: target config[..]rustc-check-cfg[..] requires -Zcheck-cfg flag" ,
388
+ )
389
+ . run ( ) ;
390
+ }
391
+
357
392
#[ cargo_test( nightly, reason = "--check-cfg is unstable" ) ]
358
393
fn build_script_test ( ) {
359
394
let p = project ( )
@@ -409,6 +444,34 @@ fn build_script_test() {
409
444
. run ( ) ;
410
445
}
411
446
447
+ #[ cargo_test]
448
+ fn build_script_feature_gate ( ) {
449
+ let p = project ( )
450
+ . file (
451
+ "Cargo.toml" ,
452
+ r#"
453
+ [package]
454
+ name = "foo"
455
+ version = "0.0.1"
456
+ build = "build.rs"
457
+ "# ,
458
+ )
459
+ . file (
460
+ "build.rs" ,
461
+ r#"fn main() {
462
+ println!("cargo:rustc-check-cfg=cfg(foo)");
463
+ println!("cargo:rustc-cfg=foo");
464
+ }"# ,
465
+ )
466
+ . file ( "src/main.rs" , "fn main() {}" )
467
+ . build ( ) ;
468
+
469
+ p. cargo ( "check" )
470
+ . with_stderr_contains ( "warning[..]cargo:rustc-check-cfg requires -Zcheck-cfg flag" )
471
+ . with_status ( 0 )
472
+ . run ( ) ;
473
+ }
474
+
412
475
#[ cargo_test( nightly, reason = "--check-cfg is unstable" ) ]
413
476
fn config_valid ( ) {
414
477
let p = project ( )
@@ -467,3 +530,32 @@ fn config_invalid() {
467
530
. with_status ( 101 )
468
531
. run ( ) ;
469
532
}
533
+
534
+ #[ cargo_test]
535
+ fn config_feature_gate ( ) {
536
+ let p = project ( )
537
+ . file (
538
+ "Cargo.toml" ,
539
+ r#"
540
+ [package]
541
+ name = "foo"
542
+ version = "0.1.0"
543
+
544
+ [features]
545
+ f_a = []
546
+ "# ,
547
+ )
548
+ . file ( "src/main.rs" , "fn main() {}" )
549
+ . file (
550
+ ".cargo/config.toml" ,
551
+ r#"
552
+ [unstable]
553
+ check-cfg = true
554
+ "# ,
555
+ )
556
+ . build ( ) ;
557
+
558
+ p. cargo ( "check -v" )
559
+ . with_stderr_does_not_contain ( "--check-cfg" )
560
+ . run ( ) ;
561
+ }
You can’t perform that action at this time.
0 commit comments