-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustdoc: explicit marker trait impl bounds are not simplified #63281
Comments
Isn't this the correct behavior? With the automatically generated impl, there's no user-written impl for Rustdoc to render. When a user impl is provided, however, I think it makes sense to render exactly what they wrote. |
If there are usecases for showing exactly how the impl was written, then maybe there could be a flag to opt-in to the behaviour of the automatically generated impl? I have the extended problem I mentioned where it's impossible to determine what the bounds are from the docs in this crate, the |
If the bounds can be simplified in any of the following cases, I think the issues with pin-project can be resolved.
|
71: Do not display UnpinStruct in the document by default r=taiki-e a=taiki-e There are some problems as mentioned in #70 This causes the problem that by default the actual Unpin bounds cannot be known from the document if the original struct/enum itself is public (see #53 (comment) and rust-lang/rust#63281 for more). This can be enabled using `--cfg pin_project_show_unpin_struct` in RUSTFLAGS. ```toml # in Cargo.toml [package.metadata.docs.rs] rustdoc-args = ["--cfg", "pin_project_show_unpin_struct"] ``` cc @Aaron1011 @seanmonstar @LucioFranco Co-authored-by: Taiki Endo <[email protected]>
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
andBaz
), one uses the automatic implementation forSend
while the other has the same implementation explicitly defined, in both cases the direct requirement isFoo<T>: Send
which can be simplified down toT: Send
by looking at the bounds onFoo
: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 ifFoo
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.The text was updated successfully, but these errors were encountered: