@@ -480,6 +480,9 @@ fn allow_priv_in_custom_build() {
480
480
. run ( )
481
481
}
482
482
483
+
484
+ // A indirectly add D as private dependency.
485
+ // A -> B -> C -> D
483
486
#[ cargo_test( nightly, reason = "exported_private_dependencies lint is unstable" ) ]
484
487
fn recursive_package_pub_no_warning ( ) {
485
488
Package :: new ( "grandparent_bar" , "0.1.0" )
@@ -549,6 +552,8 @@ fn recursive_package_pub_no_warning() {
549
552
. run ( )
550
553
}
551
554
555
+ // A indirectly add D as private dependency.
556
+ // A -> B -> C -> D
552
557
#[ cargo_test( nightly, reason = "exported_private_dependencies lint is unstable" ) ]
553
558
fn recursive_package_priv_warning ( ) {
554
559
Package :: new ( "grandparent_bar" , "0.1.0" )
@@ -617,3 +622,78 @@ fn recursive_package_priv_warning() {
617
622
)
618
623
. run ( )
619
624
}
625
+
626
+ // A indirectly add D as public dependency, then directly add D as private dependency.
627
+ // A -> B -> C -> D
628
+ // \ _ _ _ _ _ /|\
629
+ #[ cargo_test( nightly, reason = "exported_private_dependencies lint is unstable" ) ]
630
+ fn recursive_package_pub_priv_together ( ) {
631
+ Package :: new ( "grandparent_bar" , "0.1.0" )
632
+ . file ( "src/lib.rs" , "pub struct FromPriv;" )
633
+ . publish ( ) ;
634
+ Package :: new ( "parent_bar" , "0.1.0" )
635
+ . cargo_feature ( "public-dependency" )
636
+ . add_dep ( Dependency :: new ( "grandparent_bar" , "0.1.0" ) . public ( true ) )
637
+ . file (
638
+ "src/lib.rs" ,
639
+ "
640
+ extern crate grandparent_bar;
641
+ pub use grandparent_bar::*;
642
+ " ,
643
+ )
644
+ . publish ( ) ;
645
+ Package :: new ( "pub_dep" , "0.1.0" )
646
+ . cargo_feature ( "public-dependency" )
647
+ . add_dep ( Dependency :: new ( "parent_bar" , "0.1.0" ) . public ( true ) )
648
+ . file (
649
+ "src/lib.rs" ,
650
+ "
651
+ extern crate parent_bar;
652
+ pub use parent_bar::*;
653
+ " ,
654
+ )
655
+ . publish ( ) ;
656
+ let p = project ( )
657
+ . file (
658
+ "Cargo.toml" ,
659
+ r#"
660
+ cargo-features = ["public-dependency"]
661
+
662
+ [package]
663
+ name = "foo"
664
+ version = "0.0.1"
665
+
666
+ [dependencies]
667
+ pub_dep = {version = "0.1.0", public = true}
668
+ grandparent_bar = "0.1.0"
669
+ "# ,
670
+ )
671
+ . file (
672
+ "src/lib.rs" ,
673
+ "
674
+ extern crate pub_dep;
675
+ extern crate grandparent_bar;
676
+
677
+ pub fn use_pub(_: grandparent_bar::FromPriv) {}
678
+ " ,
679
+ )
680
+ . build ( ) ;
681
+
682
+ p. cargo ( "check --message-format=short" )
683
+ . masquerade_as_nightly_cargo ( & [ "public-dependency" ] )
684
+ . with_stderr (
685
+ "\
686
+ [UPDATING] `[..]` index
687
+ [DOWNLOADING] crates ...
688
+ [DOWNLOADED] pub_dep v0.1.0 ([..])
689
+ [DOWNLOADED] parent_bar v0.1.0 ([..])
690
+ [DOWNLOADED] grandparent_bar v0.1.0 ([..])
691
+ [CHECKING] grandparent_bar v0.1.0
692
+ [CHECKING] parent_bar v0.1.0
693
+ [CHECKING] pub_dep v0.1.0
694
+ [CHECKING] foo v0.0.1 ([..])
695
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
696
+ " ,
697
+ )
698
+ . run ( )
699
+ }
0 commit comments