From 081336e8eb5d94071dad7f6fee9efd00305dc381 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 19 Feb 2017 00:31:09 +0100 Subject: [PATCH 1/4] Improve associated constant rendering in rustdoc --- src/librustdoc/html/render.rs | 2 +- src/librustdoc/html/static/main.js | 2 +- src/librustdoc/html/static/rustdoc.css | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index ae4c94d4b38c0..86b7c9736dab4 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2217,7 +2217,7 @@ fn assoc_const(w: &mut fmt::Formatter, ty: &clean::Type, default: Option<&String>, link: AssocItemLink) -> fmt::Result { - write!(w, "const {}", + write!(w, "const {}", naive_assoc_href(it, link), it.name.as_ref().unwrap())?; diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index c12e1e7d6080d..200285862276a 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -979,7 +979,7 @@ .html("[]"); toggle.children(".inner").text(labelForToggleButton(false)); - $(".method").each(function() { + $(".method, .impl-items > .associatedconstant").each(function() { if ($(this).next().is(".docblock") || ($(this).next().is(".stability") && $(this).next().next().is(".docblock"))) { $(this).children().last().after(toggle.clone()); diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 681d2354056f6..b0bf69b0181f2 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -89,7 +89,7 @@ h2 { h3 { font-size: 1.3em; } -h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) { +h1, h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) { font-weight: 500; margin: 20px 0 15px 0; padding-bottom: 6px; @@ -99,10 +99,10 @@ h1.fqn { margin-top: 0; position: relative; } -h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) { +h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) { border-bottom: 1px solid; } -h3.impl, h3.method, h4.method, h3.type, h4.type { +h3.impl, h3.method, h4.method, h3.type, h4.type, h4.associatedconstant { font-weight: 600; margin-top: 10px; margin-bottom: 10px; @@ -382,7 +382,7 @@ h4 > code, h3 > code, .invisible > code { .content .impl-items .docblock, .content .impl-items .stability { margin-left: 40px; } -.content .impl-items .method, .content .impl-items > .type { +.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant { margin-left: 20px; } From 5ac7a035af0f13b351a6e0ec9f889874d08e725d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 26 Feb 2017 18:33:42 +0100 Subject: [PATCH 2/4] Put the const type and value into --- src/librustdoc/clean/mod.rs | 2 +- src/librustdoc/html/format.rs | 88 ++++++++++++++++++++++++++++------- src/librustdoc/html/render.rs | 25 ++++++---- 3 files changed, 88 insertions(+), 27 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 751ed7d443d29..215d3d1a8279c 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1475,7 +1475,7 @@ pub struct PolyTrait { /// A representation of a Type suitable for hyperlinking purposes. Ideally one can get the original /// type out of the AST/TyCtxt given one of these, if more information is needed. Most importantly /// it does not preserve mutability or boxes. -#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)] pub enum Type { /// structs/enums/traits (most that'd be an hir::TyPath) ResolvedPath { diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 6f8c6aa7094dd..c796f0b20d3bb 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -560,7 +560,8 @@ impl<'a> fmt::Display for HRef<'a> { } } -fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt::Result { +fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool, + is_not_debug: bool) -> fmt::Result { match *t { clean::Generic(ref name) => { f.write_str(name) @@ -571,7 +572,8 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt: tybounds(f, typarams) } clean::Infer => write!(f, "_"), - clean::Primitive(prim) => primitive_link(f, prim, prim.as_str()), + clean::Primitive(prim) if is_not_debug => primitive_link(f, prim, prim.as_str()), + clean::Primitive(prim) => write!(f, "{}", prim.as_str()), clean::BareFunction(ref decl) => { if f.alternate() { write!(f, "{}{}fn{:#}{:#}", @@ -589,26 +591,30 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt: } clean::Tuple(ref typs) => { match &typs[..] { - &[] => primitive_link(f, PrimitiveType::Tuple, "()"), - &[ref one] => { + &[] if is_not_debug => primitive_link(f, PrimitiveType::Tuple, "()"), + &[] => write!(f, "()"), + &[ref one] if is_not_debug => { primitive_link(f, PrimitiveType::Tuple, "(")?; //carry f.alternate() into this display w/o branching manually fmt::Display::fmt(one, f)?; primitive_link(f, PrimitiveType::Tuple, ",)") } - many => { + &[ref one] => write!(f, "({},)", one), + many if is_not_debug => { primitive_link(f, PrimitiveType::Tuple, "(")?; fmt::Display::fmt(&CommaSep(&many), f)?; primitive_link(f, PrimitiveType::Tuple, ")") } + many => write!(f, "({})", &CommaSep(&many)), } } - clean::Vector(ref t) => { + clean::Vector(ref t) if is_not_debug => { primitive_link(f, PrimitiveType::Slice, &format!("["))?; fmt::Display::fmt(t, f)?; primitive_link(f, PrimitiveType::Slice, &format!("]")) } - clean::FixedVector(ref t, ref s) => { + clean::Vector(ref t) => write!(f, "[{}]", t), + clean::FixedVector(ref t, ref s) if is_not_debug => { primitive_link(f, PrimitiveType::Array, "[")?; fmt::Display::fmt(t, f)?; if f.alternate() { @@ -619,10 +625,17 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt: &format!("; {}]", Escape(s))) } } + clean::FixedVector(ref t, ref s) => { + if f.alternate() { + write!(f, "[{}; {}]", t, s) + } else { + write!(f, "[{}; {}]", t, Escape(s)) + } + } clean::Never => f.write_str("!"), clean::RawPointer(m, ref t) => { match **t { - clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} => { + clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} if is_not_debug => { if f.alternate() { primitive_link(f, clean::PrimitiveType::RawPointer, &format!("*{}{:#}", RawMutableSpace(m), t)) @@ -631,11 +644,21 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt: &format!("*{}{}", RawMutableSpace(m), t)) } } - _ => { + clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} => { + if f.alternate() { + write!(f, "*{}{:#}", RawMutableSpace(m), t) + } else { + write!(f, "*{}{}", RawMutableSpace(m), t) + } + } + _ if is_not_debug => { primitive_link(f, clean::PrimitiveType::RawPointer, &format!("*{}", RawMutableSpace(m)))?; fmt::Display::fmt(t, f) } + _ => { + write!(f, "*{}{}", RawMutableSpace(m), t) + } } } clean::BorrowedRef{ lifetime: ref l, mutability, type_: ref ty} => { @@ -647,15 +670,23 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt: match **ty { clean::Vector(ref bt) => { // BorrowedRef{ ... Vector(T) } is &[T] match **bt { - clean::Generic(_) => + clean::Generic(_) if is_not_debug => { if f.alternate() { primitive_link(f, PrimitiveType::Slice, &format!("&{}{}[{:#}]", lt, m, **bt)) } else { primitive_link(f, PrimitiveType::Slice, &format!("&{}{}[{}]", lt, m, **bt)) - }, - _ => { + } + } + clean::Generic(_) => { + if f.alternate() { + write!(f, "&{}{}[{:#}]", lt, m, **bt) + } else { + write!(f, "&{}{}[{}]", lt, m, **bt) + } + } + _ if is_not_debug => { if f.alternate() { primitive_link(f, PrimitiveType::Slice, &format!("&{}{}[", lt, m))?; @@ -667,15 +698,26 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt: } primitive_link(f, PrimitiveType::Slice, "]") } + _ => { + if f.alternate() { + write!(f, "&{}{}[{:#}]", lt, m, **bt) + } else { + write!(f, "&{}{}[{}]", lt, m, **bt) + } + } } } _ => { if f.alternate() { write!(f, "&{}{}", lt, m)?; - fmt_type(&ty, f, use_absolute) + fmt_type(&ty, f, use_absolute, is_not_debug) } else { - write!(f, "&{}{}", lt, m)?; - fmt_type(&ty, f, use_absolute) + if is_not_debug { + write!(f, "&{}{}", lt, m)?; + } else { + write!(f, "&{}{}", lt, m)?; + } + fmt_type(&ty, f, use_absolute, is_not_debug) } } } @@ -725,7 +767,11 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt: if f.alternate() { write!(f, "<{:#} as {:#}>::{}", self_type, trait_, name) } else { - write!(f, "<{} as {}>::{}", self_type, trait_, name) + if is_not_debug { + write!(f, "<{} as {}>::{}", self_type, trait_, name) + } else { + write!(f, "<{} as {}>::{}", self_type, trait_, name) + } } } clean::Unique(..) => { @@ -736,7 +782,13 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt: impl fmt::Display for clean::Type { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt_type(self, f, false) + fmt_type(self, f, false, true) + } +} + +impl fmt::Debug for clean::Type { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt_type(self, f, false, false) } } @@ -777,7 +829,7 @@ fn fmt_impl(i: &clean::Impl, plain.push_str(" for "); } - fmt_type(&i.for_, f, use_absolute)?; + fmt_type(&i.for_, f, use_absolute, true)?; plain.push_str(&format!("{:#}", i.for_)); fmt::Display::fmt(&WhereClause(&i.generics, plain.len() + 1), f)?; diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 86b7c9736dab4..30127ca96a15d 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1654,9 +1654,23 @@ fn document_short(w: &mut fmt::Formatter, item: &clean::Item, link: AssocItemLin Ok(()) } +fn md_render_assoc_item(item: &clean::Item) -> String { + match item.inner { + clean::AssociatedConstItem(ref ty, ref default) => { + if let Some(default) = default.as_ref() { + format!("```\n{}: {:?} = {}\n```\n\n", item.name.as_ref().unwrap(), ty, default) + } else { + format!("```\n{}: {:?}\n```\n\n", item.name.as_ref().unwrap(), ty) + } + } + _ => String::new(), + } +} + fn document_full(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result { if let Some(s) = item.doc_value() { - write!(w, "
{}
", Markdown(s))?; + write!(w, "
{}
", + Markdown(&format!("{}{}", md_render_assoc_item(item), s)))?; } Ok(()) } @@ -2214,17 +2228,12 @@ fn naive_assoc_href(it: &clean::Item, link: AssocItemLink) -> String { fn assoc_const(w: &mut fmt::Formatter, it: &clean::Item, - ty: &clean::Type, - default: Option<&String>, + _ty: &clean::Type, + _default: Option<&String>, link: AssocItemLink) -> fmt::Result { write!(w, "const {}", naive_assoc_href(it, link), it.name.as_ref().unwrap())?; - - write!(w, ": {}", ty)?; - if let Some(default) = default { - write!(w, " = {}", Escape(default))?; - } Ok(()) } From d06f72d06203c3d0a8db8d472316765b43a784db Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 28 Feb 2017 00:27:19 +0100 Subject: [PATCH 3/4] Apply the same transformation to every types --- src/librustdoc/html/format.rs | 54 ++++++++++++++++++++------------ src/librustdoc/html/highlight.rs | 6 ++-- src/librustdoc/html/render.rs | 43 ++++++++++++++++--------- 3 files changed, 65 insertions(+), 38 deletions(-) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index c796f0b20d3bb..23507dc889b71 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -90,6 +90,16 @@ impl<'a, T: fmt::Display> fmt::Display for CommaSep<'a, T> { } } +impl<'a, T: fmt::Debug> fmt::Debug for CommaSep<'a, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + for (i, item) in self.0.iter().enumerate() { + if i != 0 { write!(f, ", ")?; } + fmt::Debug::fmt(item, f)?; + } + Ok(()) + } +} + impl<'a> fmt::Display for TyParamBounds<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let &TyParamBounds(bounds) = self; @@ -165,7 +175,7 @@ impl<'a> fmt::Display for WhereClause<'a> { if f.alternate() { clause.push_str(" where "); } else { - clause.push_str(" where "); + clause.push_str(" where "); } for (i, pred) in gens.where_predicates.iter().enumerate() { if i > 0 { @@ -449,8 +459,8 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path, } else { root.push_str(&seg.name); root.push_str("/"); - write!(w, "{}::", + write!(w, "{}::", root, seg.name)?; } @@ -491,7 +501,7 @@ fn primitive_link(f: &mut fmt::Formatter, Some(&def_id) if def_id.is_local() => { let len = CURRENT_LOCATION_KEY.with(|s| s.borrow().len()); let len = if len == 0 {0} else {len - 1}; - write!(f, "", + write!(f, "", repeat("../").take(len).collect::(), prim.to_url_str())?; needs_termination = true; @@ -508,7 +518,7 @@ fn primitive_link(f: &mut fmt::Formatter, (.., render::Unknown) => None, }; if let Some((cname, root)) = loc { - write!(f, "", + write!(f, "", root, cname, prim.to_url_str())?; @@ -550,7 +560,7 @@ impl<'a> fmt::Display for HRef<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match href(self.did) { Some((url, shortty, fqp)) => if !f.alternate() { - write!(f, "{}", + write!(f, "{}", shortty, url, shortty, fqp.join("::"), self.text) } else { write!(f, "{}", self.text) @@ -599,13 +609,13 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool, fmt::Display::fmt(one, f)?; primitive_link(f, PrimitiveType::Tuple, ",)") } - &[ref one] => write!(f, "({},)", one), + &[ref one] => write!(f, "({:?},)", one), many if is_not_debug => { primitive_link(f, PrimitiveType::Tuple, "(")?; fmt::Display::fmt(&CommaSep(&many), f)?; primitive_link(f, PrimitiveType::Tuple, ")") } - many => write!(f, "({})", &CommaSep(&many)), + many => write!(f, "({:?})", &CommaSep(&many)), } } clean::Vector(ref t) if is_not_debug => { @@ -613,7 +623,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool, fmt::Display::fmt(t, f)?; primitive_link(f, PrimitiveType::Slice, &format!("]")) } - clean::Vector(ref t) => write!(f, "[{}]", t), + clean::Vector(ref t) => write!(f, "[{:?}]", t), clean::FixedVector(ref t, ref s) if is_not_debug => { primitive_link(f, PrimitiveType::Array, "[")?; fmt::Display::fmt(t, f)?; @@ -627,9 +637,9 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool, } clean::FixedVector(ref t, ref s) => { if f.alternate() { - write!(f, "[{}; {}]", t, s) + write!(f, "[{:?}; {}]", t, s) } else { - write!(f, "[{}; {}]", t, Escape(s)) + write!(f, "[{:?}; {}]", t, Escape(s)) } } clean::Never => f.write_str("!"), @@ -646,9 +656,9 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool, } clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} => { if f.alternate() { - write!(f, "*{}{:#}", RawMutableSpace(m), t) + write!(f, "*{}{:#?}", RawMutableSpace(m), t) } else { - write!(f, "*{}{}", RawMutableSpace(m), t) + write!(f, "*{}{:?}", RawMutableSpace(m), t) } } _ if is_not_debug => { @@ -657,7 +667,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool, fmt::Display::fmt(t, f) } _ => { - write!(f, "*{}{}", RawMutableSpace(m), t) + write!(f, "*{}{:?}", RawMutableSpace(m), t) } } } @@ -681,9 +691,9 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool, } clean::Generic(_) => { if f.alternate() { - write!(f, "&{}{}[{:#}]", lt, m, **bt) + write!(f, "&{}{}[{:#?}]", lt, m, **bt) } else { - write!(f, "&{}{}[{}]", lt, m, **bt) + write!(f, "&{}{}[{:?}]", lt, m, **bt) } } _ if is_not_debug => { @@ -700,9 +710,9 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool, } _ => { if f.alternate() { - write!(f, "&{}{}[{:#}]", lt, m, **bt) + write!(f, "&{}{}[{:#?}]", lt, m, **bt) } else { - write!(f, "&{}{}[{}]", lt, m, **bt) + write!(f, "&{}{}[{:?}]", lt, m, **bt) } } } @@ -765,12 +775,16 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool, } clean::QPath { ref name, ref self_type, ref trait_ } => { if f.alternate() { - write!(f, "<{:#} as {:#}>::{}", self_type, trait_, name) + if is_not_debug { + write!(f, "<{:#} as {:#}>::{}", self_type, trait_, name) + } else { + write!(f, "<{:#?} as {:#?}>::{}", self_type, trait_, name) + } } else { if is_not_debug { write!(f, "<{} as {}>::{}", self_type, trait_, name) } else { - write!(f, "<{} as {}>::{}", self_type, trait_, name) + write!(f, "<{:?} as {:?}>::{}", self_type, trait_, name) } } } diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 0629e93e7ef5d..46db2d538a652 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -144,12 +144,12 @@ impl Writer for U { -> io::Result<()> { match klass { Class::None => write!(self, "{}", text), - klass => write!(self, "{}", klass.rustdoc_class(), text), + klass => write!(self, "{}", klass.rustdoc_class(), text), } } fn enter_span(&mut self, klass: Class) -> io::Result<()> { - write!(self, "", klass.rustdoc_class()) + write!(self, "", klass.rustdoc_class()) } fn exit_span(&mut self) -> io::Result<()> { @@ -363,7 +363,7 @@ fn write_header(class: Option<&str>, if let Some(id) = id { write!(out, "id='{}' ", id)?; } - write!(out, "class='rust {}'>\n", class.unwrap_or("")) + write!(out, "class=\"rust {}\">\n", class.unwrap_or("")) } fn write_footer(out: &mut Write) -> io::Result<()> { diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 30127ca96a15d..ead913b57be50 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1547,7 +1547,7 @@ impl<'a> fmt::Display for Item<'a> { component)?; } } - write!(fmt, "{}", + write!(fmt, "{}", self.item.type_(), self.item.name.as_ref().unwrap())?; write!(fmt, "")?; // in-band @@ -1667,8 +1667,20 @@ fn md_render_assoc_item(item: &clean::Item) -> String { } } +fn get_doc_value(item: &clean::Item) -> Option<&str> { + let x = item.doc_value(); + if x.is_none() { + match item.inner { + clean::AssociatedConstItem(_, _) => Some(""), + _ => None, + } + } else { + x + } +} + fn document_full(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result { - if let Some(s) = item.doc_value() { + if let Some(s) = get_doc_value(item) { write!(w, "
{}
", Markdown(&format!("{}{}", md_render_assoc_item(item), s)))?; } @@ -1831,7 +1843,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context, let doc_value = myitem.doc_value().unwrap_or(""); write!(w, " - {name}{unsafety_flag} {stab_docs} {docs} @@ -2228,12 +2240,13 @@ fn naive_assoc_href(it: &clean::Item, link: AssocItemLink) -> String { fn assoc_const(w: &mut fmt::Formatter, it: &clean::Item, - _ty: &clean::Type, + ty: &clean::Type, _default: Option<&String>, link: AssocItemLink) -> fmt::Result { - write!(w, "const {}", + write!(w, "const {}: {}", naive_assoc_href(it, link), - it.name.as_ref().unwrap())?; + it.name.as_ref().unwrap(), + ty)?; Ok(()) } @@ -2241,7 +2254,7 @@ fn assoc_type(w: &mut fmt::Formatter, it: &clean::Item, bounds: &Vec, default: Option<&clean::Type>, link: AssocItemLink) -> fmt::Result { - write!(w, "type {}", + write!(w, "type {}", naive_assoc_href(it, link), it.name.as_ref().unwrap())?; if !bounds.is_empty() { @@ -2384,7 +2397,7 @@ fn item_struct(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, let ns_id = derive_id(format!("{}.{}", field.name.as_ref().unwrap(), ItemType::StructField.name_space())); - write!(w, " + write!(w, " ", @@ -2426,7 +2439,7 @@ fn item_union(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, if fields.peek().is_some() { write!(w, "

Fields

")?; for (field, ty) in fields { - write!(w, "{name}: {ty} + write!(w, "{name}: {ty} ", shortty = ItemType::StructField, name = field.name.as_ref().unwrap(), @@ -2911,7 +2924,7 @@ fn render_impl(w: &mut fmt::Formatter, cx: &Context, i: &Impl, link: AssocItemLi if render_method_item { let id = derive_id(format!("{}.{}", item_type, name)); let ns_id = derive_id(format!("{}.{}", name, item_type.name_space())); - write!(w, "

", id, item_type)?; + write!(w, "

", id, item_type)?; write!(w, "