Skip to content

Commit 22dc5c4

Browse files
committed
rustdoc: Remove {Crate,SharedContext}.collapsed
They're unneeded now that `doc_value()` and `collapsed_doc_value()` are the same.
1 parent da26b51 commit 22dc5c4

File tree

5 files changed

+4
-23
lines changed

5 files changed

+4
-23
lines changed

src/librustdoc/clean/types.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,11 @@ crate struct Crate {
121121
crate primitives: ThinVec<(DefId, PrimitiveType)>,
122122
/// Only here so that they can be filtered through the rustdoc passes.
123123
crate external_traits: Rc<RefCell<FxHashMap<DefId, TraitWithExtraInfo>>>,
124-
crate collapsed: bool,
125124
}
126125

127126
// `Crate` is frequently moved by-value. Make sure it doesn't unintentionally get bigger.
128127
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
129-
rustc_data_structures::static_assert_size!(Crate, 104);
128+
rustc_data_structures::static_assert_size!(Crate, 96);
130129

131130
impl Crate {
132131
crate fn name(&self, tcx: TyCtxt<'_>) -> Symbol {

src/librustdoc/clean/utils.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,7 @@ crate fn krate(cx: &mut DocContext<'_>) -> Crate {
7676
}));
7777
}
7878

79-
Crate {
80-
module,
81-
externs,
82-
primitives,
83-
external_traits: cx.external_traits.clone(),
84-
collapsed: false,
85-
}
79+
Crate { module, externs, primitives, external_traits: cx.external_traits.clone() }
8680
}
8781

8882
fn external_generic_args(

src/librustdoc/core.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,6 @@ crate fn run_global_ctxt(
512512
let mut cache = ctxt.cache;
513513
krate = tcx.sess.time("create_format_cache", || cache.populate(krate, tcx, &render_options));
514514

515-
// The main crate doc comments are always collapsed.
516-
krate.collapsed = true;
517-
518515
(krate, render_options, cache)
519516
}
520517

src/librustdoc/html/render/context.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ crate struct SharedContext<'tcx> {
8888
crate local_sources: FxHashMap<PathBuf, String>,
8989
/// Show the memory layout of types in the docs.
9090
pub(super) show_type_layout: bool,
91-
/// Whether the collapsed pass ran
92-
collapsed: bool,
9391
/// The base-URL of the issue tracker for when an item has been tagged with
9492
/// an issue number.
9593
pub(super) issue_tracker_base_url: Option<String>,
@@ -142,12 +140,6 @@ impl SharedContext<'_> {
142140
Ok(())
143141
}
144142

145-
/// Returns the `collapsed_doc_value` of the given item if this is the main crate, otherwise
146-
/// returns the `doc_value`.
147-
crate fn maybe_collapsed_doc_value<'a>(&self, item: &'a clean::Item) -> Option<String> {
148-
if self.collapsed { item.doc_value() } else { item.doc_value() }
149-
}
150-
151143
crate fn edition(&self) -> Edition {
152144
self.tcx.sess.edition()
153145
}
@@ -472,7 +464,6 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
472464
let (sender, receiver) = channel();
473465
let mut scx = SharedContext {
474466
tcx,
475-
collapsed: krate.collapsed,
476467
src_root,
477468
local_sources,
478469
issue_tracker_base_url,

src/librustdoc/html/render/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ fn document_full_inner(
575575
is_collapsible: bool,
576576
heading_offset: HeadingOffset,
577577
) {
578-
if let Some(s) = cx.shared.maybe_collapsed_doc_value(item) {
578+
if let Some(s) = item.doc_value() {
579579
debug!("Doc block: =====\n{}\n=====", s);
580580
if is_collapsible {
581581
w.write_str(
@@ -1628,7 +1628,7 @@ fn render_impl(
16281628
write!(w, "</summary>")
16291629
}
16301630

1631-
if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) {
1631+
if let Some(ref dox) = i.impl_item.doc_value() {
16321632
let mut ids = cx.id_map.borrow_mut();
16331633
write!(
16341634
w,

0 commit comments

Comments
 (0)