Skip to content

Commit 7c54229

Browse files
committed
Move module listing open tag into render_attributes_in_code_with_options
1 parent 3b74869 commit 7c54229

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
@@ -2913,8 +2913,7 @@ fn render_attributes_in_code(
29132913
prefix: &str,
29142914
cx: &Context<'_>,
29152915
) -> fmt::Result {
2916-
let _ = render_attributes_in_code_with_options(w, item, prefix, cx, true, None)?;
2917-
Ok(())
2916+
render_attributes_in_code_with_options(w, item, prefix, cx, true, "")
29182917
}
29192918

29202919
pub(super) fn render_attributes_in_code_with_options(
@@ -2923,20 +2922,11 @@ pub(super) fn render_attributes_in_code_with_options(
29232922
prefix: &str,
29242923
cx: &Context<'_>,
29252924
render_doc_hidden: bool,
2926-
open_tag: Option<&str>,
2927-
) -> Result<bool, fmt::Error> {
2928-
let mut wrote_any = false;
2929-
let open_tag = open_tag.unwrap_or("");
2930-
let mut render_attr = |attr: &str| -> fmt::Result {
2931-
if !wrote_any {
2932-
w.write_str(open_tag)?;
2933-
wrote_any = true;
2934-
}
2935-
render_code_attribute(prefix, attr, w)
2936-
};
2937-
2925+
open_tag: &str,
2926+
) -> fmt::Result {
2927+
w.write_str(open_tag)?;
29382928
if render_doc_hidden && item.is_doc_hidden() {
2939-
render_attr("#[doc(hidden)]")?;
2929+
render_code_attribute(prefix, "#[doc(hidden)]", w)?;
29402930
}
29412931
for attr in &item.attrs.other_attrs {
29422932
let hir::Attribute::Parsed(kind) = attr else { continue };
@@ -2951,15 +2941,15 @@ pub(super) fn render_attributes_in_code_with_options(
29512941
AttributeKind::NonExhaustive(..) => Cow::Borrowed("#[non_exhaustive]"),
29522942
_ => continue,
29532943
};
2954-
render_attr(attr.as_ref())?;
2944+
render_code_attribute(prefix, attr.as_ref(), w)?;
29552945
}
29562946

29572947
if let Some(def_id) = item.def_id()
29582948
&& let Some(repr) = repr_attribute(cx.tcx(), cx.cache(), def_id)
29592949
{
2960-
render_attr(&repr)?;
2950+
render_code_attribute(prefix, &repr, w)?;
29612951
}
2962-
Ok(wrote_any)
2952+
Ok(())
29632953
}
29642954

29652955
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)