Skip to content

Commit 134eae9

Browse files
committed
librustdoc: remove unused for_html field from Buffer 🦄
1 parent 942db67 commit 134eae9

File tree

6 files changed

+17
-26
lines changed

6 files changed

+17
-26
lines changed

src/librustdoc/html/format.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ impl Print for &'_ str {
6262
}
6363
}
6464

65-
#[derive(Debug, Clone)]
65+
#[derive(Debug, Default, Clone)]
6666
pub(crate) struct Buffer {
67-
for_html: bool,
6867
buffer: String,
6968
}
7069

@@ -86,16 +85,8 @@ impl core::fmt::Write for Buffer {
8685
}
8786

8887
impl Buffer {
89-
pub(crate) fn empty_from(v: &Buffer) -> Buffer {
90-
Buffer { for_html: v.for_html, buffer: String::new() }
91-
}
92-
93-
pub(crate) fn html() -> Buffer {
94-
Buffer { for_html: true, buffer: String::new() }
95-
}
96-
9788
pub(crate) fn new() -> Buffer {
98-
Buffer { for_html: false, buffer: String::new() }
89+
Self::default()
9990
}
10091

10192
pub(crate) fn is_empty(&self) -> bool {

src/librustdoc/html/layout.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ pub(crate) fn render<T: Print, S: Print>(
9898
let mut themes: Vec<String> = style_files.iter().map(|s| s.basename().unwrap()).collect();
9999
themes.sort();
100100

101-
let content = Buffer::html().to_display(t); // Note: This must happen before making the sidebar.
102-
let sidebar = Buffer::html().to_display(sidebar);
101+
let content = Buffer::new().to_display(t); // Note: This must happen before making the sidebar.
102+
let sidebar = Buffer::new().to_display(sidebar);
103103
PageLayout {
104104
static_root_path,
105105
page,

src/librustdoc/html/render/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl<'tcx> Context<'tcx> {
235235
};
236236

237237
if !render_redirect_pages {
238-
let mut page_buffer = Buffer::html();
238+
let mut page_buffer = Buffer::new();
239239
print_item(self, it, &mut page_buffer);
240240
let page = layout::Page {
241241
css_class: tyname_s,
@@ -627,7 +627,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
627627
rust_logo: has_doc_flag(self.tcx(), LOCAL_CRATE.as_def_id(), sym::rust_logo),
628628
};
629629
let all = shared.all.replace(AllTypes::new());
630-
let mut sidebar = Buffer::html();
630+
let mut sidebar = Buffer::new();
631631

632632
// all.html is not customizable, so a blank id map is fine
633633
let blocks = sidebar_module_like(all.item_sections(), &mut IdMap::new(), ModuleLike::Crate);

src/librustdoc/html/render/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ pub(crate) fn render_all_impls(
12221222
synthetic: &[&Impl],
12231223
blanket_impl: &[&Impl],
12241224
) {
1225-
let mut impls = Buffer::html();
1225+
let mut impls = Buffer::new();
12261226
render_impls(cx, &mut impls, concrete, containing_item, true);
12271227
let impls = impls.into_inner();
12281228
if !impls.is_empty() {
@@ -1277,7 +1277,7 @@ fn render_assoc_items_inner(
12771277
let (non_trait, traits): (Vec<_>, _) = v.iter().partition(|i| i.inner_impl().trait_.is_none());
12781278
if !non_trait.is_empty() {
12791279
let mut close_tags = <Vec<&str>>::with_capacity(1);
1280-
let mut tmp_buf = Buffer::html();
1280+
let mut tmp_buf = Buffer::new();
12811281
let (render_mode, id, class_html) = match what {
12821282
AssocItemRender::All => {
12831283
write_impl_section_heading(&mut tmp_buf, "Implementations", "implementations");
@@ -1305,7 +1305,7 @@ fn render_assoc_items_inner(
13051305
(RenderMode::ForDeref { mut_: deref_mut_ }, derived_id, r#" class="impl-items""#)
13061306
}
13071307
};
1308-
let mut impls_buf = Buffer::html();
1308+
let mut impls_buf = Buffer::new();
13091309
for i in &non_trait {
13101310
render_impl(
13111311
&mut impls_buf,
@@ -1485,7 +1485,7 @@ pub(crate) fn notable_traits_button(ty: &clean::Type, cx: &Context<'_>) -> Optio
14851485
}
14861486

14871487
fn notable_traits_decl(ty: &clean::Type, cx: &Context<'_>) -> (String, String) {
1488-
let mut out = Buffer::html();
1488+
let mut out = Buffer::new();
14891489

14901490
let did = ty.def_id(cx.cache()).expect("notable_traits_button already checked this");
14911491

@@ -1622,8 +1622,8 @@ fn render_impl(
16221622

16231623
let in_trait_class = if trait_.is_some() { " trait-impl" } else { "" };
16241624

1625-
let mut doc_buffer = Buffer::empty_from(boring);
1626-
let mut info_buffer = Buffer::empty_from(boring);
1625+
let mut doc_buffer = Buffer::new();
1626+
let mut info_buffer = Buffer::new();
16271627
let mut short_documented = true;
16281628

16291629
if render_method_item {
@@ -1819,8 +1819,8 @@ fn render_impl(
18191819
}
18201820
}
18211821

1822-
let mut impl_items = Buffer::empty_from(w);
1823-
let mut default_impl_items = Buffer::empty_from(w);
1822+
let mut impl_items = Buffer::new();
1823+
let mut default_impl_items = Buffer::new();
18241824
let impl_ = i.inner_impl();
18251825

18261826
// Impl items are grouped by kinds:

src/librustdoc/html/render/print_item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
787787
let item_type = m.type_();
788788
let id = cx.derive_id(format!("{item_type}.{name}"));
789789

790-
let mut content = Buffer::empty_from(w);
790+
let mut content = Buffer::new();
791791
write!(content, "{}", document_full(m, cx, HeadingOffset::H5));
792792

793793
let toggled = !content.is_empty();
@@ -2152,7 +2152,7 @@ fn render_union<'a, 'cx: 'a>(
21522152

21532153
let where_displayed = g
21542154
.map(|g| {
2155-
let mut buf = Buffer::html();
2155+
let mut buf = Buffer::new();
21562156
write!(buf, "{}", g.print(cx));
21572157
let where_displayed = print_where_clause_and_check(&mut buf, g, cx);
21582158
write!(f, "{buf}", buf = buf.into_inner()).unwrap();

src/librustdoc/html/render/write_shared.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ impl TypeAliasPart {
622622
// to make that functionality work here, it needs to be called with
623623
// each type alias, and if it gives a different result, split the impl
624624
for &(type_alias_fqp, type_alias_item) in type_aliases {
625-
let mut buf = Buffer::html();
625+
let mut buf = Buffer::new();
626626
cx.id_map.borrow_mut().clear();
627627
cx.deref_id_map.borrow_mut().clear();
628628
let target_did = impl_

0 commit comments

Comments
 (0)