Skip to content
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

Revisit docsrs settings now that cfg implies doc(cfg) #4163

Closed
asomers opened this issue Oct 9, 2021 · 5 comments · Fixed by #4193
Closed

Revisit docsrs settings now that cfg implies doc(cfg) #4163

asomers opened this issue Oct 9, 2021 · 5 comments · Fixed by #4193
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug. T-docs Topic: documentation

Comments

@asomers
Copy link
Contributor

asomers commented Oct 9, 2021

Description
A recent change to rustdoc makes #[cfg] now imply #[doc(cfg)]. That's handy for most crates, but makes Tokio's various cfg macros now partially redundant and somewhat confusing. In the best case, Tokio may be able to simply delete all of the docsrs stuff.
rust-lang/rust#89596

@asomers asomers added A-tokio Area: The main tokio crate C-bug Category: This is a bug. labels Oct 9, 2021
@Darksonn Darksonn added the T-docs Topic: documentation label Oct 10, 2021
@Darksonn
Copy link
Contributor

I worry if this will make some things documented incorrectly. For example, we might have a #[cfg(not(loom))] on something, or maybe we use cfgs to choose between two implementations depending on a feature flag. E.g. the #[tokio::main] macro that is visible in the documentation has an #[cfg(feature = "rt-multi-thread")] even though it exists without that feature flag.

@hawkw
Copy link
Member

hawkw commented Oct 10, 2021

I worry if this will make some things documented incorrectly. For example, we might have a #[cfg(not(loom))] on something, or maybe we use cfgs to choose between two implementations depending on a feature flag. E.g. the #[tokio::main] macro that is visible in the documentation has an #[cfg(feature = "rt-multi-thread")] even though it exists without that feature flag.

According to the linked PR, we can use #![doc(cfg_hide(loom))] to disable generating docs for the loom cfg, at least. I'm not sure how this will behave for definitions where two separate versions of that definition are enabled/disabled based on the cfg attribute, though...

@Noah-Kennedy
Copy link
Contributor

Does the change in rustdoc break anything for us, or just allow us to potentially simplify things?

@hawkw
Copy link
Member

hawkw commented Oct 11, 2021

Does the change in rustdoc break anything for us, or just allow us to potentially simplify things?

It shouldn't break builds, but it may result in incorrect docs in some places, I think? Per @Darksonn's comment, there are some places where we use #[doc(cfg(...))] attributes for APIs that require a cfg but are not actually compiled out based on that cfg.

@Darksonn
Copy link
Contributor

I ran cargo doc on Tokio using the nightly before and after this change. The following files were not identical:

doc/enum.NotDefinedHere.html
doc/index.html
doc/os/index.html
doc/os/windows/index.html
doc/os/windows/io/index.html
doc/os/windows/io/trait.AsRawHandle.html
doc/os/windows/io/trait.FromRawHandle.html
doc/os/windows/io/type.RawHandle.html
doc/winapi/index.html
doc/winapi/shared/index.html
doc/winapi/shared/winerror/index.html
doc/winapi/shared/winerror/type.ERROR_ACCESS_DENIED.html
doc/winapi/shared/winerror/type.ERROR_MORE_DATA.html
doc/winapi/shared/winerror/type.ERROR_PIPE_BUSY.html
doc/winapi/um/index.html
doc/winapi/um/minwinbase/index.html
doc/winapi/um/minwinbase/type.SECURITY_ATTRIBUTES.html
doc/winapi/um/winbase/index.html
doc/winapi/um/winbase/type.PIPE_CLIENT_END.html
doc/winapi/um/winbase/type.PIPE_SERVER_END.html
doc/winapi/um/winbase/type.PIPE_TYPE_BYTE.html
doc/winapi/um/winbase/type.PIPE_TYPE_MESSAGE.html
doc/winapi/um/winbase/type.SECURITY_IDENTIFICATION.html
index.html
io/struct.Interest.html
io/struct.Ready.html
net/fn.lookup_host.html
net/index.html
net/struct.TcpListener.html
net/struct.TcpSocket.html
net/struct.TcpStream.html
net/struct.UdpSocket.html
net/struct.UnixDatagram.html
net/struct.UnixListener.html
net/struct.UnixStream.html
net/tcp/index.html
net/tcp/struct.OwnedReadHalf.html
net/tcp/struct.OwnedWriteHalf.html
net/tcp/struct.ReadHalf.html
net/tcp/struct.ReuniteError.html
net/tcp/struct.WriteHalf.html
net/trait.ToSocketAddrs.html
net/unix/index.html
net/unix/struct.OwnedReadHalf.html
net/unix/struct.OwnedWriteHalf.html
net/unix/struct.ReadHalf.html
net/unix/struct.ReuniteError.html
net/unix/struct.SocketAddr.html
net/unix/struct.UCred.html
net/unix/struct.WriteHalf.html
net/windows/index.html
net/windows/named_pipe/enum.PipeEnd.html
net/windows/named_pipe/enum.PipeMode.html
net/windows/named_pipe/index.html
net/windows/named_pipe/struct.ClientOptions.html
net/windows/named_pipe/struct.NamedPipeClient.html
net/windows/named_pipe/struct.NamedPipeServer.html
net/windows/named_pipe/struct.PipeInfo.html
net/windows/named_pipe/struct.ServerOptions.html
runtime/struct.Builder.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug. T-docs Topic: documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants