Skip to content

Commit c4bb66c

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 9763eb8 commit c4bb66c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/librustdoc/html/render/context.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::io;
44
use std::path::PathBuf;
55
use std::rc::Rc;
66
use std::sync::mpsc::channel;
7-
use std::sync::Arc;
87

98
use rustc_data_structures::fx::FxHashMap;
109
use rustc_hir::def_id::LOCAL_CRATE;
@@ -53,7 +52,7 @@ crate struct Context<'tcx> {
5352
/// real location of an item. This is used to allow external links to
5453
/// publicly reused items to redirect to the right location.
5554
crate render_redirect_pages: bool,
56-
crate shared: Arc<SharedContext<'tcx>>,
55+
crate shared: Rc<SharedContext<'tcx>>,
5756
/// The [`Cache`] used during rendering.
5857
///
5958
/// Ideally the cache would be in [`SharedContext`], but it's mutated
@@ -410,16 +409,16 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
410409
current: Vec::new(),
411410
dst,
412411
render_redirect_pages: false,
413-
shared: Arc::new(scx),
412+
shared: Rc::new(scx),
414413
cache: Rc::new(cache),
415414
};
416415

417416
CURRENT_DEPTH.with(|s| s.set(0));
418417

419418
// Write shared runs within a flock; disable thread dispatching of IO temporarily.
420-
Arc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(true);
419+
Rc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(true);
421420
write_shared(&cx, &krate, index, &md_opts)?;
422-
Arc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(false);
421+
Rc::get_mut(&mut cx.shared).unwrap().fs.set_sync_only(false);
423422
Ok((cx, krate))
424423
}
425424

@@ -501,7 +500,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
501500
}
502501

503502
// Flush pending errors.
504-
Arc::get_mut(&mut self.shared).unwrap().fs.close();
503+
Rc::get_mut(&mut self.shared).unwrap().fs.close();
505504
let nb_errors = self.shared.errors.iter().map(|err| diag.struct_err(&err).emit()).count();
506505
if nb_errors > 0 {
507506
Err(Error::new(io::Error::new(io::ErrorKind::Other, "I/O error"), ""))

0 commit comments

Comments
 (0)