Skip to content

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

Closed
@oxalica

Description

@oxalica

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions