Skip to content

Commit 1f080f6

Browse files
authored
Rollup merge of rust-lang#92077 - jyn514:remove-collapsed, r=GuillaumeGomez
rustdoc: Remove unused `collapsed` field `render/context` always runs after `run_global_context`, so it was always set to `true`. This is a holdover from when rustdoc allowed configuring passes, but the `collapse-docs` pass was removed ages ago, and the ability to configure passes is about to be removed. Found while reviewing rust-lang#91305.
2 parents 690d6b0 + dea1c68 commit 1f080f6

File tree

5 files changed

+4
-17
lines changed

5 files changed

+4
-17
lines changed

src/librustdoc/clean/types.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,11 @@ crate struct Crate {
122122
crate primitives: ThinVec<(DefId, PrimitiveType)>,
123123
/// Only here so that they can be filtered through the rustdoc passes.
124124
crate external_traits: Rc<RefCell<FxHashMap<DefId, TraitWithExtraInfo>>>,
125-
crate collapsed: bool,
126125
}
127126

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

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

src/librustdoc/clean/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ crate fn krate(cx: &mut DocContext<'_>) -> Crate {
7272
}));
7373
}
7474

75-
Crate { module, primitives, external_traits: cx.external_traits.clone(), collapsed: false }
75+
Crate { module, primitives, external_traits: cx.external_traits.clone() }
7676
}
7777

7878
fn external_generic_args(

src/librustdoc/core.rs

-3
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,6 @@ crate fn run_global_ctxt(
510510

511511
krate = tcx.sess.time("create_format_cache", || Cache::populate(&mut ctxt, krate));
512512

513-
// The main crate doc comments are always collapsed.
514-
krate.collapsed = true;
515-
516513
(krate, ctxt.render_options, ctxt.cache)
517514
}
518515

src/librustdoc/html/render/context.rs

-9
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.collapsed_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

+2-2
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ fn document_full_inner(
567567
is_collapsible: bool,
568568
heading_offset: HeadingOffset,
569569
) {
570-
if let Some(s) = cx.shared.maybe_collapsed_doc_value(item) {
570+
if let Some(s) = item.collapsed_doc_value() {
571571
debug!("Doc block: =====\n{}\n=====", s);
572572
if is_collapsible {
573573
w.write_str(
@@ -1612,7 +1612,7 @@ fn render_impl(
16121612
write!(w, "</summary>")
16131613
}
16141614

1615-
if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) {
1615+
if let Some(ref dox) = i.impl_item.collapsed_doc_value() {
16161616
let mut ids = cx.id_map.borrow_mut();
16171617
write!(
16181618
w,

0 commit comments

Comments
 (0)