about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-10-11 21:42:17 +0000
committerbors <bors@rust-lang.org>2014-10-11 21:42:17 +0000
commit519e85b8a930b252e28a834574f9b4999d656798 (patch)
tree969d89462a42fa4fc393a29fe93278b827d61ca9
parentcd1fa91d2bf97a6331e1d0265eec0f3324191f89 (diff)
parentf40b60b0e46512e204225ce42c702ce23c943232 (diff)
downloadrust-519e85b8a930b252e28a834574f9b4999d656798.tar.gz
rust-519e85b8a930b252e28a834574f9b4999d656798.zip
auto merge of #17892 : nodakai/rust/rustdoc-dont-nest-a, r=alexcrichton
Some examples:

- `std::slice::slice`: [before](http://validator.w3.org/check?uri=http%3A%2F%2Fdoc.rust-lang.org%2Fstd%2Fslice%2Fprimitive.slice.html&charset=%28detect+automatically%29&doctype=Inline&group=0) and [after](http://validator.w3.org/check?uri=http%3A%2F%2Fnodakai.github.io%2Frust-f40b60b-doc%2Fstd%2Fslice%2Fprimitive.slice.html&charset=%28detect+automatically%29&doctype=Inline&group=0)
- `core::char::char`: [before](http://validator.w3.org/check?uri=http%3A%2F%2Fdoc.rust-lang.org%2Fcore%2Fchar%2Fprimitive.char.html&charset=%28detect+automatically%29&doctype=Inline&group=0) and [after](http://validator.w3.org/check?uri=http%3A%2F%2Fnodakai.github.io%2Frust-f40b60b-doc%2Fcore%2Fchar%2Fprimitive.char.html&charset=%28detect+automatically%29&doctype=Inline&group=0)
- `hexfloat::expand_syntax_ext`: [before](http://validator.w3.org/check?uri=http%3A%2F%2Fdoc.rust-lang.org%2Fhexfloat%2Ffn.expand_syntax_ext.html&charset=%28detect+automatically%29&doctype=Inline&group=0) and [after](http://validator.w3.org/check?uri=http%3A%2F%2Fnodakai.github.io%2Frust-f40b60b-doc%2Fhexfloat%2Ffn.expand_syntax_ext.html&charset=%28detect+automatically%29&doctype=Inline&group=0)

TODO: do the same for tuples.
-rw-r--r--src/librustdoc/html/format.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index ebccb1188cc..02ba4aabc99 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -478,7 +478,25 @@ impl fmt::Show for clean::Type {
                     Some(ref l) => format!("{} ", *l),
                     _ => "".to_string(),
                 };
-                write!(f, "&amp;{}{}{}", lt, MutableSpace(mutability), **ty)
+                let m = MutableSpace(mutability);
+                match **ty {
+                    clean::Vector(ref bt) => { // BorrowedRef{ ... Vector(T) } is &[T]
+                        match **bt {
+                            clean::Generic(_) =>
+                                primitive_link(f, clean::Slice,
+                                    format!("&amp;{}{}[{}]", lt, m, **bt).as_slice()),
+                            _ => {
+                                try!(primitive_link(f, clean::Slice,
+                                    format!("&amp;{}{}[", lt, m).as_slice()));
+                                try!(write!(f, "{}", **bt));
+                                primitive_link(f, clean::Slice, "]")
+                            }
+                        }
+                    }
+                    _ => {
+                        write!(f, "&amp;{}{}{}", lt, m, **ty)
+                    }
+                }
             }
             clean::Unique(..) => {
                 fail!("should have been cleaned")