about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamelid <camelidcamel@gmail.com>2021-02-21 14:25:21 -0800
committerCamelid <camelidcamel@gmail.com>2021-03-05 18:08:01 -0800
commitc4bb66c2842cdd433ad6dbe1168726ff1ca148d3 (patch)
treed11934421449ce94ca10d9e0f143729a359a3f90
parent9763eb87a3a389b90c6540f56194d2f7f78d62be (diff)
downloadrust-c4bb66c2842cdd433ad6dbe1168726ff1ca148d3.tar.gz
rust-c4bb66c2842cdd433ad6dbe1168726ff1ca148d3.zip
rustdoc: Replace `Arc` around `SharedContext` with `Rc`
It doesn't look like it's shared across threads, so it doesn't need to
be thread-safe. Of course, since we're using Rust, we'll get an error if
we try to share it across threads, so this should be safe :)
-rw-r--r--src/librustdoc/html/render/context.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs
index 990a05679f1..064c9759b58 100644
--- a/src/librustdoc/html/render/context.rs
+++ b/src/librustdoc/html/render/context.rs
@@ -4,7 +4,6 @@ use std::io;
 use std::path::PathBuf;
 use std::rc::Rc;
 use std::sync::mpsc::channel;
-use std::sync::Arc;
 
 use rustc_data_structures::fx::FxHashMap;
 use rustc_hir::def_id::LOCAL_CRATE;
@@ -53,7 +52,7 @@ crate struct Context<'tcx> {
     /// real location of an item. This is used to allow external links to
     /// publicly reused items to redirect to the right location.
     crate render_redirect_pages: bool,
-    crate shared: Arc<SharedContext<'tcx>>,
+    crate shared: Rc<SharedContext<'tcx>>,
     /// The [`Cache`] used during rendering.
     ///
     /// Ideally the cache would be in [`SharedContext`], but it's mutated
@@ -410,16 +409,16 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
             current: Vec::new(),
             dst,
             render_redirect_pages: false,
-            shared: Arc::new(scx),
+            shared: Rc::new(scx),
             cache: Rc::new(cache),
         };
 
         CURRENT_DEPTH.with(|s| s.set(0));
 
         // Write shared runs within a flock; disable thread dispatching of IO temporarily.
-        Arc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(true);
+        Rc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(true);
         write_shared(&cx, &krate, index, &md_opts)?;
-        Arc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(false);
+        Rc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(false);
         Ok((cx, krate))
     }
 
@@ -501,7 +500,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
         }
 
         // Flush pending errors.
-        Arc::get_mut(&mut self.shared).unwrap().fs.close();
+        Rc::get_mut(&mut self.shared).unwrap().fs.close();
         let nb_errors = self.shared.errors.iter().map(|err| diag.struct_err(&err).emit()).count();
         if nb_errors > 0 {
             Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))