Skip to content

Commit 43477d6

Browse files
committed
Move module listing open tag into render_attributes_in_code_with_options
1 parent b42c386 commit 43477d6

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
@@ -2932,8 +2932,7 @@ fn render_attributes_in_code(
29322932
prefix: &str,
29332933
cx: &Context<'_>,
29342934
) -> fmt::Result {
2935-
let _ = render_attributes_in_code_with_options(w, item, prefix, cx, true, None)?;
2936-
Ok(())
2935+
render_attributes_in_code_with_options(w, item, prefix, cx, true, "")
29372936
}
29382937

29392938
pub(super) fn render_attributes_in_code_with_options(
@@ -2942,20 +2941,11 @@ pub(super) fn render_attributes_in_code_with_options(
29422941
prefix: &str,
29432942
cx: &Context<'_>,
29442943
render_doc_hidden: bool,
2945-
open_tag: Option<&str>,
2946-
) -> Result<bool, fmt::Error> {
2947-
let mut wrote_any = false;
2948-
let open_tag = open_tag.unwrap_or("");
2949-
let mut render_attr = |attr: &str| -> fmt::Result {
2950-
if !wrote_any {
2951-
w.write_str(open_tag)?;
2952-
wrote_any = true;
2953-
}
2954-
render_code_attribute(prefix, attr, w)
2955-
};
2956-
2944+
open_tag: &str,
2945+
) -> fmt::Result {
2946+
w.write_str(open_tag)?;
29572947
if render_doc_hidden && item.is_doc_hidden() {
2958-
render_attr("#[doc(hidden)]")?;
2948+
render_code_attribute(prefix, "#[doc(hidden)]", w)?;
29592949
}
29602950
for attr in &item.attrs.other_attrs {
29612951
let hir::Attribute::Parsed(kind) = attr else { continue };
@@ -2970,15 +2960,15 @@ pub(super) fn render_attributes_in_code_with_options(
29702960
AttributeKind::NonExhaustive(..) => Cow::Borrowed("#[non_exhaustive]"),
29712961
_ => continue,
29722962
};
2973-
render_attr(attr.as_ref())?;
2963+
render_code_attribute(prefix, attr.as_ref(), w)?;
29742964
}
29752965

29762966
if let Some(def_id) = item.def_id()
29772967
&& let Some(repr) = repr_attribute(cx.tcx(), cx.cache(), def_id)
29782968
{
2979-
render_attr(&repr)?;
2969+
render_code_attribute(prefix, &repr, w)?;
29802970
}
2981-
Ok(wrote_any)
2971+
Ok(())
29822972
}
29832973

29842974
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
@@ -363,17 +363,14 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
363363

364364
let visibility_and_hidden = visibility_and_hidden(myitem);
365365
// Module listings use the hidden marker, so skip doc(hidden) here.
366-
let wrote_attrs = super::render_attributes_in_code_with_options(
366+
super::render_attributes_in_code_with_options(
367367
w,
368368
myitem,
369369
"",
370370
cx,
371371
false,
372-
Some("<dt><code>"),
372+
"<dt><code>",
373373
)?;
374-
if !wrote_attrs {
375-
w.write_str("<dt><code>")?;
376-
}
377374
match *src {
378375
Some(src) => {
379376
write!(

0 commit comments

Comments
 (0)