rustdoc: generate implementors for all auto traits
Previously we would only generate a list of synthetic implementations for two well known traits – Send and Sync. With this patch all the auto traits known to rustc are considered. This includes such traits like Unpin and user’s own traits. Sadly the implementation still iterates through the list of crate items and checks them against the traits, which for non-std crates containing their own auto-traits will still not include types defined in std/core. It is an improvement nontheless.
This commit is contained in:
parent
4fb77a0398
commit
4c8d00a3ec
8 changed files with 24 additions and 83 deletions
|
|
@ -8,3 +8,6 @@ pub struct Foo;
|
|||
// @!has - 'Auto Trait Implementations'
|
||||
impl !Send for Foo {}
|
||||
impl !Sync for Foo {}
|
||||
impl !std::marker::Unpin for Foo {}
|
||||
impl !std::panic::RefUnwindSafe for Foo {}
|
||||
impl !std::panic::UnwindSafe for Foo {}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ impl<B, C> Signal2 for B where B: Signal<Item = C> {
|
|||
// @has - '//code' 'impl<B> Send for Switch<B> where <B as Signal>::Item: Send'
|
||||
// @has - '//code' 'impl<B> Sync for Switch<B> where <B as Signal>::Item: Sync'
|
||||
// @count - '//*[@id="implementations-list"]/*[@class="impl"]' 0
|
||||
// @count - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]' 2
|
||||
// @count - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]' 5
|
||||
pub struct Switch<B: Signal> {
|
||||
pub inner: <B as Signal2>::Item2,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// @has - '//code' 'impl<T> Send for Foo<T> where T: Send'
|
||||
// @has - '//code' 'impl<T> Sync for Foo<T> where T: Sync'
|
||||
// @count - '//*[@id="implementations-list"]/*[@class="impl"]' 0
|
||||
// @count - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]' 2
|
||||
// @count - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]' 5
|
||||
pub struct Foo<T> {
|
||||
field: T,
|
||||
}
|
||||
|
|
|
|||
9
src/test/rustdoc/synthetic_auto/crate-local.rs
Normal file
9
src/test/rustdoc/synthetic_auto/crate-local.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#![feature(optin_builtin_traits)]
|
||||
|
||||
pub auto trait Banana {}
|
||||
|
||||
// @has crate_local/struct.Peach.html
|
||||
// @has - '//code' 'impl Banana for Peach'
|
||||
// @has - '//code' 'impl Send for Peach'
|
||||
// @has - '//code' 'impl Sync for Peach'
|
||||
pub struct Peach;
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
// 'impl<T> Send for Foo<T>'
|
||||
//
|
||||
// @count - '//*[@id="implementations-list"]/*[@class="impl"]' 1
|
||||
// @count - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]' 1
|
||||
// @count - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]' 4
|
||||
pub struct Foo<T> {
|
||||
field: T,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue