@@ -564,10 +564,39 @@ fn unexpected_cfgs_target() {
564
564
. file ( "c/src/lib.rs" , "" )
565
565
. build ( ) ;
566
566
567
- p. cargo ( "check -Zcheck-target-cfgs" )
567
+ p. cargo ( "check -Zcargo-lints - Zcheck-target-cfgs" )
568
568
. masquerade_as_nightly_cargo ( & [ "requires -Zcheck-target-cfgs" ] )
569
- // FIXME: We should warn on multiple cfgs
570
569
. with_stderr_data ( str![ [ r#"
570
+ [WARNING] unexpected `cfg` condition name: foo
571
+ --> Cargo.toml:11:25
572
+ |
573
+ 11 | [target."cfg(any(foo, all(bar)))".dependencies]
574
+ | -------------------------
575
+ |
576
+ [WARNING] unexpected `cfg` condition name: bar
577
+ --> Cargo.toml:11:25
578
+ |
579
+ 11 | [target."cfg(any(foo, all(bar)))".dependencies]
580
+ | -------------------------
581
+ |
582
+ [WARNING] unexpected `cfg` condition value: `` for `windows = ""`
583
+ --> Cargo.toml:18:25
584
+ |
585
+ 18 | [target.'cfg(not(windows = ""))'.dependencies]
586
+ | ------------------------
587
+ |
588
+ [WARNING] unexpected `cfg` condition value: `zoo` for `unix = "zoo"`
589
+ --> Cargo.toml:14:25
590
+ |
591
+ 14 | [target.'cfg(unix = "zoo")'.dependencies]
592
+ | -------------------
593
+ |
594
+ [WARNING] unexpected `cfg` condition value: `zoo` for `unix = "zoo"`
595
+ --> Cargo.toml:14:25
596
+ |
597
+ 14 | [target.'cfg(unix = "zoo")'.dependencies]
598
+ | -------------------
599
+ |
571
600
[LOCKING] 2 packages to latest compatible versions
572
601
[CHECKING] b v0.0.1 ([ROOT]/foo/b)
573
602
[CHECKING] a v0.0.1 ([ROOT]/foo)
@@ -614,10 +643,28 @@ fn unexpected_cfgs_target_with_lint() {
614
643
. file ( "b/src/lib.rs" , "" )
615
644
. build ( ) ;
616
645
617
- p. cargo ( "check -Zcheck-target-cfgs" )
646
+ p. cargo ( "check -Zcargo-lints - Zcheck-target-cfgs" )
618
647
. masquerade_as_nightly_cargo ( & [ "requires -Zcheck-target-cfgs" ] )
619
- // FIXME: We should warn on multiple cfgs
648
+ // FIXME: We should not warn on `cfg(foo = "foo")` but we currently do
620
649
. with_stderr_data ( str![ [ r#"
650
+ [WARNING] unexpected `cfg` condition name: bar
651
+ --> Cargo.toml:14:25
652
+ |
653
+ 14 | [target."cfg(bar)".dependencies]
654
+ | ----------
655
+ |
656
+ [WARNING] unexpected `cfg` condition name: foo for `foo = "foo"`
657
+ --> Cargo.toml:11:25
658
+ |
659
+ 11 | [target.'cfg(foo = "foo")'.dependencies] # should not warn here
660
+ | ------------------
661
+ |
662
+ [WARNING] unexpected `cfg` condition name: foo
663
+ --> Cargo.toml:8:25
664
+ |
665
+ 8 | [target."cfg(foo)".dependencies] # should not warn here
666
+ | ----------
667
+ |
621
668
[LOCKING] 1 package to latest compatible version
622
669
[CHECKING] a v0.0.1 ([ROOT]/foo)
623
670
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
@@ -638,10 +685,10 @@ fn unexpected_cfgs_target_diagnostics() {
638
685
edition = "2015"
639
686
authors = []
640
687
641
- [target."cfg(target_pointer_width)".dependencies]
688
+ [target."cfg(target_pointer_width)".dependencies] # expect (none) as value
642
689
b = { path = 'b' }
643
690
644
- [target.'cfg( all(foo , bar))'.dependencies]
691
+ [target.'cfg( all(foo , bar))'.dependencies] # no snippet due to weird formatting
645
692
b = { path = 'b' }
646
693
"# ,
647
694
)
@@ -650,9 +697,19 @@ fn unexpected_cfgs_target_diagnostics() {
650
697
. file ( "b/src/lib.rs" , "" )
651
698
. build ( ) ;
652
699
653
- p. cargo ( "check -Zcheck-target-cfgs" )
700
+ p. cargo ( "check -Zcargo-lints - Zcheck-target-cfgs" )
654
701
. masquerade_as_nightly_cargo ( & [ "requires -Zcheck-target-cfgs" ] )
655
702
. with_stderr_data ( str![ [ r#"
703
+ [WARNING] unexpected `cfg` condition name: foo in `[target.'cfg(all(foo, bar))']`
704
+ = [HELP] occurred in `[ROOT]/foo/Cargo.toml`
705
+ [WARNING] unexpected `cfg` condition name: bar in `[target.'cfg(all(foo, bar))']`
706
+ = [HELP] occurred in `[ROOT]/foo/Cargo.toml`
707
+ [WARNING] unexpected `cfg` condition value: (none) for `target_pointer_width`
708
+ --> Cargo.toml:8:25
709
+ |
710
+ 8 | [target."cfg(target_pointer_width)".dependencies] # expect (none) as value
711
+ | ---------------------------
712
+ |
656
713
[LOCKING] 1 package to latest compatible version
657
714
[CHECKING] a v0.0.1 ([ROOT]/foo)
658
715
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
@@ -685,10 +742,16 @@ fn unexpected_cfgs_target_lint_level_allow() {
685
742
. file ( "b/src/lib.rs" , "" )
686
743
. build ( ) ;
687
744
688
- p. cargo ( "check -Zcheck-target-cfgs" )
745
+ p. cargo ( "check -Zcargo-lints - Zcheck-target-cfgs" )
689
746
. masquerade_as_nightly_cargo ( & [ "requires -Zcheck-target-cfgs" ] )
690
- // FIXME: We should warn on multiple cfgs
747
+ // FIXME: We shouldn't warn any target cfgs because of the level="allow"
691
748
. with_stderr_data ( str![ [ r#"
749
+ [WARNING] unexpected `cfg` condition name: foo
750
+ --> Cargo.toml:8:25
751
+ |
752
+ 8 | [target."cfg(foo)".dependencies]
753
+ | ----------
754
+ |
692
755
[LOCKING] 1 package to latest compatible version
693
756
[CHECKING] a v0.0.1 ([ROOT]/foo)
694
757
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
@@ -721,9 +784,15 @@ fn unexpected_cfgs_target_lint_level_deny() {
721
784
. file ( "b/src/lib.rs" , "" )
722
785
. build ( ) ;
723
786
724
- p. cargo ( "check -Zcheck-target-cfgs" )
787
+ p. cargo ( "check -Zcargo-lints - Zcheck-target-cfgs" )
725
788
. masquerade_as_nightly_cargo ( & [ "requires -Zcheck-target-cfgs" ] )
726
789
. with_stderr_data ( str![ [ r#"
790
+ [WARNING] unexpected `cfg` condition name: foo
791
+ --> Cargo.toml:8:25
792
+ |
793
+ 8 | [target."cfg(foo)".dependencies]
794
+ | ----------
795
+ |
727
796
[LOCKING] 1 package to latest compatible version
728
797
[CHECKING] a v0.0.1 ([ROOT]/foo)
729
798
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
@@ -759,9 +828,16 @@ fn unexpected_cfgs_target_cfg_any() {
759
828
. file ( "b/src/lib.rs" , "" )
760
829
. build ( ) ;
761
830
762
- p. cargo ( "check -Zcheck-target-cfgs" )
831
+ p. cargo ( "check -Zcargo-lints - Zcheck-target-cfgs" )
763
832
. masquerade_as_nightly_cargo ( & [ "requires -Zcheck-target-cfgs" ] )
833
+ // FIXME: We shouldn't be linting `cfg(foo)` because of the `cfg(any())`
764
834
. with_stderr_data ( str![ [ r#"
835
+ [WARNING] unexpected `cfg` condition name: foo
836
+ --> Cargo.toml:8:25
837
+ |
838
+ 8 | [target."cfg(foo)".dependencies]
839
+ | ----------
840
+ |
765
841
[LOCKING] 1 package to latest compatible version
766
842
[CHECKING] a v0.0.1 ([ROOT]/foo)
767
843
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
@@ -814,9 +890,6 @@ fn no_unexpected_cfgs_target() {
814
890
p. cargo ( "check -Zcargo-lints" )
815
891
. masquerade_as_nightly_cargo ( & [ "requires -Zcargo-lints" ] )
816
892
. with_stderr_data ( str![ [ r#"
817
- [LOCKING] 1 package to latest compatible version
818
- [CHECKING] b v0.0.1 ([ROOT]/foo/b)
819
- [CHECKING] a v0.0.1 ([ROOT]/foo)
820
893
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
821
894
822
895
"# ] ] )
0 commit comments