Rollup merge of #59855 - GuillaumeGomez:fix-attr-position-in-type-decl, r=QuietMisdreavus
Fix attributes position in type declaration Fixes #59797. r? @rust-lang/rustdoc
This commit is contained in:
commit
8af5c8f4cb
@ -3136,7 +3136,6 @@ fn item_trait(
|
|||||||
// FIXME: we should be using a derived_id for the Anchors here
|
// FIXME: we should be using a derived_id for the Anchors here
|
||||||
write!(w, "{{\n")?;
|
write!(w, "{{\n")?;
|
||||||
for t in &types {
|
for t in &types {
|
||||||
write!(w, " ")?;
|
|
||||||
render_assoc_item(w, t, AssocItemLink::Anchor(None), ItemType::Trait)?;
|
render_assoc_item(w, t, AssocItemLink::Anchor(None), ItemType::Trait)?;
|
||||||
write!(w, ";\n")?;
|
write!(w, ";\n")?;
|
||||||
}
|
}
|
||||||
@ -3144,7 +3143,6 @@ fn item_trait(
|
|||||||
w.write_str("\n")?;
|
w.write_str("\n")?;
|
||||||
}
|
}
|
||||||
for t in &consts {
|
for t in &consts {
|
||||||
write!(w, " ")?;
|
|
||||||
render_assoc_item(w, t, AssocItemLink::Anchor(None), ItemType::Trait)?;
|
render_assoc_item(w, t, AssocItemLink::Anchor(None), ItemType::Trait)?;
|
||||||
write!(w, ";\n")?;
|
write!(w, ";\n")?;
|
||||||
}
|
}
|
||||||
@ -3152,7 +3150,6 @@ fn item_trait(
|
|||||||
w.write_str("\n")?;
|
w.write_str("\n")?;
|
||||||
}
|
}
|
||||||
for (pos, m) in required.iter().enumerate() {
|
for (pos, m) in required.iter().enumerate() {
|
||||||
write!(w, " ")?;
|
|
||||||
render_assoc_item(w, m, AssocItemLink::Anchor(None), ItemType::Trait)?;
|
render_assoc_item(w, m, AssocItemLink::Anchor(None), ItemType::Trait)?;
|
||||||
write!(w, ";\n")?;
|
write!(w, ";\n")?;
|
||||||
|
|
||||||
@ -3164,7 +3161,6 @@ fn item_trait(
|
|||||||
w.write_str("\n")?;
|
w.write_str("\n")?;
|
||||||
}
|
}
|
||||||
for (pos, m) in provided.iter().enumerate() {
|
for (pos, m) in provided.iter().enumerate() {
|
||||||
write!(w, " ")?;
|
|
||||||
render_assoc_item(w, m, AssocItemLink::Anchor(None), ItemType::Trait)?;
|
render_assoc_item(w, m, AssocItemLink::Anchor(None), ItemType::Trait)?;
|
||||||
match m.inner {
|
match m.inner {
|
||||||
clean::MethodItem(ref inner) if !inner.generics.where_predicates.is_empty() => {
|
clean::MethodItem(ref inner) if !inner.generics.where_predicates.is_empty() => {
|
||||||
@ -3473,8 +3469,9 @@ fn render_assoc_item(w: &mut fmt::Formatter<'_>,
|
|||||||
(0, true)
|
(0, true)
|
||||||
};
|
};
|
||||||
render_attributes(w, meth)?;
|
render_attributes(w, meth)?;
|
||||||
write!(w, "{}{}{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
|
write!(w, "{}{}{}{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
|
||||||
{generics}{decl}{where_clause}",
|
{generics}{decl}{where_clause}",
|
||||||
|
if parent == ItemType::Trait { " " } else { "" },
|
||||||
VisSpace(&meth.visibility),
|
VisSpace(&meth.visibility),
|
||||||
ConstnessSpace(header.constness),
|
ConstnessSpace(header.constness),
|
||||||
UnsafetySpace(header.unsafety),
|
UnsafetySpace(header.unsafety),
|
||||||
@ -3775,7 +3772,7 @@ const ATTRIBUTE_WHITELIST: &'static [&'static str] = &[
|
|||||||
"non_exhaustive"
|
"non_exhaustive"
|
||||||
];
|
];
|
||||||
|
|
||||||
fn render_attributes(w: &mut fmt::Formatter<'_>, it: &clean::Item) -> fmt::Result {
|
fn render_attributes(w: &mut dyn fmt::Write, it: &clean::Item) -> fmt::Result {
|
||||||
let mut attrs = String::new();
|
let mut attrs = String::new();
|
||||||
|
|
||||||
for attr in &it.attrs.other_attrs {
|
for attr in &it.attrs.other_attrs {
|
||||||
|
@ -1577,3 +1577,17 @@ div.name.expand::before {
|
|||||||
left: -15px;
|
left: -15px;
|
||||||
top: 2px;
|
top: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This part is to fix the "Expand attributes" part in the type declaration. */
|
||||||
|
.type-decl > pre > :first-child {
|
||||||
|
margin-left: 0 !important;
|
||||||
|
}
|
||||||
|
.type-decl > pre > :nth-child(2) {
|
||||||
|
margin-left: 1.8em !important;
|
||||||
|
}
|
||||||
|
.type-decl > pre > .toggle-attributes {
|
||||||
|
margin-left: 2.2em;
|
||||||
|
}
|
||||||
|
.type-decl > pre > .docblock.attributes {
|
||||||
|
margin-left: 4em;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user