1
Fork 0

shuffle ownership of external_traits

constraints:

- clean/inline.rs needs this map to fill in traits when inlining
- fold.rs needs this map to allow passes to fold trait items
- html/render.rs needs this map to seed the Cache.traits map of all
  known traits

The first two are the real problem, since `DocFolder` only operates on
`clean::Crate` but `clean/inline.rs` only sees the `DocContext`. The
introduction of early passes means that these two now exist at the same
time, so they need to share ownership of the map. Even better, the use
of `Crate` in a rustc thread pool means that it needs to be Sync, so it
can't use `Lrc<Lock>` to manually activate thread-safety.

`parking_lot` is reused from elsewhere in the tree to allow use of its
`ReentrantMutex`, as the relevant parts of rustdoc are still
single-threaded and this allows for easier use in that context.
This commit is contained in:
QuietMisdreavus 2018-09-01 21:20:39 -05:00
parent c754e8240c
commit 354507e61f
9 changed files with 31 additions and 24 deletions

View file

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