@@ -38,6 +38,7 @@ use proc_macro::bridge::client::ProcMacro;
38
38
use std:: iter:: TrustedLen ;
39
39
use std:: num:: NonZeroUsize ;
40
40
use std:: path:: Path ;
41
+ use std:: sync:: atomic:: { AtomicBool , Ordering } ;
41
42
use std:: { io, iter, mem} ;
42
43
43
44
pub ( super ) use cstore_impl:: provide;
@@ -112,7 +113,7 @@ pub(crate) struct CrateMetadata {
112
113
/// Whether or not this crate should be consider a private dependency.
113
114
/// Used by the 'exported_private_dependencies' lint, and for determining
114
115
/// whether to emit suggestions that reference this crate.
115
- private_dep : Lock < bool > ,
116
+ private_dep : AtomicBool ,
116
117
/// The hash for the host proc macro. Used to support `-Z dual-proc-macro`.
117
118
host_hash : Option < Svh > ,
118
119
@@ -1612,7 +1613,7 @@ impl CrateMetadata {
1612
1613
dependencies,
1613
1614
dep_kind : Lock :: new ( dep_kind) ,
1614
1615
source : Lrc :: new ( source) ,
1615
- private_dep : Lock :: new ( private_dep) ,
1616
+ private_dep : AtomicBool :: new ( private_dep) ,
1616
1617
host_hash,
1617
1618
extern_crate : Lock :: new ( None ) ,
1618
1619
hygiene_context : Default :: default ( ) ,
@@ -1660,8 +1661,11 @@ impl CrateMetadata {
1660
1661
self . dep_kind . with_lock ( |dep_kind| * dep_kind = f ( * dep_kind) )
1661
1662
}
1662
1663
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" ) ;
1665
1669
}
1666
1670
1667
1671
pub ( crate ) fn required_panic_strategy ( & self ) -> Option < PanicStrategy > {
0 commit comments