Skip to content

Commit c574810

Browse files
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).
1 parent 8f80a8d commit c574810

File tree

7 files changed

+9
-16
lines changed

7 files changed

+9
-16
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -3252,7 +3252,6 @@ name = "rustdoc"
32523252
version = "0.0.0"
32533253
dependencies = [
32543254
"minifier 0.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
3255-
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
32563255
"pulldown-cmark 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
32573256
"rustc-rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
32583257
"tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)",

src/librustdoc/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ pulldown-cmark = { version = "0.5.3", default-features = false }
1313
minifier = "0.0.33"
1414
rayon = { version = "0.2.0", package = "rustc-rayon" }
1515
tempfile = "3"
16-
parking_lot = "0.7"

src/librustdoc/clean/inline.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,7 @@ pub fn record_extern_trait(cx: &DocContext<'_>, did: DefId) {
574574
}
575575

576576
{
577-
let external_traits = cx.external_traits.lock();
578-
if external_traits.borrow().contains_key(&did) ||
577+
if cx.external_traits.borrow().contains_key(&did) ||
579578
cx.active_extern_traits.borrow().contains(&did)
580579
{
581580
return;
@@ -588,8 +587,7 @@ pub fn record_extern_trait(cx: &DocContext<'_>, did: DefId) {
588587
let trait_ = build_external_trait(cx, did);
589588

590589
{
591-
let external_traits = cx.external_traits.lock();
592-
external_traits.borrow_mut().insert(did, trait_);
590+
cx.external_traits.borrow_mut().insert(did, trait_);
593591
}
594592
cx.active_extern_traits.borrow_mut().remove_item(&did);
595593
}

src/librustdoc/clean/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ use std::cell::RefCell;
4545
use std::sync::Arc;
4646
use std::u32;
4747

48-
use parking_lot::ReentrantMutex;
49-
5048
use crate::core::{self, DocContext};
5149
use crate::doctree;
5250
use crate::html::render::{cache, ExternalLocation};
@@ -133,7 +131,7 @@ pub struct Crate {
133131
pub primitives: Vec<(DefId, PrimitiveType, Attributes)>,
134132
// These are later on moved into `CACHEKEY`, leaving the map empty.
135133
// Only here so that they can be filtered through the rustdoc passes.
136-
pub external_traits: Arc<ReentrantMutex<RefCell<FxHashMap<DefId, Trait>>>>,
134+
pub external_traits: Arc<RefCell<FxHashMap<DefId, Trait>>>,
137135
pub masked_crates: FxHashSet<CrateNum>,
138136
}
139137

src/librustdoc/core.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use syntax::json::JsonEmitter;
2222
use syntax::symbol::sym;
2323
use errors;
2424
use errors::emitter::{Emitter, EmitterWriter};
25-
use parking_lot::ReentrantMutex;
2625

2726
use std::cell::RefCell;
2827
use std::mem;
@@ -50,7 +49,7 @@ pub struct DocContext<'tcx> {
5049
/// Later on moved into `html::render::CACHE_KEY`
5150
pub renderinfo: RefCell<RenderInfo>,
5251
/// Later on moved through `clean::Crate` into `html::render::CACHE_KEY`
53-
pub external_traits: Arc<ReentrantMutex<RefCell<FxHashMap<DefId, clean::Trait>>>>,
52+
pub external_traits: Arc<RefCell<FxHashMap<DefId, clean::Trait>>>,
5453
/// Used while populating `external_traits` to ensure we don't process the same trait twice at
5554
/// the same time.
5655
pub active_extern_traits: RefCell<Vec<DefId>>,

src/librustdoc/fold.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ pub trait DocFolder : Sized {
105105
c.module = c.module.take().and_then(|module| self.fold_item(module));
106106

107107
{
108-
let guard = c.external_traits.lock();
109-
let traits = guard.replace(Default::default());
110-
guard.borrow_mut().extend(traits.into_iter().map(|(k, mut v)| {
108+
let mut guard = c.external_traits.borrow_mut();
109+
let external_traits = std::mem::replace(&mut *guard, Default::default());
110+
*guard = external_traits.into_iter().map(|(k, mut v)| {
111111
v.items = v.items.into_iter().filter_map(|i| self.fold_item(i)).collect();
112112
(k, v)
113-
}));
113+
}).collect();
114114
}
115115
c
116116
}

src/librustdoc/html/render.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ pub fn run(mut krate: clean::Crate,
659659
crate_version: krate.version.take(),
660660
orphan_impl_items: Vec::new(),
661661
orphan_trait_impls: Vec::new(),
662-
traits: krate.external_traits.lock().replace(Default::default()),
662+
traits: krate.external_traits.replace(Default::default()),
663663
deref_trait_did,
664664
deref_mut_trait_did,
665665
owned_box_did,

0 commit comments

Comments
 (0)