@@ -163,7 +163,10 @@ impl<'a> std::fmt::Debug for CrateDump<'a> {
163
163
enum CrateOrigin < ' a > {
164
164
/// This crate was a dependency of another crate.
165
165
Dependency {
166
+ /// Where this dependency was included from.
166
167
dep_root : & ' a CratePaths ,
168
+ /// True if the parent is private, meaning the dependent should also be private.
169
+ parent_private : bool ,
167
170
/// Dependency info about this crate.
168
171
dep : & ' a CrateDep ,
169
172
} ,
@@ -193,6 +196,17 @@ impl<'a> CrateOrigin<'a> {
193
196
_ => None ,
194
197
}
195
198
}
199
+
200
+ /// `Some(true)` if the dependency is private or its parent is private, `Some(false)` if the
201
+ /// dependency is not private, `None` if it could not be determined.
202
+ fn private_dep ( & self ) -> Option < bool > {
203
+ match self {
204
+ CrateOrigin :: Dependency { parent_private, dep, .. } => {
205
+ Some ( dep. is_private || * parent_private)
206
+ }
207
+ _ => None ,
208
+ }
209
+ }
196
210
}
197
211
198
212
impl CStore {
@@ -497,7 +511,8 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
497
511
& crate_paths
498
512
} ;
499
513
500
- let cnum_map = self . resolve_crate_deps ( dep_root, & crate_root, & metadata, cnum, dep_kind) ?;
514
+ let cnum_map =
515
+ self . resolve_crate_deps ( dep_root, & crate_root, & metadata, cnum, dep_kind, private_dep) ?;
501
516
502
517
let raw_proc_macros = if crate_root. is_proc_macro_crate ( ) {
503
518
let temp_root;
@@ -638,7 +653,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
638
653
let host_hash = dep. map ( |d| d. host_hash ) . flatten ( ) ;
639
654
let extra_filename = dep. map ( |d| & d. extra_filename [ ..] ) ;
640
655
let path_kind = if dep. is_some ( ) { PathKind :: Dependency } else { PathKind :: Crate } ;
641
- let private_dep = dep . map ( |d| d . is_private ) ;
656
+ let private_dep = origin . private_dep ( ) ;
642
657
643
658
let result = if let Some ( cnum) = self . existing_match ( name, hash, path_kind) {
644
659
( LoadResult :: Previous ( cnum) , None )
@@ -735,6 +750,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
735
750
metadata : & MetadataBlob ,
736
751
krate : CrateNum ,
737
752
dep_kind : CrateDepKind ,
753
+ parent_is_private : bool ,
738
754
) -> Result < CrateNumMap , CrateError > {
739
755
debug ! (
740
756
"resolving deps of external crate `{}` with dep root `{}`" ,
@@ -753,18 +769,20 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
753
769
crate_num_map. push ( krate) ;
754
770
for dep in deps {
755
771
info ! (
756
- "resolving dep `{}`->`{}` hash: `{}` extra filename: `{}`" ,
772
+ "resolving dep `{}`->`{}` hash: `{}` extra filename: `{}` private {} " ,
757
773
crate_root. name( ) ,
758
774
dep. name,
759
775
dep. hash,
760
- dep. extra_filename
776
+ dep. extra_filename,
777
+ dep. is_private,
761
778
) ;
762
779
let dep_kind = match dep_kind {
763
780
CrateDepKind :: MacrosOnly => CrateDepKind :: MacrosOnly ,
764
781
_ => dep. kind ,
765
782
} ;
766
783
let cnum = self . maybe_resolve_crate ( dep. name , dep_kind, CrateOrigin :: Dependency {
767
784
dep_root,
785
+ parent_private : parent_is_private,
768
786
dep : & dep,
769
787
} ) ?;
770
788
crate_num_map. push ( cnum) ;
0 commit comments