@@ -702,10 +702,39 @@ fn unexpected_cfgs_target() {
702
702
. file ( "c/src/lib.rs" , "" )
703
703
. build ( ) ;
704
704
705
- p. cargo ( "check -Zcheck-target-cfgs" )
705
+ p. cargo ( "check -Zcargo-lints - Zcheck-target-cfgs" )
706
706
. masquerade_as_nightly_cargo ( & [ "requires -Zcheck-target-cfgs" ] )
707
- // FIXME: We should warn on multiple cfgs
708
707
. with_stderr_data ( str![ [ r#"
708
+ [WARNING] unexpected `cfg` condition name: foo
709
+ --> Cargo.toml:11:25
710
+ |
711
+ 11 | [target."cfg(any(foo, all(bar)))".dependencies]
712
+ | -------------------------
713
+ |
714
+ [WARNING] unexpected `cfg` condition name: bar
715
+ --> Cargo.toml:11:25
716
+ |
717
+ 11 | [target."cfg(any(foo, all(bar)))".dependencies]
718
+ | -------------------------
719
+ |
720
+ [WARNING] unexpected `cfg` condition value: `` for `windows = ""`
721
+ --> Cargo.toml:18:25
722
+ |
723
+ 18 | [target.'cfg(not(windows = ""))'.dependencies]
724
+ | ------------------------
725
+ |
726
+ [WARNING] unexpected `cfg` condition value: `zoo` for `unix = "zoo"`
727
+ --> Cargo.toml:14:25
728
+ |
729
+ 14 | [target.'cfg(unix = "zoo")'.dependencies]
730
+ | -------------------
731
+ |
732
+ [WARNING] unexpected `cfg` condition value: `zoo` for `unix = "zoo"`
733
+ --> Cargo.toml:14:25
734
+ |
735
+ 14 | [target.'cfg(unix = "zoo")'.dependencies]
736
+ | -------------------
737
+ |
709
738
[LOCKING] 2 packages to latest compatible versions
710
739
[CHECKING] b v0.0.1 ([ROOT]/foo/b)
711
740
[CHECKING] a v0.0.1 ([ROOT]/foo)
@@ -752,10 +781,28 @@ fn unexpected_cfgs_target_with_lint() {
752
781
. file ( "b/src/lib.rs" , "" )
753
782
. build ( ) ;
754
783
755
- p. cargo ( "check -Zcheck-target-cfgs" )
784
+ p. cargo ( "check -Zcargo-lints - Zcheck-target-cfgs" )
756
785
. masquerade_as_nightly_cargo ( & [ "requires -Zcheck-target-cfgs" ] )
757
- // FIXME: We should warn on multiple cfgs
786
+ // FIXME: We should not warn on `cfg(foo = "foo")` but we currently do
758
787
. with_stderr_data ( str![ [ r#"
788
+ [WARNING] unexpected `cfg` condition name: bar
789
+ --> Cargo.toml:14:25
790
+ |
791
+ 14 | [target."cfg(bar)".dependencies]
792
+ | ----------
793
+ |
794
+ [WARNING] unexpected `cfg` condition name: foo for `foo = "foo"`
795
+ --> Cargo.toml:11:25
796
+ |
797
+ 11 | [target.'cfg(foo = "foo")'.dependencies] # should not warn here
798
+ | ------------------
799
+ |
800
+ [WARNING] unexpected `cfg` condition name: foo
801
+ --> Cargo.toml:8:25
802
+ |
803
+ 8 | [target."cfg(foo)".dependencies] # should not warn here
804
+ | ----------
805
+ |
759
806
[LOCKING] 1 package to latest compatible version
760
807
[CHECKING] a v0.0.1 ([ROOT]/foo)
761
808
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
@@ -776,10 +823,10 @@ fn unexpected_cfgs_target_diagnostics() {
776
823
edition = "2015"
777
824
authors = []
778
825
779
- [target."cfg(target_pointer_width)".dependencies]
826
+ [target."cfg(target_pointer_width)".dependencies] # expect (none) as value
780
827
b = { path = 'b' }
781
828
782
- [target.'cfg( all(foo , bar))'.dependencies]
829
+ [target.'cfg( all(foo , bar))'.dependencies] # no snippet due to weird formatting
783
830
b = { path = 'b' }
784
831
"# ,
785
832
)
@@ -788,9 +835,19 @@ fn unexpected_cfgs_target_diagnostics() {
788
835
. file ( "b/src/lib.rs" , "" )
789
836
. build ( ) ;
790
837
791
- p. cargo ( "check -Zcheck-target-cfgs" )
838
+ p. cargo ( "check -Zcargo-lints - Zcheck-target-cfgs" )
792
839
. masquerade_as_nightly_cargo ( & [ "requires -Zcheck-target-cfgs" ] )
793
840
. with_stderr_data ( str![ [ r#"
841
+ [WARNING] unexpected `cfg` condition name: foo in `[target.'cfg(all(foo, bar))']`
842
+ = [HELP] occurred in `[ROOT]/foo/Cargo.toml`
843
+ [WARNING] unexpected `cfg` condition name: bar in `[target.'cfg(all(foo, bar))']`
844
+ = [HELP] occurred in `[ROOT]/foo/Cargo.toml`
845
+ [WARNING] unexpected `cfg` condition value: (none) for `target_pointer_width`
846
+ --> Cargo.toml:8:25
847
+ |
848
+ 8 | [target."cfg(target_pointer_width)".dependencies] # expect (none) as value
849
+ | ---------------------------
850
+ |
794
851
[LOCKING] 1 package to latest compatible version
795
852
[CHECKING] a v0.0.1 ([ROOT]/foo)
796
853
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
@@ -823,10 +880,16 @@ fn unexpected_cfgs_target_lint_level_allow() {
823
880
. file ( "b/src/lib.rs" , "" )
824
881
. build ( ) ;
825
882
826
- p. cargo ( "check -Zcheck-target-cfgs" )
883
+ p. cargo ( "check -Zcargo-lints - Zcheck-target-cfgs" )
827
884
. masquerade_as_nightly_cargo ( & [ "requires -Zcheck-target-cfgs" ] )
828
- // FIXME: We should warn on multiple cfgs
885
+ // FIXME: We shouldn't warn any target cfgs because of the level="allow"
829
886
. with_stderr_data ( str![ [ r#"
887
+ [WARNING] unexpected `cfg` condition name: foo
888
+ --> Cargo.toml:8:25
889
+ |
890
+ 8 | [target."cfg(foo)".dependencies]
891
+ | ----------
892
+ |
830
893
[LOCKING] 1 package to latest compatible version
831
894
[CHECKING] a v0.0.1 ([ROOT]/foo)
832
895
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
@@ -859,9 +922,15 @@ fn unexpected_cfgs_target_lint_level_deny() {
859
922
. file ( "b/src/lib.rs" , "" )
860
923
. build ( ) ;
861
924
862
- p. cargo ( "check -Zcheck-target-cfgs" )
925
+ p. cargo ( "check -Zcargo-lints - Zcheck-target-cfgs" )
863
926
. masquerade_as_nightly_cargo ( & [ "requires -Zcheck-target-cfgs" ] )
864
927
. with_stderr_data ( str![ [ r#"
928
+ [WARNING] unexpected `cfg` condition name: foo
929
+ --> Cargo.toml:8:25
930
+ |
931
+ 8 | [target."cfg(foo)".dependencies]
932
+ | ----------
933
+ |
865
934
[LOCKING] 1 package to latest compatible version
866
935
[CHECKING] a v0.0.1 ([ROOT]/foo)
867
936
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
@@ -897,9 +966,16 @@ fn unexpected_cfgs_target_cfg_any() {
897
966
. file ( "b/src/lib.rs" , "" )
898
967
. build ( ) ;
899
968
900
- p. cargo ( "check -Zcheck-target-cfgs" )
969
+ p. cargo ( "check -Zcargo-lints - Zcheck-target-cfgs" )
901
970
. masquerade_as_nightly_cargo ( & [ "requires -Zcheck-target-cfgs" ] )
971
+ // FIXME: We shouldn't be linting `cfg(foo)` because of the `cfg(any())`
902
972
. with_stderr_data ( str![ [ r#"
973
+ [WARNING] unexpected `cfg` condition name: foo
974
+ --> Cargo.toml:8:25
975
+ |
976
+ 8 | [target."cfg(foo)".dependencies]
977
+ | ----------
978
+ |
903
979
[LOCKING] 1 package to latest compatible version
904
980
[CHECKING] a v0.0.1 ([ROOT]/foo)
905
981
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
@@ -952,9 +1028,6 @@ fn no_unexpected_cfgs_target() {
952
1028
p. cargo ( "check -Zcargo-lints" )
953
1029
. masquerade_as_nightly_cargo ( & [ "requires -Zcargo-lints" ] )
954
1030
. with_stderr_data ( str![ [ r#"
955
- [LOCKING] 1 package to latest compatible version
956
- [CHECKING] b v0.0.1 ([ROOT]/foo/b)
957
- [CHECKING] a v0.0.1 ([ROOT]/foo)
958
1031
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
959
1032
960
1033
"# ] ] )
0 commit comments