@@ -9,7 +9,7 @@ use rustc_data_structures::captures::Captures;
99use rustc_data_structures:: fx:: FxHashMap ;
1010use rustc_data_structures:: owned_slice:: OwnedSlice ;
1111use rustc_data_structures:: svh:: Svh ;
12- use rustc_data_structures:: sync:: { AppendOnlyVec , Lock , Lrc , OnceCell } ;
12+ use rustc_data_structures:: sync:: { AppendOnlyVec , AtomicBool , Lock , Lrc , OnceCell } ;
1313use rustc_data_structures:: unhash:: UnhashMap ;
1414use rustc_expand:: base:: { SyntaxExtension , SyntaxExtensionKind } ;
1515use rustc_expand:: proc_macro:: { AttrProcMacro , BangProcMacro , DeriveProcMacro } ;
@@ -40,6 +40,7 @@ use proc_macro::bridge::client::ProcMacro;
4040use std:: iter:: TrustedLen ;
4141use std:: num:: NonZeroUsize ;
4242use std:: path:: Path ;
43+ use std:: sync:: atomic:: Ordering ;
4344use std:: { io, iter, mem} ;
4445
4546pub ( super ) use cstore_impl:: provide;
@@ -112,9 +113,10 @@ pub(crate) struct CrateMetadata {
112113 dep_kind : Lock < CrateDepKind > ,
113114 /// Filesystem location of this crate.
114115 source : Lrc < CrateSource > ,
115- /// Whether or not this crate should be consider a private dependency
116- /// for purposes of the 'exported_private_dependencies' lint
117- private_dep : bool ,
116+ /// Whether or not this crate should be consider a private dependency.
117+ /// Used by the 'exported_private_dependencies' lint, and for determining
118+ /// whether to emit suggestions that reference this crate.
119+ private_dep : AtomicBool ,
118120 /// The hash for the host proc macro. Used to support `-Z dual-proc-macro`.
119121 host_hash : Option < Svh > ,
120122
@@ -701,12 +703,13 @@ impl MetadataBlob {
701703 writeln ! ( out, "=External Dependencies=" ) ?;
702704
703705 for ( i, dep) in root. crate_deps . decode ( self ) . enumerate ( ) {
704- let CrateDep { name, extra_filename, hash, host_hash, kind } = dep;
706+ let CrateDep { name, extra_filename, hash, host_hash, kind, is_private } = dep;
705707 let number = i + 1 ;
706708
707709 writeln ! (
708710 out,
709- "{number} {name}{extra_filename} hash {hash} host_hash {host_hash:?} kind {kind:?}"
711+ "{number} {name}{extra_filename} hash {hash} host_hash {host_hash:?} kind {kind:?} {privacy}" ,
712+ privacy = if is_private { "private" } else { "public" }
710713 ) ?;
711714 }
712715 write ! ( out, "\n " ) ?;
@@ -1624,7 +1627,7 @@ impl CrateMetadata {
16241627 dependencies,
16251628 dep_kind : Lock :: new ( dep_kind) ,
16261629 source : Lrc :: new ( source) ,
1627- private_dep,
1630+ private_dep : AtomicBool :: new ( private_dep ) ,
16281631 host_hash,
16291632 extern_crate : Lock :: new ( None ) ,
16301633 hygiene_context : Default :: default ( ) ,
@@ -1672,6 +1675,10 @@ impl CrateMetadata {
16721675 self . dep_kind . with_lock ( |dep_kind| * dep_kind = f ( * dep_kind) )
16731676 }
16741677
1678+ pub ( crate ) fn update_and_private_dep ( & self , private_dep : bool ) {
1679+ self . private_dep . fetch_and ( private_dep, Ordering :: SeqCst ) ;
1680+ }
1681+
16751682 pub ( crate ) fn required_panic_strategy ( & self ) -> Option < PanicStrategy > {
16761683 self . root . required_panic_strategy
16771684 }
0 commit comments