@@ -40,6 +40,7 @@ use proc_macro::bridge::client::ProcMacro;
40
40
use std:: iter:: TrustedLen ;
41
41
use std:: num:: NonZeroUsize ;
42
42
use std:: path:: Path ;
43
+ use std:: sync:: atomic:: { AtomicBool , Ordering } ;
43
44
use std:: { io, iter, mem} ;
44
45
45
46
pub ( super ) use cstore_impl:: provide;
@@ -114,7 +115,7 @@ pub(crate) struct CrateMetadata {
114
115
/// Whether or not this crate should be consider a private dependency.
115
116
/// Used by the 'exported_private_dependencies' lint, and for determining
116
117
/// whether to emit suggestions that reference this crate.
117
- private_dep : Lock < bool > ,
118
+ private_dep : AtomicBool ,
118
119
/// The hash for the host proc macro. Used to support `-Z dual-proc-macro`.
119
120
host_hash : Option < Svh > ,
120
121
@@ -1619,7 +1620,7 @@ impl CrateMetadata {
1619
1620
dependencies,
1620
1621
dep_kind : Lock :: new ( dep_kind) ,
1621
1622
source : Lrc :: new ( source) ,
1622
- private_dep : Lock :: new ( private_dep) ,
1623
+ private_dep : AtomicBool :: new ( private_dep) ,
1623
1624
host_hash,
1624
1625
extern_crate : Lock :: new ( None ) ,
1625
1626
hygiene_context : Default :: default ( ) ,
@@ -1667,8 +1668,11 @@ impl CrateMetadata {
1667
1668
self . dep_kind . with_lock ( |dep_kind| * dep_kind = f ( * dep_kind) )
1668
1669
}
1669
1670
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" ) ;
1672
1676
}
1673
1677
1674
1678
pub ( crate ) fn required_panic_strategy ( & self ) -> Option < PanicStrategy > {
0 commit comments