about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamelid <camelidcamel@gmail.com>2021-02-21 14:35:15 -0800
committerCamelid <camelidcamel@gmail.com>2021-03-05 19:39:08 -0800
commitb3d2a371bb8c0bccbc07d3a29c79218495549509 (patch)
treefe23864976580028c9f9b09a8494745ec5eeb53b
parentc4bb66c2842cdd433ad6dbe1168726ff1ca148d3 (diff)
downloadrust-b3d2a371bb8c0bccbc07d3a29c79218495549509.tar.gz
rust-b3d2a371bb8c0bccbc07d3a29c79218495549509.zip
rustdoc: Make a bunch of fields private
Also create issue for removing shared mutable state.
-rw-r--r--src/librustdoc/html/render/context.rs15
-rw-r--r--src/librustdoc/html/render/mod.rs15
2 files changed, 18 insertions, 12 deletions
diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs
index 064c9759b58..e8d323b9af1 100644
--- a/src/librustdoc/html/render/context.rs
+++ b/src/librustdoc/html/render/context.rs
@@ -44,15 +44,20 @@ use crate::html::{layout, sources};
 crate struct Context<'tcx> {
     /// Current hierarchy of components leading down to what's currently being
     /// rendered
-    crate current: Vec<String>,
+    pub(super) current: Vec<String>,
     /// The current destination folder of where HTML artifacts should be placed.
     /// This changes as the context descends into the module hierarchy.
-    crate dst: PathBuf,
+    pub(super) dst: PathBuf,
     /// A flag, which when `true`, will render pages which redirect to the
     /// 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: Rc<SharedContext<'tcx>>,
+    pub(super) render_redirect_pages: bool,
+    /// Shared mutable state.
+    ///
+    /// Issue for improving the situation: [#82381][]
+    ///
+    /// [#82381]: https://github.com/rust-lang/rust/issues/82381
+    pub(super) shared: Rc<SharedContext<'tcx>>,
     /// The [`Cache`] used during rendering.
     ///
     /// Ideally the cache would be in [`SharedContext`], but it's mutated
@@ -62,7 +67,7 @@ crate struct Context<'tcx> {
     /// It's immutable once in `Context`, so it's not as bad that it's not in
     /// `SharedContext`.
     // FIXME: move `cache` to `SharedContext`
-    crate cache: Rc<Cache>,
+    pub(super) cache: Rc<Cache>,
 }
 
 impl<'tcx> Context<'tcx> {
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index 3bb13d29992..c074b789e74 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -81,6 +81,7 @@ crate fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ {
     })
 }
 
+/// Shared mutable state used in [`Context`] and elsewhere.
 crate struct SharedContext<'tcx> {
     crate tcx: TyCtxt<'tcx>,
     /// The path to the crate root source minus the file name.
@@ -96,16 +97,16 @@ crate struct SharedContext<'tcx> {
     /// The local file sources we've emitted and their respective url-paths.
     crate local_sources: FxHashMap<PathBuf, String>,
     /// Whether the collapsed pass ran
-    crate collapsed: bool,
+    collapsed: bool,
     /// The base-URL of the issue tracker for when an item has been tagged with
     /// an issue number.
-    crate issue_tracker_base_url: Option<String>,
+    issue_tracker_base_url: Option<String>,
     /// The directories that have already been created in this doc run. Used to reduce the number
     /// of spurious `create_dir_all` calls.
-    crate created_dirs: RefCell<FxHashSet<PathBuf>>,
+    created_dirs: RefCell<FxHashSet<PathBuf>>,
     /// This flag indicates whether listings of modules (in the side bar and documentation itself)
     /// should be ordered alphabetically or in order of appearance (in the source code).
-    crate sort_modules_alphabetically: bool,
+    sort_modules_alphabetically: bool,
     /// Additional CSS files to be added to the generated docs.
     crate style_files: Vec<StylePath>,
     /// Suffix to be added on resource files (if suffix is "-v2" then "light.css" becomes
@@ -118,7 +119,7 @@ crate struct SharedContext<'tcx> {
     crate fs: DocFS,
     /// The default edition used to parse doctests.
     crate edition: Edition,
-    crate codes: ErrorCodes,
+    codes: ErrorCodes,
     playground: Option<markdown::Playground>,
     /// The map used to ensure all generated 'id=' attributes are unique.
     id_map: RefCell<IdMap>,
@@ -128,11 +129,11 @@ crate struct SharedContext<'tcx> {
     all: RefCell<AllTypes>,
     /// Storage for the errors produced while generating documentation so they
     /// can be printed together at the end.
-    crate errors: Receiver<String>,
+    errors: Receiver<String>,
     /// `None` by default, depends on the `generate-redirect-map` option flag. If this field is set
     /// to `Some(...)`, it'll store redirections and then generate a JSON file at the top level of
     /// the crate.
-    crate redirections: Option<RefCell<FxHashMap<String, String>>>,
+    redirections: Option<RefCell<FxHashMap<String, String>>>,
 }
 
 impl SharedContext<'_> {