tokio-rs / tokio

A runtime for writing reliable asynchronous applications with Rust. Provides I/O, networking, scheduling, timers, ...
https://tokio.rs
MIT License
25.44k stars 2.3k forks source link

Unable to use the docsrs configuration under Windows #6625

Open Coding-Badly opened 4 weeks ago

Coding-Badly commented 4 weeks ago

Version 1.38.0

Platform Windows 11 Pro / 64 bit

Description On Windows, the documentation for a project using Tokio cannot be build with docsrs enabled. This makes it difficult-to-impossible to include the automatically generated feature flag details. More details are available from this post on the Rust Users forum.

A test project was created with cargo new tokio-issue-112683.

Cargo.toml was updated to this...

[package]
name = "tokio-issue-112683"
version = "0.1.0"
edition = "2021"

[dependencies]
tokio = { version = "1.38.0", features = ["full"] }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

Set the RUSTFLAGS environment variable... set RUSTFLAGS=--cfg docsrs

Then try to build the documentation... cargo +nightly doc --all-features

The error list is long...

    Checking tokio v1.38.0
error[E0433]: failed to resolve: could not find `unix` in `os`
  --> C:\Users\bcook\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tokio-1.38.0\src\io\bsd\poll_aio.rs:12:14
   |
12 | use std::os::unix::io::AsRawFd;
   |              ^^^^ could not find `unix` in `os`
   |
note: found an item that was configured out
  --> C:\Users\bcook\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\std\src\os\mod.rs:26:9
   |
26 | pub mod unix {}
   |         ^^^^
note: found an item that was configured out
  --> C:\Users\bcook\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\std\src\os\mod.rs:64:9
   |
64 | pub mod unix;
   |         ^^^^

error[E0433]: failed to resolve: could not find `unix` in `os`
  --> C:\Users\bcook\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tokio-1.38.0\src\io\bsd\poll_aio.rs:13:14
   |
13 | use std::os::unix::prelude::RawFd;
   |              ^^^^ could not find `unix` in `os`
   |
note: found an item that was configured out
  --> C:\Users\bcook\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\std\src\os\mod.rs:26:9
   |
26 | pub mod unix {}
   |         ^^^^
note: found an item that was configured out
  --> C:\Users\bcook\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\std\src\os\mod.rs:64:9
   |
64 | pub mod unix;
   |         ^^^^

...
Darksonn commented 4 weeks ago

I think that we should probably only support building docs that include items from all platforms on unix. But trying to build docs on windows should still successfully build docs for the things that are available on windows.