about summary refs log tree commit diff
path: root/src/test/rustdoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-05-26 21:36:57 +0000
committerbors <bors@rust-lang.org>2015-05-26 21:36:57 +0000
commitcccc137b888af7561687aae7e6af3ed32461c160 (patch)
tree79f170a7e8f8c7fba46074d90c10396d867ec269 /src/test/rustdoc
parent1742a01f8d5717f1ab2f445c4d4656633b4c88b9 (diff)
parent06304ed52201ea0cae7a09f2546123c78a60a193 (diff)
downloadrust-cccc137b888af7561687aae7e6af3ed32461c160.tar.gz
rust-cccc137b888af7561687aae7e6af3ed32461c160.zip
Auto merge of #25675 - bluss:rustdoc-assoc-types-index, r=alexcrichton
rustdoc: Associated type fixes

The first commit fixes a bug with "dud" items in the search index from
misrepresented `type` items in trait impl blocks.

For a trait *implementation* there are typedefs which are the types for
that particular trait and implementor. Skip these in the search index.

There were lots of dud items in the search index due to this (search for
Item, Iterator's associated type).

Add a boolean to clean::TypedefItem so that it tracks whether the it is
a type alias on its own, or if it's a `type` item in a trait impl.

The second commit fixes a bug that made signatures and where bounds
using associated types (if they were not on `Self`) incorrect.

The third commit fixes so that where clauses in type alias definititons
are shown.

Fixes #22442
Fixes #24417
Fixes #25769
Diffstat (limited to 'src/test/rustdoc')
-rw-r--r--src/test/rustdoc/assoc-types.rs22
-rw-r--r--src/test/rustdoc/search-index.rs10
-rw-r--r--src/test/rustdoc/where.rs4
3 files changed, 36 insertions, 0 deletions
diff --git a/src/test/rustdoc/assoc-types.rs b/src/test/rustdoc/assoc-types.rs
index 20076a76494..d5047ade062 100644
--- a/src/test/rustdoc/assoc-types.rs
+++ b/src/test/rustdoc/assoc-types.rs
@@ -18,3 +18,25 @@ pub trait Index<I: ?Sized> {
     //      "fn index<'a>(&'a self, index: I) -> &'a Self::Output"
     fn index<'a>(&'a self, index: I) -> &'a Self::Output;
 }
+
+// @has assoc_types/fn.use_output.html
+// @has - '//*[@class="rust fn"]' '-> &T::Output'
+pub fn use_output<T: Index<usize>>(obj: &T, index: usize) -> &T::Output {
+    obj.index(index)
+}
+
+pub trait Feed {
+    type Input;
+}
+
+// @has assoc_types/fn.use_input.html
+// @has - '//*[@class="rust fn"]' 'T::Input'
+pub fn use_input<T: Feed>(_feed: &T, _element: T::Input) { }
+
+// @has assoc_types/fn.cmp_input.html
+// @has - '//*[@class="rust fn"]' 'where T::Input: PartialEq<U::Input>'
+pub fn cmp_input<T: Feed, U: Feed>(a: &T::Input, b: &U::Input) -> bool
+    where T::Input: PartialEq<U::Input>
+{
+    a == b
+}
diff --git a/src/test/rustdoc/search-index.rs b/src/test/rustdoc/search-index.rs
index 42469a21f22..70b77f6760d 100644
--- a/src/test/rustdoc/search-index.rs
+++ b/src/test/rustdoc/search-index.rs
@@ -10,6 +10,8 @@
 
 #![crate_name = "rustdoc_test"]
 
+use std::ops::Deref;
+
 // @has search-index.js Foo
 pub use private::Foo;
 
@@ -24,3 +26,11 @@ mod private {
         fn trait_method(&self) {} // @!has - priv_method
     }
 }
+
+pub struct Bar;
+
+impl Deref for Bar {
+    // @!has search-index.js Target
+    type Target = Bar;
+    fn deref(&self) -> &Bar { self }
+}
diff --git a/src/test/rustdoc/where.rs b/src/test/rustdoc/where.rs
index 3ce91d63300..91ec69d9a3c 100644
--- a/src/test/rustdoc/where.rs
+++ b/src/test/rustdoc/where.rs
@@ -42,3 +42,7 @@ pub enum Foxtrot<F> { Foxtrot1(F) }
 // @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//code' \
 //          "impl<F> MyTrait for Foxtrot<F> where F: MyTrait"
 impl<F> MyTrait for Foxtrot<F> where F: MyTrait {}
+
+// @has foo/type.Golf.html '//pre[@class="rust typedef"]' \
+//          "type Golf<T> where T: Clone = (T, T)"
+pub type Golf<T> where T: Clone = (T, T);