about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-08-10 15:20:21 -0400
committerMark Rousskov <mark.simulacrum@gmail.com>2019-08-11 10:36:46 -0400
commitc57481001ea81665b1ca23368b710a0435d28653 (patch)
tree119381b099f7b5c229a26f2eae616044e805b610
parent8f80a8d7d564b17fe3831c4b5e5404d93a013bf5 (diff)
downloadrust-c57481001ea81665b1ca23368b710a0435d28653.tar.gz
rust-c57481001ea81665b1ca23368b710a0435d28653.zip
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).
-rw-r--r--Cargo.lock1
-rw-r--r--src/librustdoc/Cargo.toml1
-rw-r--r--src/librustdoc/clean/inline.rs6
-rw-r--r--src/librustdoc/clean/mod.rs4
-rw-r--r--src/librustdoc/core.rs3
-rw-r--r--src/librustdoc/fold.rs8
-rw-r--r--src/librustdoc/html/render.rs2
7 files changed, 9 insertions, 16 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 52cfa2cb1f8..ab6731e4d43 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3252,7 +3252,6 @@ name = "rustdoc"
 version = "0.0.0"
 dependencies = [
  "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)",
  "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)",
diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml
index 334dc74c6c8..0eb8b73016d 100644
--- a/src/librustdoc/Cargo.toml
+++ b/src/librustdoc/Cargo.toml
@@ -13,4 +13,3 @@ pulldown-cmark = { version = "0.5.3", default-features = false }
 minifier = "0.0.33"
 rayon = { version = "0.2.0", package = "rustc-rayon" }
 tempfile = "3"
-parking_lot = "0.7"
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index 884cdef3c77..a8336607f7a 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -574,8 +574,7 @@ pub fn record_extern_trait(cx: &DocContext<'_>, did: DefId) {
     }
 
     {
-        let external_traits = cx.external_traits.lock();
-        if external_traits.borrow().contains_key(&did) ||
+        if cx.external_traits.borrow().contains_key(&did) ||
             cx.active_extern_traits.borrow().contains(&did)
         {
             return;
@@ -588,8 +587,7 @@ pub fn record_extern_trait(cx: &DocContext<'_>, did: DefId) {
     let trait_ = build_external_trait(cx, did);
 
     {
-        let external_traits = cx.external_traits.lock();
-        external_traits.borrow_mut().insert(did, trait_);
+        cx.external_traits.borrow_mut().insert(did, trait_);
     }
     cx.active_extern_traits.borrow_mut().remove_item(&did);
 }
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 0c38e68a764..ee76bf35cab 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -45,8 +45,6 @@ use std::cell::RefCell;
 use std::sync::Arc;
 use std::u32;
 
-use parking_lot::ReentrantMutex;
-
 use crate::core::{self, DocContext};
 use crate::doctree;
 use crate::html::render::{cache, ExternalLocation};
@@ -133,7 +131,7 @@ pub struct Crate {
     pub primitives: Vec<(DefId, PrimitiveType, Attributes)>,
     // These are later on moved into `CACHEKEY`, leaving the map empty.
     // 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>,
 }
 
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index 869bec6cb88..6b524e1206f 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -22,7 +22,6 @@ use syntax::json::JsonEmitter;
 use syntax::symbol::sym;
 use errors;
 use errors::emitter::{Emitter, EmitterWriter};
-use parking_lot::ReentrantMutex;
 
 use std::cell::RefCell;
 use std::mem;
@@ -50,7 +49,7 @@ pub struct DocContext<'tcx> {
     /// Later on moved into `html::render::CACHE_KEY`
     pub renderinfo: RefCell<RenderInfo>,
     /// 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
     /// the same time.
     pub active_extern_traits: RefCell<Vec<DefId>>,
diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs
index cfa22bc27b7..5482239c7ce 100644
--- a/src/librustdoc/fold.rs
+++ b/src/librustdoc/fold.rs
@@ -105,12 +105,12 @@ pub trait DocFolder : Sized {
         c.module = c.module.take().and_then(|module| self.fold_item(module));
 
         {
-            let guard = c.external_traits.lock();
-            let traits = guard.replace(Default::default());
-            guard.borrow_mut().extend(traits.into_iter().map(|(k, mut v)| {
+            let mut guard = c.external_traits.borrow_mut();
+            let external_traits = std::mem::replace(&mut *guard, Default::default());
+            *guard = external_traits.into_iter().map(|(k, mut v)| {
                 v.items = v.items.into_iter().filter_map(|i| self.fold_item(i)).collect();
                 (k, v)
-            }));
+            }).collect();
         }
         c
     }
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index b1cee018205..211f1e325b9 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -659,7 +659,7 @@ pub fn run(mut krate: clean::Crate,
         crate_version: krate.version.take(),
         orphan_impl_items: 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_mut_trait_did,
         owned_box_did,