-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Description
Rustdoc currently renders automatic and explicit marker trait implementation bounds differently, for automatic implementations the bounds are simplified down to their most fundamental requirements, while explicit implementations show exactly what is specified.
As an example, here are two identically defined structs (Bar
and Baz
), one uses the automatic implementation for Send
while the other has the same implementation explicitly defined, in both cases the direct requirement is Foo<T>: Send
which can be simplified down to T: Send
by looking at the bounds on Foo
:
pub struct Foo<T>(T);
pub struct Bar<T>(Foo<T>);
pub struct Baz<T>(Foo<T>);
unsafe impl<T> Send for Baz<T> where Foo<T>: Send {}
and the associated impl Send
renderings:
This will become more relevant if RFC 2145 is ever implemented, that should allow bounds to refer to private types in which case there is no way to go from the impl Send for Baz
in the docs to see what the actual requirements are (but it is already possible to simulate that today if Foo
is moved into a private module).
This is also an issue for the proc-macro in https://github.com/taiki-e/pin-project (cc @taiki-e), that produces an explicit implementation for Unpin
that must refer to the field types so that it can work generically for any struct.