Skip to content

Commit bff7096

Browse files
committed
Move module listing open tag into render_attributes_in_code_with_options
1 parent 3fb84f0 commit bff7096

2 files changed

Lines changed: 10 additions & 23 deletions

File tree

src/librustdoc/html/render/mod.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,8 +2916,7 @@ fn render_attributes_in_code(
29162916
prefix: &str,
29172917
cx: &Context<'_>,
29182918
) -> fmt::Result {
2919-
let _ = render_attributes_in_code_with_options(w, item, prefix, cx, true, None)?;
2920-
Ok(())
2919+
render_attributes_in_code_with_options(w, item, prefix, cx, true, "")
29212920
}
29222921

29232922
pub(super) fn render_attributes_in_code_with_options(
@@ -2926,20 +2925,11 @@ pub(super) fn render_attributes_in_code_with_options(
29262925
prefix: &str,
29272926
cx: &Context<'_>,
29282927
render_doc_hidden: bool,
2929-
open_tag: Option<&str>,
2930-
) -> Result<bool, fmt::Error> {
2931-
let mut wrote_any = false;
2932-
let open_tag = open_tag.unwrap_or("");
2933-
let mut render_attr = |attr: &str| -> fmt::Result {
2934-
if !wrote_any {
2935-
w.write_str(open_tag)?;
2936-
wrote_any = true;
2937-
}
2938-
render_code_attribute(prefix, attr, w)
2939-
};
2940-
2928+
open_tag: &str,
2929+
) -> fmt::Result {
2930+
w.write_str(open_tag)?;
29412931
if render_doc_hidden && item.is_doc_hidden() {
2942-
render_attr("#[doc(hidden)]")?;
2932+
render_code_attribute(prefix, "#[doc(hidden)]", w)?;
29432933
}
29442934
for attr in &item.attrs.other_attrs {
29452935
let hir::Attribute::Parsed(kind) = attr else { continue };
@@ -2954,15 +2944,15 @@ pub(super) fn render_attributes_in_code_with_options(
29542944
AttributeKind::NonExhaustive(..) => Cow::Borrowed("#[non_exhaustive]"),
29552945
_ => continue,
29562946
};
2957-
render_attr(attr.as_ref())?;
2947+
render_code_attribute(prefix, attr.as_ref(), w)?;
29582948
}
29592949

29602950
if let Some(def_id) = item.def_id()
29612951
&& let Some(repr) = repr_attribute(cx.tcx(), cx.cache(), def_id)
29622952
{
2963-
render_attr(&repr)?;
2953+
render_code_attribute(prefix, &repr, w)?;
29642954
}
2965-
Ok(wrote_any)
2955+
Ok(())
29662956
}
29672957

29682958
fn render_repr_attribute_in_code(

src/librustdoc/html/render/print_item.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,17 +359,14 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
359359

360360
let visibility_and_hidden = visibility_and_hidden(myitem);
361361
// Module listings use the hidden marker, so skip doc(hidden) here.
362-
let wrote_attrs = super::render_attributes_in_code_with_options(
362+
super::render_attributes_in_code_with_options(
363363
w,
364364
myitem,
365365
"",
366366
cx,
367367
false,
368-
Some("<dt><code>"),
368+
"<dt><code>",
369369
)?;
370-
if !wrote_attrs {
371-
w.write_str("<dt><code>")?;
372-
}
373370
match *src {
374371
Some(src) => {
375372
write!(

0 commit comments

Comments
 (0)