@@ -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:: { AtomicBool , Ordering } ;
4344use std:: { io, iter, mem} ;
4445
4546pub ( super ) use cstore_impl:: provide;
@@ -114,7 +115,7 @@ pub(crate) struct CrateMetadata {
114115 /// Whether or not this crate should be consider a private dependency.
115116 /// Used by the 'exported_private_dependencies' lint, and for determining
116117 /// whether to emit suggestions that reference this crate.
117- private_dep : Lock < bool > ,
118+ private_dep : AtomicBool ,
118119 /// The hash for the host proc macro. Used to support `-Z dual-proc-macro`.
119120 host_hash : Option < Svh > ,
120121
@@ -1619,7 +1620,7 @@ impl CrateMetadata {
16191620 dependencies,
16201621 dep_kind : Lock :: new ( dep_kind) ,
16211622 source : Lrc :: new ( source) ,
1622- private_dep : Lock :: new ( private_dep) ,
1623+ private_dep : AtomicBool :: new ( private_dep) ,
16231624 host_hash,
16241625 extern_crate : Lock :: new ( None ) ,
16251626 hygiene_context : Default :: default ( ) ,
@@ -1667,8 +1668,11 @@ impl CrateMetadata {
16671668 self . dep_kind . with_lock ( |dep_kind| * dep_kind = f ( * dep_kind) )
16681669 }
16691670
1670- pub ( crate ) fn update_private_dep ( & self , f : impl FnOnce ( bool ) -> bool ) {
1671- self . private_dep . with_lock ( |private_dep| * private_dep = f ( * private_dep) )
1671+ /// `f` must not perform any I/O or take any locks. It may be called more than once.
1672+ pub ( crate ) fn update_private_dep ( & self , mut f : impl FnMut ( bool ) -> bool ) {
1673+ self . private_dep
1674+ . fetch_update ( Ordering :: Release , Ordering :: Acquire , |private_dep| Some ( f ( private_dep) ) )
1675+ . expect ( "fetch_update only returns Err if `f` returns None`, which it doesn't" ) ;
16721676 }
16731677
16741678 pub ( crate ) fn required_panic_strategy ( & self ) -> Option < PanicStrategy > {
0 commit comments