rustdoc: Cleanup associated const value rendering
Rather than (ab)using Debug for outputting the type in plain text use the alternate format parameter which already does exactly that. This fixes type parameters for example which would output raw HTML. Also cleans up adding parens around references to trait objects.
This commit is contained in:
@@ -1487,7 +1487,7 @@ pub struct PolyTrait {
|
|||||||
/// A representation of a Type suitable for hyperlinking purposes. Ideally one can get the original
|
/// 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
|
/// type out of the AST/TyCtxt given one of these, if more information is needed. Most importantly
|
||||||
/// it does not preserve mutability or boxes.
|
/// it does not preserve mutability or boxes.
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Debug)]
|
||||||
pub enum Type {
|
pub enum Type {
|
||||||
/// structs/enums/traits (most that'd be an hir::TyPath)
|
/// structs/enums/traits (most that'd be an hir::TyPath)
|
||||||
ResolvedPath {
|
ResolvedPath {
|
||||||
|
|||||||
@@ -106,16 +106,6 @@ 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> {
|
impl<'a> fmt::Display for TyParamBounds<'a> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let &TyParamBounds(bounds) = self;
|
let &TyParamBounds(bounds) = self;
|
||||||
@@ -469,8 +459,7 @@ pub fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> {
|
|||||||
/// Used when rendering a `ResolvedPath` structure. This invokes the `path`
|
/// Used when rendering a `ResolvedPath` structure. This invokes the `path`
|
||||||
/// rendering function with the necessary arguments for linking to a local path.
|
/// rendering function with the necessary arguments for linking to a local path.
|
||||||
fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
|
fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
|
||||||
print_all: bool, use_absolute: bool, is_not_debug: bool,
|
print_all: bool, use_absolute: bool) -> fmt::Result {
|
||||||
need_paren: bool) -> fmt::Result {
|
|
||||||
let empty = clean::PathSegment {
|
let empty = clean::PathSegment {
|
||||||
name: String::new(),
|
name: String::new(),
|
||||||
params: clean::PathParameters::Parenthesized {
|
params: clean::PathParameters::Parenthesized {
|
||||||
@@ -499,13 +488,9 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
|
|||||||
} else {
|
} else {
|
||||||
root.push_str(&seg.name);
|
root.push_str(&seg.name);
|
||||||
root.push_str("/");
|
root.push_str("/");
|
||||||
if is_not_debug {
|
|
||||||
write!(w, "<a class=\"mod\" href=\"{}index.html\">{}</a>::",
|
write!(w, "<a class=\"mod\" href=\"{}index.html\">{}</a>::",
|
||||||
root,
|
root,
|
||||||
seg.name)?;
|
seg.name)?;
|
||||||
} else {
|
|
||||||
write!(w, "{}::", seg.name)?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -517,39 +502,21 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if w.alternate() {
|
if w.alternate() {
|
||||||
if is_not_debug {
|
|
||||||
write!(w, "{:#}{:#}", HRef::new(did, &last.name), last.params)?;
|
write!(w, "{:#}{:#}", HRef::new(did, &last.name), last.params)?;
|
||||||
} else {
|
} else {
|
||||||
write!(w, "{:?}{}", HRef::new(did, &last.name), last.params)?;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if is_not_debug {
|
|
||||||
let path = if use_absolute {
|
let path = if use_absolute {
|
||||||
match href(did) {
|
match href(did) {
|
||||||
Some((_, _, fqp)) => format!("{}::{}",
|
Some((_, _, fqp)) => {
|
||||||
fqp[..fqp.len()-1].join("::"),
|
format!("{}::{}",
|
||||||
HRef::new(did, fqp.last()
|
fqp[..fqp.len() - 1].join("::"),
|
||||||
.unwrap_or(&String::new()))),
|
HRef::new(did, fqp.last().unwrap_or(&String::new())))
|
||||||
|
}
|
||||||
None => format!("{}", HRef::new(did, &last.name)),
|
None => format!("{}", HRef::new(did, &last.name)),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
format!("{}", HRef::new(did, &last.name))
|
format!("{}", HRef::new(did, &last.name))
|
||||||
};
|
};
|
||||||
write!(w, "{}{}{}", if need_paren { "(" } else { "" }, path, last.params)?;
|
write!(w, "{}{}", path, last.params)?;
|
||||||
} else {
|
|
||||||
let path = if use_absolute {
|
|
||||||
match href(did) {
|
|
||||||
Some((_, _, fqp)) => format!("{:?}::{:?}",
|
|
||||||
fqp[..fqp.len()-1].join("::"),
|
|
||||||
HRef::new(did, fqp.last()
|
|
||||||
.unwrap_or(&String::new()))),
|
|
||||||
None => format!("{:?}", HRef::new(did, &last.name)),
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
format!("{:?}", HRef::new(did, &last.name))
|
|
||||||
};
|
|
||||||
write!(w, "{}{}{}", if need_paren { "(" } else { "" }, path, last.params)?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -600,17 +567,13 @@ fn primitive_link(f: &mut fmt::Formatter,
|
|||||||
|
|
||||||
/// Helper to render type parameters
|
/// Helper to render type parameters
|
||||||
fn tybounds(w: &mut fmt::Formatter,
|
fn tybounds(w: &mut fmt::Formatter,
|
||||||
typarams: &Option<Vec<clean::TyParamBound>>,
|
typarams: &Option<Vec<clean::TyParamBound>>) -> fmt::Result {
|
||||||
need_paren: bool) -> fmt::Result {
|
|
||||||
match *typarams {
|
match *typarams {
|
||||||
Some(ref params) => {
|
Some(ref params) => {
|
||||||
for param in params {
|
for param in params {
|
||||||
write!(w, " + ")?;
|
write!(w, " + ")?;
|
||||||
fmt::Display::fmt(param, w)?;
|
fmt::Display::fmt(param, w)?;
|
||||||
}
|
}
|
||||||
if need_paren {
|
|
||||||
write!(w, ")")?;
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
None => Ok(())
|
None => Ok(())
|
||||||
@@ -637,30 +600,18 @@ impl<'a> fmt::Display for HRef<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> fmt::Debug for HRef<'a> {
|
fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt::Result {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "{}", self.text)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
|
|
||||||
is_not_debug: bool, is_ref: bool) -> fmt::Result {
|
|
||||||
match *t {
|
match *t {
|
||||||
clean::Generic(ref name) => {
|
clean::Generic(ref name) => {
|
||||||
f.write_str(name)
|
f.write_str(name)
|
||||||
}
|
}
|
||||||
clean::ResolvedPath{ did, ref typarams, ref path, is_generic } => {
|
clean::ResolvedPath{ did, ref typarams, ref path, is_generic } => {
|
||||||
// Paths like T::Output and Self::Output should be rendered with all segments
|
// Paths like T::Output and Self::Output should be rendered with all segments
|
||||||
let need_paren = match *typarams {
|
resolved_path(f, did, path, is_generic, use_absolute)?;
|
||||||
Some(ref v) => !v.is_empty(),
|
tybounds(f, typarams)
|
||||||
_ => false,
|
|
||||||
} && is_ref;
|
|
||||||
resolved_path(f, did, path, is_generic, use_absolute, is_not_debug, need_paren)?;
|
|
||||||
tybounds(f, typarams, need_paren)
|
|
||||||
}
|
}
|
||||||
clean::Infer => write!(f, "_"),
|
clean::Infer => write!(f, "_"),
|
||||||
clean::Primitive(prim) if is_not_debug => primitive_link(f, prim, prim.as_str()),
|
clean::Primitive(prim) => primitive_link(f, prim, prim.as_str()),
|
||||||
clean::Primitive(prim) => write!(f, "{}", prim.as_str()),
|
|
||||||
clean::BareFunction(ref decl) => {
|
clean::BareFunction(ref decl) => {
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
write!(f, "{}{}fn{:#}{:#}",
|
write!(f, "{}{}fn{:#}{:#}",
|
||||||
@@ -678,30 +629,26 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
|
|||||||
}
|
}
|
||||||
clean::Tuple(ref typs) => {
|
clean::Tuple(ref typs) => {
|
||||||
match &typs[..] {
|
match &typs[..] {
|
||||||
&[] if is_not_debug => primitive_link(f, PrimitiveType::Tuple, "()"),
|
&[] => primitive_link(f, PrimitiveType::Tuple, "()"),
|
||||||
&[] => write!(f, "()"),
|
&[ref one] => {
|
||||||
&[ref one] if is_not_debug => {
|
|
||||||
primitive_link(f, PrimitiveType::Tuple, "(")?;
|
primitive_link(f, PrimitiveType::Tuple, "(")?;
|
||||||
//carry f.alternate() into this display w/o branching manually
|
//carry f.alternate() into this display w/o branching manually
|
||||||
fmt::Display::fmt(one, f)?;
|
fmt::Display::fmt(one, f)?;
|
||||||
primitive_link(f, PrimitiveType::Tuple, ",)")
|
primitive_link(f, PrimitiveType::Tuple, ",)")
|
||||||
}
|
}
|
||||||
&[ref one] => write!(f, "({:?},)", one),
|
many => {
|
||||||
many if is_not_debug => {
|
|
||||||
primitive_link(f, PrimitiveType::Tuple, "(")?;
|
primitive_link(f, PrimitiveType::Tuple, "(")?;
|
||||||
fmt::Display::fmt(&CommaSep(&many), f)?;
|
fmt::Display::fmt(&CommaSep(&many), f)?;
|
||||||
primitive_link(f, PrimitiveType::Tuple, ")")
|
primitive_link(f, PrimitiveType::Tuple, ")")
|
||||||
}
|
}
|
||||||
many => write!(f, "({:?})", &CommaSep(&many)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clean::Vector(ref t) if is_not_debug => {
|
clean::Vector(ref t) => {
|
||||||
primitive_link(f, PrimitiveType::Slice, "[")?;
|
primitive_link(f, PrimitiveType::Slice, "[")?;
|
||||||
fmt::Display::fmt(t, f)?;
|
fmt::Display::fmt(t, f)?;
|
||||||
primitive_link(f, PrimitiveType::Slice, "]")
|
primitive_link(f, PrimitiveType::Slice, "]")
|
||||||
}
|
}
|
||||||
clean::Vector(ref t) => write!(f, "[{:?}]", t),
|
clean::FixedVector(ref t, ref s) => {
|
||||||
clean::FixedVector(ref t, ref s) if is_not_debug => {
|
|
||||||
primitive_link(f, PrimitiveType::Array, "[")?;
|
primitive_link(f, PrimitiveType::Array, "[")?;
|
||||||
fmt::Display::fmt(t, f)?;
|
fmt::Display::fmt(t, f)?;
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
@@ -712,17 +659,10 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
|
|||||||
&format!("; {}]", Escape(s)))
|
&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::Never => f.write_str("!"),
|
||||||
clean::RawPointer(m, ref t) => {
|
clean::RawPointer(m, ref t) => {
|
||||||
match **t {
|
match **t {
|
||||||
clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} if is_not_debug => {
|
clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} => {
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
primitive_link(f, clean::PrimitiveType::RawPointer,
|
primitive_link(f, clean::PrimitiveType::RawPointer,
|
||||||
&format!("*{}{:#}", RawMutableSpace(m), t))
|
&format!("*{}{:#}", RawMutableSpace(m), t))
|
||||||
@@ -731,21 +671,11 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
|
|||||||
&format!("*{}{}", RawMutableSpace(m), t))
|
&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,
|
primitive_link(f, clean::PrimitiveType::RawPointer,
|
||||||
&format!("*{}", RawMutableSpace(m)))?;
|
&format!("*{}", RawMutableSpace(m)))?;
|
||||||
fmt::Display::fmt(t, f)
|
fmt::Display::fmt(t, f)
|
||||||
}
|
}
|
||||||
_ => {
|
|
||||||
write!(f, "*{}{:?}", RawMutableSpace(m), t)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clean::BorrowedRef{ lifetime: ref l, mutability, type_: ref ty} => {
|
clean::BorrowedRef{ lifetime: ref l, mutability, type_: ref ty} => {
|
||||||
@@ -757,7 +687,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
|
|||||||
match **ty {
|
match **ty {
|
||||||
clean::Vector(ref bt) => { // BorrowedRef{ ... Vector(T) } is &[T]
|
clean::Vector(ref bt) => { // BorrowedRef{ ... Vector(T) } is &[T]
|
||||||
match **bt {
|
match **bt {
|
||||||
clean::Generic(_) if is_not_debug => {
|
clean::Generic(_) => {
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
primitive_link(f, PrimitiveType::Slice,
|
primitive_link(f, PrimitiveType::Slice,
|
||||||
&format!("&{}{}[{:#}]", lt, m, **bt))
|
&format!("&{}{}[{:#}]", lt, m, **bt))
|
||||||
@@ -766,14 +696,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
|
|||||||
&format!("&{}{}[{}]", lt, m, **bt))
|
&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() {
|
if f.alternate() {
|
||||||
primitive_link(f, PrimitiveType::Slice,
|
primitive_link(f, PrimitiveType::Slice,
|
||||||
&format!("&{}{}[", lt, m))?;
|
&format!("&{}{}[", lt, m))?;
|
||||||
@@ -785,26 +708,25 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
|
|||||||
}
|
}
|
||||||
primitive_link(f, PrimitiveType::Slice, "]")
|
primitive_link(f, PrimitiveType::Slice, "]")
|
||||||
}
|
}
|
||||||
_ => {
|
|
||||||
if f.alternate() {
|
|
||||||
write!(f, "&{}{}[{:#?}]", lt, m, **bt)
|
|
||||||
} else {
|
|
||||||
write!(f, "&{}{}[{:?}]", lt, m, **bt)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
clean::ResolvedPath { typarams: Some(ref v), .. } if !v.is_empty() => {
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
write!(f, "&{}{}", lt, m)?;
|
write!(f, "&{}{}", lt, m)?;
|
||||||
fmt_type(&ty, f, use_absolute, is_not_debug, true)
|
|
||||||
} else {
|
} else {
|
||||||
if is_not_debug {
|
|
||||||
write!(f, "&{}{}", lt, m)?;
|
write!(f, "&{}{}", lt, m)?;
|
||||||
} else {
|
|
||||||
write!(f, "&{}{}", lt, m)?;
|
|
||||||
}
|
}
|
||||||
fmt_type(&ty, f, use_absolute, is_not_debug, true)
|
write!(f, "(")?;
|
||||||
|
fmt_type(&ty, f, use_absolute)?;
|
||||||
|
write!(f, ")")
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "&{}{}", lt, m)?;
|
||||||
|
fmt_type(&ty, f, use_absolute)
|
||||||
|
} else {
|
||||||
|
write!(f, "&{}{}", lt, m)?;
|
||||||
|
fmt_type(&ty, f, use_absolute)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -833,33 +755,17 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
|
|||||||
_ => true,
|
_ => true,
|
||||||
};
|
};
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
if is_not_debug {
|
|
||||||
if should_show_cast {
|
if should_show_cast {
|
||||||
write!(f, "<{:#} as {:#}>::", self_type, trait_)?
|
write!(f, "<{:#} as {:#}>::", self_type, trait_)?
|
||||||
} else {
|
} else {
|
||||||
write!(f, "{:#}::", self_type)?
|
write!(f, "{:#}::", self_type)?
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if should_show_cast {
|
|
||||||
write!(f, "<{:#?} as {:#?}>::", self_type, trait_)?
|
|
||||||
} else {
|
|
||||||
write!(f, "{:#?}::", self_type)?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if is_not_debug {
|
|
||||||
if should_show_cast {
|
if should_show_cast {
|
||||||
write!(f, "<{} as {}>::", self_type, trait_)?
|
write!(f, "<{} as {}>::", self_type, trait_)?
|
||||||
} else {
|
} else {
|
||||||
write!(f, "{}::", self_type)?
|
write!(f, "{}::", self_type)?
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if should_show_cast {
|
|
||||||
write!(f, "<{:?} as {:?}>::", self_type, trait_)?
|
|
||||||
} else {
|
|
||||||
write!(f, "{:?}::", self_type)?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
match *trait_ {
|
match *trait_ {
|
||||||
// It's pretty unsightly to look at `<A as B>::C` in output, and
|
// It's pretty unsightly to look at `<A as B>::C` in output, and
|
||||||
@@ -874,7 +780,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
|
|||||||
// look at).
|
// look at).
|
||||||
box clean::ResolvedPath { did, ref typarams, .. } => {
|
box clean::ResolvedPath { did, ref typarams, .. } => {
|
||||||
let path = clean::Path::singleton(name.clone());
|
let path = clean::Path::singleton(name.clone());
|
||||||
resolved_path(f, did, &path, true, use_absolute, is_not_debug, false)?;
|
resolved_path(f, did, &path, true, use_absolute)?;
|
||||||
|
|
||||||
// FIXME: `typarams` are not rendered, and this seems bad?
|
// FIXME: `typarams` are not rendered, and this seems bad?
|
||||||
drop(typarams);
|
drop(typarams);
|
||||||
@@ -893,13 +799,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
|
|||||||
|
|
||||||
impl fmt::Display for clean::Type {
|
impl fmt::Display for clean::Type {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
fmt_type(self, f, false, true, false)
|
fmt_type(self, f, false)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for clean::Type {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
fmt_type(self, f, false, false, false)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -933,7 +833,7 @@ fn fmt_impl(i: &clean::Impl,
|
|||||||
write!(f, " for ")?;
|
write!(f, " for ")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt_type(&i.for_, f, use_absolute, true, false)?;
|
fmt_type(&i.for_, f, use_absolute)?;
|
||||||
|
|
||||||
fmt::Display::fmt(&WhereClause { gens: &i.generics, indent: 0, end_newline: true }, f)?;
|
fmt::Display::fmt(&WhereClause { gens: &i.generics, indent: 0, end_newline: true }, f)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -1139,7 +1039,7 @@ impl fmt::Display for clean::Import {
|
|||||||
impl fmt::Display for clean::ImportSource {
|
impl fmt::Display for clean::ImportSource {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self.did {
|
match self.did {
|
||||||
Some(did) => resolved_path(f, did, &self.path, true, false, true, false),
|
Some(did) => resolved_path(f, did, &self.path, true, false),
|
||||||
_ => {
|
_ => {
|
||||||
for (i, seg) in self.path.segments.iter().enumerate() {
|
for (i, seg) in self.path.segments.iter().enumerate() {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
|
|||||||
@@ -1662,9 +1662,9 @@ fn md_render_assoc_item(item: &clean::Item) -> String {
|
|||||||
match item.inner {
|
match item.inner {
|
||||||
clean::AssociatedConstItem(ref ty, ref default) => {
|
clean::AssociatedConstItem(ref ty, ref default) => {
|
||||||
if let Some(default) = default.as_ref() {
|
if let Some(default) = default.as_ref() {
|
||||||
format!("```\n{}: {:?} = {}\n```\n\n", item.name.as_ref().unwrap(), ty, default)
|
format!("```\n{}: {:#} = {}\n```\n\n", item.name.as_ref().unwrap(), ty, default)
|
||||||
} else {
|
} else {
|
||||||
format!("```\n{}: {:?}\n```\n\n", item.name.as_ref().unwrap(), ty)
|
format!("```\n{}: {:#}\n```\n\n", item.name.as_ref().unwrap(), ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => String::new(),
|
_ => String::new(),
|
||||||
|
|||||||
@@ -26,3 +26,21 @@ impl Bar {
|
|||||||
// @has - '//*[@class="docblock"]' 'BAR: usize = 3'
|
// @has - '//*[@class="docblock"]' 'BAR: usize = 3'
|
||||||
pub const BAR: usize = 3;
|
pub const BAR: usize = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct Baz<'a, U: 'a, T>(T, &'a [U]);
|
||||||
|
|
||||||
|
impl Bar {
|
||||||
|
// @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAZ"]' \
|
||||||
|
// "const BAZ: Baz<'static, u8, u32>"
|
||||||
|
// @has - '//*[@class="docblock"]' "BAZ: Baz<'static, u8, u32> = Baz(321, &[1, 2, 3])"
|
||||||
|
pub const BAZ: Baz<'static, u8, u32> = Baz(321, &[1, 2, 3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn f(_: &(ToString + 'static)) {}
|
||||||
|
|
||||||
|
impl Bar {
|
||||||
|
// @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.F"]' \
|
||||||
|
// "const F: fn(_: &(ToString + 'static))"
|
||||||
|
// @has - '//*[@class="docblock"]' "F: fn(_: &(ToString + 'static)) = f"
|
||||||
|
pub const F: fn(_: &(ToString + 'static)) = f;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user