@@ -136,20 +136,15 @@ fn requires_feature() {
136
136
137
137
p. cargo ( "check --message-format=short" )
138
138
. masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
139
- . with_status ( 101 )
140
139
. with_stderr (
141
140
"\
142
- error: failed to parse manifest at `[..]`
143
-
144
- Caused by:
145
- feature `public-dependency` is required
146
-
147
- The package requires the Cargo feature called `public-dependency`, \
148
- but that feature is not stabilized in this version of Cargo (1.[..]).
149
- Consider adding `cargo-features = [\" public-dependency\" ]` to the top of Cargo.toml \
150
- (above the [package] table) to tell Cargo you are opting in to use this unstable feature.
151
- See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#public-dependency \
152
- for more information about the status of this feature.
141
+ [WARNING] Ignoring `public` on dependency pub_dep. Pass `-Zpublic-dependency` to enable support for it
142
+ [UPDATING] `[..]` index
143
+ [DOWNLOADING] crates ...
144
+ [DOWNLOADED] pub_dep v0.1.0 ([..])
145
+ [CHECKING] pub_dep v0.1.0
146
+ [CHECKING] foo v0.0.1 ([CWD])
147
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
153
148
" ,
154
149
)
155
150
. run ( )
@@ -198,6 +193,47 @@ Caused by:
198
193
. run ( )
199
194
}
200
195
196
+ #[ cargo_test]
197
+ fn pub_dev_dependency_without_feature ( ) {
198
+ Package :: new ( "pub_dep" , "0.1.0" )
199
+ . file ( "src/lib.rs" , "pub struct FromPub;" )
200
+ . publish ( ) ;
201
+
202
+ let p = project ( )
203
+ . file (
204
+ "Cargo.toml" ,
205
+ r#"
206
+ [package]
207
+ name = "foo"
208
+ version = "0.0.1"
209
+
210
+ [dev-dependencies]
211
+ pub_dep = {version = "0.1.0", public = true}
212
+ "# ,
213
+ )
214
+ . file (
215
+ "src/lib.rs" ,
216
+ "
217
+ extern crate pub_dep;
218
+ pub fn use_pub(_: pub_dep::FromPub) {}
219
+ " ,
220
+ )
221
+ . build ( ) ;
222
+
223
+ p. cargo ( "check --message-format=short" )
224
+ . masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
225
+ . with_status ( 101 )
226
+ . with_stderr (
227
+ "\
228
+ [ERROR] failed to parse manifest at `[..]`
229
+
230
+ Caused by:
231
+ 'public' specifier can only be used on regular dependencies, not Development dependencies
232
+ " ,
233
+ )
234
+ . run ( )
235
+ }
236
+
201
237
#[ cargo_test( nightly, reason = "exported_private_dependencies lint is unstable" ) ]
202
238
fn workspace_pub_disallowed ( ) {
203
239
Package :: new ( "foo1" , "0.1.0" )
@@ -534,3 +570,102 @@ fn publish_package_with_public_dependency() {
534
570
)
535
571
. run ( )
536
572
}
573
+
574
+ #[ cargo_test( nightly, reason = "exported_private_dependencies lint is unstable" ) ]
575
+ fn verify_mix_cargo_feature_z ( ) {
576
+ Package :: new ( "dep" , "0.1.0" )
577
+ . file ( "src/lib.rs" , "pub struct FromDep;" )
578
+ . publish ( ) ;
579
+ Package :: new ( "priv_dep" , "0.1.0" )
580
+ . file ( "src/lib.rs" , "pub struct FromPriv;" )
581
+ . publish ( ) ;
582
+ Package :: new ( "pub_dep" , "0.1.0" )
583
+ . file ( "src/lib.rs" , "pub struct FromPub;" )
584
+ . publish ( ) ;
585
+ let p = project ( )
586
+ . file (
587
+ "Cargo.toml" ,
588
+ r#"
589
+ cargo-features = ["public-dependency"]
590
+ [package]
591
+ name = "foo"
592
+ version = "0.0.1"
593
+
594
+ [dependencies]
595
+ dep = "0.1.0"
596
+ priv_dep = {version = "0.1.0", public = false}
597
+ pub_dep = {version = "0.1.0", public = true}
598
+ "# ,
599
+ )
600
+ . file (
601
+ "src/lib.rs" ,
602
+ "
603
+ extern crate dep;
604
+ extern crate priv_dep;
605
+ extern crate pub_dep;
606
+ pub fn use_dep(_: dep::FromDep) {}
607
+ pub fn use_priv(_: priv_dep::FromPriv) {}
608
+ pub fn use_pub(_: pub_dep::FromPub) {}
609
+ " ,
610
+ )
611
+ . build ( ) ;
612
+
613
+ p. cargo ( "check -Zpublic-dependency --message-format=short" )
614
+ . masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
615
+ . with_stderr_contains (
616
+ "\
617
+ src/lib.rs:5:13: warning: type `FromDep` from private dependency 'dep' in public interface
618
+ src/lib.rs:6:13: warning: type `FromPriv` from private dependency 'priv_dep' in public interface
619
+ " ,
620
+ )
621
+ . run ( ) ;
622
+ }
623
+
624
+ #[ cargo_test( nightly, reason = "exported_private_dependencies lint is unstable" ) ]
625
+ fn verify_z_public_dependency ( ) {
626
+ Package :: new ( "dep" , "0.1.0" )
627
+ . file ( "src/lib.rs" , "pub struct FromDep;" )
628
+ . publish ( ) ;
629
+ Package :: new ( "priv_dep" , "0.1.0" )
630
+ . file ( "src/lib.rs" , "pub struct FromPriv;" )
631
+ . publish ( ) ;
632
+ Package :: new ( "pub_dep" , "0.1.0" )
633
+ . file ( "src/lib.rs" , "pub struct FromPub;" )
634
+ . publish ( ) ;
635
+ let p = project ( )
636
+ . file (
637
+ "Cargo.toml" ,
638
+ r#"
639
+ [package]
640
+ name = "foo"
641
+ version = "0.0.1"
642
+
643
+ [dependencies]
644
+ dep = "0.1.0"
645
+ priv_dep = {version = "0.1.0", public = false}
646
+ pub_dep = {version = "0.1.0", public = true}
647
+ "# ,
648
+ )
649
+ . file (
650
+ "src/lib.rs" ,
651
+ "
652
+ extern crate dep;
653
+ extern crate priv_dep;
654
+ extern crate pub_dep;
655
+ pub fn use_dep(_: dep::FromDep) {}
656
+ pub fn use_priv(_: priv_dep::FromPriv) {}
657
+ pub fn use_pub(_: pub_dep::FromPub) {}
658
+ " ,
659
+ )
660
+ . build ( ) ;
661
+
662
+ p. cargo ( "check -Zpublic-dependency --message-format=short" )
663
+ . masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
664
+ . with_stderr_contains (
665
+ "\
666
+ src/lib.rs:5:13: warning: type `FromDep` from private dependency 'dep' in public interface
667
+ src/lib.rs:6:13: warning: type `FromPriv` from private dependency 'priv_dep' in public interface
668
+ " ,
669
+ )
670
+ . run ( ) ;
671
+ }
0 commit comments