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
This commit is contained in:
commit
cccc137b88
7 changed files with 83 additions and 28 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue