1
Fork 0

rustc_metadata: specialize private_dep flag with fetch_and

This commit is contained in:
Michael Howell 2023-05-09 13:46:54 -07:00
parent bd90868b3f
commit 6a358960da
3 changed files with 7 additions and 19 deletions

View file

@ -570,7 +570,7 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
}
data.update_dep_kind(|data_dep_kind| cmp::max(data_dep_kind, dep_kind));
if let Some(private_dep) = private_dep {
data.update_private_dep(|p_d| p_d && private_dep);
data.update_and_private_dep(private_dep);
}
Ok(cnum)
}

View file

@ -1668,11 +1668,8 @@ impl CrateMetadata {
self.dep_kind.with_lock(|dep_kind| *dep_kind = f(*dep_kind))
}
/// `f` must not perform any I/O or take any locks. It may be called more than once.
pub(crate) fn update_private_dep(&self, mut f: impl FnMut(bool) -> bool) {
self.private_dep
.fetch_update(Ordering::Release, Ordering::Acquire, |private_dep| Some(f(private_dep)))
.expect("fetch_update only returns Err if `f` returns None`, which it doesn't");
pub(crate) fn update_and_private_dep(&self, private_dep: bool) {
self.private_dep.fetch_and(private_dep, Ordering::SeqCst);
}
pub(crate) fn required_panic_strategy(&self) -> Option<PanicStrategy> {