@@ -38,6 +38,7 @@ use proc_macro::bridge::client::ProcMacro;
3838use std:: iter:: TrustedLen ;
3939use std:: num:: NonZeroUsize ;
4040use std:: path:: Path ;
41+ use std:: sync:: atomic:: { AtomicBool , Ordering } ;
4142use std:: { io, iter, mem} ;
4243
4344pub ( super ) use cstore_impl:: provide;
@@ -112,7 +113,7 @@ pub(crate) struct CrateMetadata {
112113 /// Whether or not this crate should be consider a private dependency.
113114 /// Used by the 'exported_private_dependencies' lint, and for determining
114115 /// whether to emit suggestions that reference this crate.
115- private_dep : Lock < bool > ,
116+ private_dep : AtomicBool ,
116117 /// The hash for the host proc macro. Used to support `-Z dual-proc-macro`.
117118 host_hash : Option < Svh > ,
118119
@@ -1612,7 +1613,7 @@ impl CrateMetadata {
16121613 dependencies,
16131614 dep_kind : Lock :: new ( dep_kind) ,
16141615 source : Lrc :: new ( source) ,
1615- private_dep : Lock :: new ( private_dep) ,
1616+ private_dep : AtomicBool :: new ( private_dep) ,
16161617 host_hash,
16171618 extern_crate : Lock :: new ( None ) ,
16181619 hygiene_context : Default :: default ( ) ,
@@ -1660,8 +1661,11 @@ impl CrateMetadata {
16601661 self . dep_kind . with_lock ( |dep_kind| * dep_kind = f ( * dep_kind) )
16611662 }
16621663
1663- pub ( crate ) fn update_private_dep ( & self , f : impl FnOnce ( bool ) -> bool ) {
1664- self . private_dep . with_lock ( |private_dep| * private_dep = f ( * private_dep) )
1664+ /// `f` must not perform any I/O or take any locks. It may be called more than once.
1665+ pub ( crate ) fn update_private_dep ( & self , mut f : impl FnMut ( bool ) -> bool ) {
1666+ self . private_dep
1667+ . fetch_update ( Ordering :: Release , Ordering :: Acquire , |private_dep| Some ( f ( private_dep) ) )
1668+ . expect ( "fetch_update only returns Err if `f` returns None`, which it doesn't" ) ;
16651669 }
16661670
16671671 pub ( crate ) fn required_panic_strategy ( & self ) -> Option < PanicStrategy > {
0 commit comments