Remove ReentrantMutex

This drops the parking_lot dependency; the ReentrantMutex type appeared
to be unused (at least, no compilation failures occurred).

This is technically a possible change in behavior of its users, as
lock() would wait on other threads releasing their guards, but since we
didn't actually remove any threading or such in this code, it appears
that we never used that behavior (the behavior change is only noticeable
if the type previously was used in two threads, in a single thread
ReentrantMutex is useless).
This commit is contained in:
Mark Rousskov 2019-08-10 15:20:21 -04:00
parent 8f80a8d7d5
commit c57481001e
7 changed files with 9 additions and 16 deletions

View File

@ -3252,7 +3252,6 @@ name = "rustdoc"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"minifier 0.0.33 (registry+https://github.com/rust-lang/crates.io-index)", "minifier 0.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pulldown-cmark 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -13,4 +13,3 @@ pulldown-cmark = { version = "0.5.3", default-features = false }
minifier = "0.0.33" minifier = "0.0.33"
rayon = { version = "0.2.0", package = "rustc-rayon" } rayon = { version = "0.2.0", package = "rustc-rayon" }
tempfile = "3" tempfile = "3"
parking_lot = "0.7"

View File

@ -574,8 +574,7 @@ pub fn record_extern_trait(cx: &DocContext<'_>, did: DefId) {
} }
{ {
let external_traits = cx.external_traits.lock(); if cx.external_traits.borrow().contains_key(&did) ||
if external_traits.borrow().contains_key(&did) ||
cx.active_extern_traits.borrow().contains(&did) cx.active_extern_traits.borrow().contains(&did)
{ {
return; return;
@ -588,8 +587,7 @@ pub fn record_extern_trait(cx: &DocContext<'_>, did: DefId) {
let trait_ = build_external_trait(cx, did); let trait_ = build_external_trait(cx, did);
{ {
let external_traits = cx.external_traits.lock(); cx.external_traits.borrow_mut().insert(did, trait_);
external_traits.borrow_mut().insert(did, trait_);
} }
cx.active_extern_traits.borrow_mut().remove_item(&did); cx.active_extern_traits.borrow_mut().remove_item(&did);
} }

View File

@ -45,8 +45,6 @@ use std::cell::RefCell;
use std::sync::Arc; use std::sync::Arc;
use std::u32; use std::u32;
use parking_lot::ReentrantMutex;
use crate::core::{self, DocContext}; use crate::core::{self, DocContext};
use crate::doctree; use crate::doctree;
use crate::html::render::{cache, ExternalLocation}; use crate::html::render::{cache, ExternalLocation};
@ -133,7 +131,7 @@ pub struct Crate {
pub primitives: Vec<(DefId, PrimitiveType, Attributes)>, pub primitives: Vec<(DefId, PrimitiveType, Attributes)>,
// These are later on moved into `CACHEKEY`, leaving the map empty. // These are later on moved into `CACHEKEY`, leaving the map empty.
// Only here so that they can be filtered through the rustdoc passes. // Only here so that they can be filtered through the rustdoc passes.
pub external_traits: Arc<ReentrantMutex<RefCell<FxHashMap<DefId, Trait>>>>, pub external_traits: Arc<RefCell<FxHashMap<DefId, Trait>>>,
pub masked_crates: FxHashSet<CrateNum>, pub masked_crates: FxHashSet<CrateNum>,
} }

View File

@ -22,7 +22,6 @@ use syntax::json::JsonEmitter;
use syntax::symbol::sym; use syntax::symbol::sym;
use errors; use errors;
use errors::emitter::{Emitter, EmitterWriter}; use errors::emitter::{Emitter, EmitterWriter};
use parking_lot::ReentrantMutex;
use std::cell::RefCell; use std::cell::RefCell;
use std::mem; use std::mem;
@ -50,7 +49,7 @@ pub struct DocContext<'tcx> {
/// Later on moved into `html::render::CACHE_KEY` /// Later on moved into `html::render::CACHE_KEY`
pub renderinfo: RefCell<RenderInfo>, pub renderinfo: RefCell<RenderInfo>,
/// Later on moved through `clean::Crate` into `html::render::CACHE_KEY` /// Later on moved through `clean::Crate` into `html::render::CACHE_KEY`
pub external_traits: Arc<ReentrantMutex<RefCell<FxHashMap<DefId, clean::Trait>>>>, pub external_traits: Arc<RefCell<FxHashMap<DefId, clean::Trait>>>,
/// Used while populating `external_traits` to ensure we don't process the same trait twice at /// Used while populating `external_traits` to ensure we don't process the same trait twice at
/// the same time. /// the same time.
pub active_extern_traits: RefCell<Vec<DefId>>, pub active_extern_traits: RefCell<Vec<DefId>>,

View File

@ -105,12 +105,12 @@ pub trait DocFolder : Sized {
c.module = c.module.take().and_then(|module| self.fold_item(module)); c.module = c.module.take().and_then(|module| self.fold_item(module));
{ {
let guard = c.external_traits.lock(); let mut guard = c.external_traits.borrow_mut();
let traits = guard.replace(Default::default()); let external_traits = std::mem::replace(&mut *guard, Default::default());
guard.borrow_mut().extend(traits.into_iter().map(|(k, mut v)| { *guard = external_traits.into_iter().map(|(k, mut v)| {
v.items = v.items.into_iter().filter_map(|i| self.fold_item(i)).collect(); v.items = v.items.into_iter().filter_map(|i| self.fold_item(i)).collect();
(k, v) (k, v)
})); }).collect();
} }
c c
} }

View File

@ -659,7 +659,7 @@ pub fn run(mut krate: clean::Crate,
crate_version: krate.version.take(), crate_version: krate.version.take(),
orphan_impl_items: Vec::new(), orphan_impl_items: Vec::new(),
orphan_trait_impls: Vec::new(), orphan_trait_impls: Vec::new(),
traits: krate.external_traits.lock().replace(Default::default()), traits: krate.external_traits.replace(Default::default()),
deref_trait_did, deref_trait_did,
deref_mut_trait_did, deref_mut_trait_did,
owned_box_did, owned_box_did,