about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-07-21 01:41:22 +0000
committerbors <bors@rust-lang.org>2015-07-21 01:41:22 +0000
commit238765e1eb9dc1bd6ba4cc064b37f57207426e84 (patch)
tree19cc1495e7664218d59000d0dd4c79dd5514f04a /src
parent118a5c4c342883606fd96b121d741b133caa0347 (diff)
parenta3e78f4151ee23ad3175402e81247302619c1df7 (diff)
downloadrust-238765e1eb9dc1bd6ba4cc064b37f57207426e84.tar.gz
rust-238765e1eb9dc1bd6ba4cc064b37f57207426e84.zip
Auto merge of #27103 - wthrowe:doc_format, r=alexcrichton
This fixes a couple of bugs visible on https://doc.rust-lang.org/nightly/std/marker/trait.Sync.html .  For example:
* `impl<T> Sync for *const T` should read `impl<T> !Sync for *const T`
* `impl<T> !Sync for Weak<T>` should read `impl<T> !Sync for Weak<T> where T: ?Sized`

This does change a struct in librustdoc and it seems that almost everything there is marked public, so if librustdoc has stability guarantees that could be a problem.  If it is, I'll find a way to rework the change to avoid modifying public structures.
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/html/format.rs13
-rw-r--r--src/librustdoc/html/render.rs29
-rw-r--r--src/test/auxiliary/rustdoc-impl-parts-crosscrate.rs15
-rw-r--r--src/test/rustdoc/impl-parts-crosscrate.rs30
-rw-r--r--src/test/rustdoc/impl-parts.rs23
5 files changed, 86 insertions, 24 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index fc06dc347b5..2255a2e969f 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -540,6 +540,19 @@ impl fmt::Display for clean::Type {
     }
 }
 
+impl fmt::Display for clean::Impl {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        try!(write!(f, "impl{} ", self.generics));
+        if let Some(ref ty) = self.trait_ {
+            try!(write!(f, "{}{} for ",
+                        if self.polarity == Some(clean::ImplPolarity::Negative) { "!" } else { "" },
+                        *ty));
+        }
+        try!(write!(f, "{}{}", self.for_, WhereClause(&self.generics)));
+        Ok(())
+    }
+}
+
 impl fmt::Display for clean::Arguments {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         for (i, input) in self.values.iter().enumerate() {
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 07e3ae975d6..57c0db8f96e 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -118,11 +118,8 @@ pub enum ExternalLocation {
 /// Metadata about an implementor of a trait.
 pub struct Implementor {
     pub def_id: ast::DefId,
-    pub generics: clean::Generics,
-    pub trait_: clean::Type,
-    pub for_: clean::Type,
     pub stability: Option<clean::Stability>,
-    pub polarity: Option<clean::ImplPolarity>,
+    pub impl_: clean::Impl,
 }
 
 /// Metadata about implementations for a type.
@@ -644,10 +641,7 @@ fn write_shared(cx: &Context,
             // going on). If they're in different crates then the crate defining
             // the trait will be interested in our implementation.
             if imp.def_id.krate == did.krate { continue }
-            try!(write!(&mut f, r#""impl{} {}{} for {}","#,
-                        imp.generics,
-                        if imp.polarity == Some(clean::ImplPolarity::Negative) { "!" } else { "" },
-                        imp.trait_, imp.for_));
+            try!(write!(&mut f, r#""{}","#, imp.impl_));
         }
         try!(writeln!(&mut f, r"];"));
         try!(writeln!(&mut f, "{}", r"
@@ -888,11 +882,8 @@ impl DocFolder for Cache {
                 Some(clean::ResolvedPath{ did, .. }) => {
                     self.implementors.entry(did).or_insert(vec![]).push(Implementor {
                         def_id: item.def_id,
-                        generics: i.generics.clone(),
-                        trait_: i.trait_.as_ref().unwrap().clone(),
-                        for_: i.for_.clone(),
                         stability: item.stability.clone(),
-                        polarity: i.polarity.clone(),
+                        impl_: i.clone(),
                     });
                 }
                 Some(..) | None => {}
@@ -1910,8 +1901,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
     match cache.implementors.get(&it.def_id) {
         Some(implementors) => {
             for i in implementors {
-                try!(writeln!(w, "<li><code>impl{} {} for {}{}</code></li>",
-                              i.generics, i.trait_, i.for_, WhereClause(&i.generics)));
+                try!(writeln!(w, "<li><code>{}</code></li>", i.impl_));
             }
         }
         None => {}
@@ -2335,16 +2325,7 @@ fn render_deref_methods(w: &mut fmt::Formatter, impl_: &Impl) -> fmt::Result {
 fn render_impl(w: &mut fmt::Formatter, i: &Impl, link: AssocItemLink,
                render_header: bool) -> fmt::Result {
     if render_header {
-        try!(write!(w, "<h3 class='impl'><code>impl{} ",
-                    i.impl_.generics));
-        if let Some(clean::ImplPolarity::Negative) = i.impl_.polarity {
-            try!(write!(w, "!"));
-        }
-        if let Some(ref ty) = i.impl_.trait_ {
-            try!(write!(w, "{} for ", *ty));
-        }
-        try!(write!(w, "{}{}</code></h3>", i.impl_.for_,
-                    WhereClause(&i.impl_.generics)));
+        try!(write!(w, "<h3 class='impl'><code>{}</code></h3>", i.impl_));
         if let Some(ref dox) = i.dox {
             try!(write!(w, "<div class='docblock'>{}</div>", Markdown(dox)));
         }
diff --git a/src/test/auxiliary/rustdoc-impl-parts-crosscrate.rs b/src/test/auxiliary/rustdoc-impl-parts-crosscrate.rs
new file mode 100644
index 00000000000..6e8f80c8f5f
--- /dev/null
+++ b/src/test/auxiliary/rustdoc-impl-parts-crosscrate.rs
@@ -0,0 +1,15 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(optin_builtin_traits)]
+
+pub trait AnOibit {}
+
+impl AnOibit for .. {}
diff --git a/src/test/rustdoc/impl-parts-crosscrate.rs b/src/test/rustdoc/impl-parts-crosscrate.rs
new file mode 100644
index 00000000000..5fa2e03e0a8
--- /dev/null
+++ b/src/test/rustdoc/impl-parts-crosscrate.rs
@@ -0,0 +1,30 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:rustdoc-impl-parts-crosscrate.rs
+// ignore-cross-compile
+
+#![feature(optin_builtin_traits)]
+
+extern crate rustdoc_impl_parts_crosscrate;
+
+pub struct Bar<T> { t: T }
+
+// The output file is html embeded in javascript, so the html tags
+// aren't stripped by the processing script and we can't check for the
+// full impl string.  Instead, just make sure something from each part
+// is mentioned.
+
+// @has implementors/rustdoc_impl_parts_crosscrate/trait.AnOibit.js Bar
+// @has - Send
+// @has - !AnOibit
+// @has - Copy
+impl<T: Send> !rustdoc_impl_parts_crosscrate::AnOibit for Bar<T>
+    where T: Copy {}
diff --git a/src/test/rustdoc/impl-parts.rs b/src/test/rustdoc/impl-parts.rs
new file mode 100644
index 00000000000..89c5e60e343
--- /dev/null
+++ b/src/test/rustdoc/impl-parts.rs
@@ -0,0 +1,23 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(optin_builtin_traits)]
+
+pub trait AnOibit {}
+
+impl AnOibit for .. {}
+
+pub struct Foo<T> { field: T }
+
+// @has impl_parts/struct.Foo.html '//*[@class="impl"]//code' \
+//     "impl<T: Clone> !AnOibit for Foo<T> where T: Sync"
+// @has impl_parts/trait.AnOibit.html '//*[@class="item-list"]//code' \
+//     "impl<T: Clone> !AnOibit for Foo<T> where T: Sync"
+impl<T: Clone> !AnOibit for Foo<T> where T: Sync {}