Skip to content

Commit 894fdf9

Browse files
committed
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 :)
1 parent bea81a3 commit 894fdf9

File tree

1 file changed

+5
-6
lines changed
  • src/librustdoc/html/render

1 file changed

+5
-6
lines changed

src/librustdoc/html/render/mod.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ use std::rc::Rc;
4444
use std::str;
4545
use std::string::ToString;
4646
use std::sync::mpsc::{channel, Receiver};
47-
use std::sync::Arc;
4847

4948
use itertools::Itertools;
5049
use rustc_ast_pretty::pprust;
@@ -111,7 +110,7 @@ crate struct Context<'tcx> {
111110
/// real location of an item. This is used to allow external links to
112111
/// publicly reused items to redirect to the right location.
113112
crate render_redirect_pages: bool,
114-
crate shared: Arc<SharedContext<'tcx>>,
113+
crate shared: Rc<SharedContext<'tcx>>,
115114
/// The [`Cache`] used during rendering.
116115
///
117116
/// Ideally the cache would be in [`SharedContext`], but it's mutated
@@ -517,16 +516,16 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
517516
current: Vec::new(),
518517
dst,
519518
render_redirect_pages: false,
520-
shared: Arc::new(scx),
519+
shared: Rc::new(scx),
521520
cache: Rc::new(cache),
522521
};
523522

524523
CURRENT_DEPTH.with(|s| s.set(0));
525524

526525
// Write shared runs within a flock; disable thread dispatching of IO temporarily.
527-
Arc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(true);
526+
Rc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(true);
528527
write_shared(&cx, &krate, index, &md_opts)?;
529-
Arc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(false);
528+
Rc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(false);
530529
Ok((cx, krate))
531530
}
532531

@@ -599,7 +598,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
599598
self.shared.fs.write(&settings_file, v.as_bytes())?;
600599

601600
// Flush pending errors.
602-
Arc::get_mut(&mut self.shared).unwrap().fs.close();
601+
Rc::get_mut(&mut self.shared).unwrap().fs.close();
603602
let nb_errors = self.shared.errors.iter().map(|err| diag.struct_err(&err).emit()).count();
604603
if nb_errors > 0 {
605604
Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))

0 commit comments

Comments
 (0)