From c57481001ea81665b1ca23368b710a0435d28653 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 10 Aug 2019 15:20:21 -0400 Subject: [PATCH] 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). --- Cargo.lock | 1 - src/librustdoc/Cargo.toml | 1 - src/librustdoc/clean/inline.rs | 6 ++---- src/librustdoc/clean/mod.rs | 4 +--- src/librustdoc/core.rs | 3 +-- src/librustdoc/fold.rs | 8 ++++---- src/librustdoc/html/render.rs | 2 +- 7 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52cfa2cb1f80..ab6731e4d433 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 334dc74c6c8f..0eb8b73016d1 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 884cdef3c771..a8336607f7ae 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 0c38e68a764f..ee76bf35cab9 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>>>, + pub external_traits: Arc>>, pub masked_crates: FxHashSet, } diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 869bec6cb88a..6b524e1206f3 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, /// Later on moved through `clean::Crate` into `html::render::CACHE_KEY` - pub external_traits: Arc>>>, + pub external_traits: Arc>>, /// Used while populating `external_traits` to ensure we don't process the same trait twice at /// the same time. pub active_extern_traits: RefCell>, diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index cfa22bc27b75..5482239c7ce2 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 b1cee0182052..211f1e325b9e 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,