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

rustdoc fails on tokio 1.33.0 with --cfg=docsrs since nightly-2023-10-31 #117622

Closed
oxalica opened this issue Nov 5, 2023 · 3 comments
Closed
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@oxalica
Copy link
Contributor

oxalica commented Nov 5, 2023

Code

Cargo.toml:

# ..headers omitted
[dependencies]
tokio = { version = "=1.33.0", features = ["net"] }

src/lib.rs is empty.

Run RUSTDOCFLAGS='--cfg=docsrs' cargo doc.

I expected to see this happen: success without any error.

Instead, this happened:

[..]
 Documenting tokio v1.33.0
error[E0277]: the trait bound `doc::NotDefinedHere: mio::event::Source` is not satisfied
   --> <whatever>/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/net/windows/named_pipe.rs:104:9
    |
104 |     io: PollEvented<mio_windows::NamedPipe>,
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `mio::event::Source` is not implemented for `doc::NotDefinedHere`
    |
    = help: the following other types implement trait `mio::event::Source`:
              std::boxed::Box<T>
              mio::unix::SourceFd<'a>
              mio::unix::pipe::Sender
              mio::unix::pipe::Receiver
              mio::io_source::IoSource<T>
              mio::net::TcpListener
              mio::net::TcpStream
              mio::net::UdpSocket
            and 3 others
note: required by a bound in `io::poll_evented::PollEvented`
   --> <whatever>/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/io/poll_evented.rs:65:38
    |
65  |     pub(crate) struct PollEvented<E: Source> {
    |                                      ^^^^^^ required by this bound in `PollEvented`

error[E0277]: the trait bound `doc::NotDefinedHere: mio::event::Source` is not satisfied
   --> <whatever>/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/net/windows/named_pipe.rs:977:9
    |
977 |     io: PollEvented<mio_windows::NamedPipe>,
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `mio::event::Source` is not implemented for `doc::NotDefinedHere`
    |
    = help: the following other types implement trait `mio::event::Source`:
              std::boxed::Box<T>
              mio::unix::SourceFd<'a>
              mio::unix::pipe::Sender
              mio::unix::pipe::Receiver
              mio::io_source::IoSource<T>
              mio::net::TcpListener
              mio::net::TcpStream
              mio::net::UdpSocket
            and 3 others
note: required by a bound in `io::poll_evented::PollEvented`
   --> <whatever>/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/io/poll_evented.rs:65:38
    |
65  |     pub(crate) struct PollEvented<E: Source> {
    |                                      ^^^^^^ required by this bound in `PollEvented`

For more information about this error, try `rustc --explain E0277`.
error: could not document `tokio`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2021 --crate-type lib --crate-name tokio <whatever>/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.33.0/src/lib.rs --cap-lints allow -o <whatever>/target/doc --cfg 'feature="default"' --cfg 'feature="libc"' --cfg 'feature="mio"' --cfg 'feature="net"' --cfg 'feature="socket2"' --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=127 -C metadata=6d4124359ab93408 -L dependency=<whatever>/target/debug/deps --extern libc=<whatever>/target/debug/deps/liblibc-02ca9efcb1ab59f3.rmeta --extern mio=<whatever>/target/debug/deps/libmio-de01690419bd3c4f.rmeta --extern pin_project_lite=<whatever>/target/debug/deps/libpin_project_lite-6c4ee879e3ffa189.rmeta --extern socket2=<whatever>/target/debug/deps/libsocket2-c2e9deaac3e208ee.rmeta --cfg=docsrs --crate-version 1.33.0` (exit status: 1)

Version it worked on

It most recently worked on:

> rustdoc --version --verbose
rustdoc 1.75.0-nightly (31bc7e2c4 2023-10-30)
binary: rustdoc
commit-hash: 31bc7e2c47e82798a392c770611975a6883132c8
commit-date: 2023-10-30
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.3

Version with regression

> rustdoc --version --verbose
rustdoc 1.75.0-nightly (9d83ac217 2023-10-31)
binary: rustdoc
commit-hash: 9d83ac217957eece2189eccf4a7232caec7232ee
commit-date: 2023-10-31
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.3

Context

  1. I'm initially using --cfg docsrs mainly for my own crate, but it's also accidentally used by tokio, which enables doc(cfg(..)) usage Tracking issue for #[doc(cfg(…))], #[doc(cfg_hide(…))] and doc_auto_cfg #43781. I guess it's related.

  2. I'm not fully sure this is an intended failure or not. But intuitively, rustdoc should not check trait bounds in private fields of private types.

  3. This failure is caught by CI in https://github.com/oxalica/async-lsp/actions/runs/6714596487/job/18248066086.

@oxalica oxalica added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Nov 5, 2023
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 5, 2023
@saethlin saethlin added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Nov 6, 2023
@saethlin
Copy link
Member

saethlin commented Nov 6, 2023

I'm not fully sure this is an intended failure or not. But intuitively, rustdoc should not check trait bounds in private fields of private types.

Are you asking for rustdoc to successfully render docs for code that doesn't compile? I would not expect that to work.

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 6, 2023
@oxalica
Copy link
Contributor Author

oxalica commented Nov 6, 2023

Are you asking for rustdoc to successfully render docs for code that doesn't compile? I would not expect that to work.

Yes. IIUC, cfg(doc(..)) is initially introduced to also document platform-specific modules which usually does not typecheck, thus it's a feature to suppress some kind of errors. In #43348 it applies everybody_loops, and since #73566 it suppress all resolution errors in fn bodies. For this intent, I'd consider it's expected to also ignore type errors in non-documented private struct.

@fmease
Copy link
Member

fmease commented Nov 6, 2023

I'm certain that this is due to #117450 which intentionally made rustdoc accept fewer invalid Rust programs.
See also this very relevant discussion on Zulip.

@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Nov 6, 2023
@fmease fmease removed C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Nov 6, 2023
@oxalica oxalica closed this as completed Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants