Skip to content

Commit 19f1bad

Browse files
Fix items alignment
1 parent 5971266 commit 19f1bad

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

src/librustdoc/html/render.rs

+19-11
Original file line numberDiff line numberDiff line change
@@ -3389,8 +3389,10 @@ fn assoc_const(w: &mut fmt::Formatter<'_>,
33893389
it: &clean::Item,
33903390
ty: &clean::Type,
33913391
_default: Option<&String>,
3392-
link: AssocItemLink<'_>) -> fmt::Result {
3393-
write!(w, "{}const <a href='{}' class=\"constant\"><b>{}</b></a>: {}",
3392+
link: AssocItemLink<'_>,
3393+
extra: &str) -> fmt::Result {
3394+
write!(w, "{}{}const <a href='{}' class=\"constant\"><b>{}</b></a>: {}",
3395+
extra,
33943396
VisSpace(&it.visibility),
33953397
naive_assoc_href(it, link),
33963398
it.name.as_ref().unwrap(),
@@ -3401,8 +3403,10 @@ fn assoc_const(w: &mut fmt::Formatter<'_>,
34013403
fn assoc_type<W: fmt::Write>(w: &mut W, it: &clean::Item,
34023404
bounds: &[clean::GenericBound],
34033405
default: Option<&clean::Type>,
3404-
link: AssocItemLink<'_>) -> fmt::Result {
3405-
write!(w, "type <a href='{}' class=\"type\">{}</a>",
3406+
link: AssocItemLink<'_>,
3407+
extra: &str) -> fmt::Result {
3408+
write!(w, "{}type <a href='{}' class=\"type\">{}</a>",
3409+
extra,
34063410
naive_assoc_href(it, link),
34073411
it.name.as_ref().unwrap())?;
34083412
if !bounds.is_empty() {
@@ -3513,10 +3517,12 @@ fn render_assoc_item(w: &mut fmt::Formatter<'_>,
35133517
method(w, item, m.header, &m.generics, &m.decl, link, parent)
35143518
}
35153519
clean::AssociatedConstItem(ref ty, ref default) => {
3516-
assoc_const(w, item, ty, default.as_ref(), link)
3520+
assoc_const(w, item, ty, default.as_ref(), link,
3521+
if parent == ItemType::Trait { " " } else { "" })
35173522
}
35183523
clean::AssociatedTypeItem(ref bounds, ref default) => {
3519-
assoc_type(w, item, bounds, default.as_ref(), link)
3524+
assoc_type(w, item, bounds, default.as_ref(), link,
3525+
if parent == ItemType::Trait { " " } else { "" })
35203526
}
35213527
_ => panic!("render_assoc_item called on non-associated-item")
35223528
}
@@ -4129,7 +4135,8 @@ fn spotlight_decl(decl: &clean::FnDecl) -> Result<String, fmt::Error> {
41294135
out.push_str("<span class=\"where fmt-newline\"> ");
41304136
assoc_type(&mut out, it, &[],
41314137
Some(&tydef.type_),
4132-
AssocItemLink::GotoSource(t_did, &FxHashSet::default()))?;
4138+
AssocItemLink::GotoSource(t_did, &FxHashSet::default()),
4139+
"")?;
41334140
out.push_str(";</span>");
41344141
}
41354142
}
@@ -4165,7 +4172,8 @@ fn render_impl(w: &mut fmt::Formatter<'_>, cx: &Context, i: &Impl, link: AssocIt
41654172
if let clean::TypedefItem(ref tydef, _) = it.inner {
41664173
write!(w, "<span class=\"where fmt-newline\"> ")?;
41674174
assoc_type(w, it, &vec![], Some(&tydef.type_),
4168-
AssocItemLink::Anchor(None))?;
4175+
AssocItemLink::Anchor(None),
4176+
"")?;
41694177
write!(w, ";</span>")?;
41704178
}
41714179
}
@@ -4235,15 +4243,15 @@ fn render_impl(w: &mut fmt::Formatter<'_>, cx: &Context, i: &Impl, link: AssocIt
42354243
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
42364244
write!(w, "<h4 id='{}' class=\"{}{}\">", id, item_type, extra_class)?;
42374245
write!(w, "<code id='{}'>", ns_id)?;
4238-
assoc_type(w, item, &Vec::new(), Some(&tydef.type_), link.anchor(&id))?;
4246+
assoc_type(w, item, &Vec::new(), Some(&tydef.type_), link.anchor(&id), "")?;
42394247
write!(w, "</code></h4>")?;
42404248
}
42414249
clean::AssociatedConstItem(ref ty, ref default) => {
42424250
let id = cx.derive_id(format!("{}.{}", item_type, name));
42434251
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
42444252
write!(w, "<h4 id='{}' class=\"{}{}\">", id, item_type, extra_class)?;
42454253
write!(w, "<code id='{}'>", ns_id)?;
4246-
assoc_const(w, item, ty, default.as_ref(), link.anchor(&id))?;
4254+
assoc_const(w, item, ty, default.as_ref(), link.anchor(&id), "")?;
42474255
write!(w, "</code>")?;
42484256
render_stability_since_raw(w, item.stable_since(), outer_version)?;
42494257
if let Some(l) = (Item { cx, item }).src_href() {
@@ -4257,7 +4265,7 @@ fn render_impl(w: &mut fmt::Formatter<'_>, cx: &Context, i: &Impl, link: AssocIt
42574265
let ns_id = cx.derive_id(format!("{}.{}", name, item_type.name_space()));
42584266
write!(w, "<h4 id='{}' class=\"{}{}\">", id, item_type, extra_class)?;
42594267
write!(w, "<code id='{}'>", ns_id)?;
4260-
assoc_type(w, item, bounds, default.as_ref(), link.anchor(&id))?;
4268+
assoc_type(w, item, bounds, default.as_ref(), link.anchor(&id), "")?;
42614269
write!(w, "</code></h4>")?;
42624270
}
42634271
clean::StrippedItem(..) => return Ok(()),

0 commit comments

Comments
 (0)